compressed_lists package¶
Submodules¶
compressed_lists.base module¶
- class compressed_lists.base.CompressedList(unlist_data, partitioning, element_type=None, element_metadata=None, metadata=None, validate=True)[source]¶
Bases:
object
Base class for compressed list objects.
CompressedList stores list elements concatenated in a single vector-like object with partitioning information that defines where each list element starts and ends.
- __init__(unlist_data, partitioning, element_type=None, element_metadata=None, metadata=None, validate=True)[source]¶
Initialize a CompressedList.
- Parameters:
unlist_data (
Any
) – Vector-like object containing concatenated elements.partitioning (
Partitioning
) – Partitioning object defining element boundaries (exclusive).element_type (
Any
) – class for the type of elements.element_metadata (
Optional
[dict
]) – Optional metadata for elements.validate (
bool
) – Internal use only.
- copy()[source]¶
Alias for
__copy__()
.
- property element_metadata: dict¶
Alias for
get_element_metadata
.
- property element_type: str¶
Alias for
get_element_type
, provided for back-compatibility.
- extract_range(start, end)[source]¶
Extract a range from unlist_data.
This method must be implemented by subclasses to handle type-specific extraction from unlist_data.
- extract_subset(indices)[source]¶
Extract a subset of elements by indices.
- Parameters:
- Return type:
- Returns:
A new CompressedList with only the selected elements.
- classmethod from_list(lst, names=None, metadata=None)[source]¶
Create a CompressedList from a regular list.
This method must be implemented by subclasses to handle type-specific conversion from list to unlist_data.
- get_element_metadata()[source]¶
- Return type:
- Returns:
Dictionary of metadata for each element in this object.
- lapply(func)[source]¶
Apply a function to each element.
- Parameters:
func (
Callable
) – Function to apply to each element.- Return type:
- Returns:
A new CompressedList with the results.
- property metadata: dict¶
Alias for
get_metadata
.
- property paritioning: Partitioning¶
Alias for
get_paritioning
, provided for back-compatibility.
- relist(unlist_data)[source]¶
Create a new CompressedList with the same partitioning but different data.
- Parameters:
unlist_data (
Any
) – New unlisted data.- Return type:
- Returns:
A new CompressedList.
- set_element_metadata(element_metadata, in_place=False)[source]¶
Set new element metadata.
- Parameters:
- Return type:
- Returns:
A modified
CompressedList
object, either as a copy of the original or as a reference to the (in-place-modified) original.
- set_metadata(metadata, in_place=False)[source]¶
Set additional metadata.
- Parameters:
- Return type:
- Returns:
A modified
CompressedList
object, either as a copy of the original or as a reference to the (in-place-modified) original.
- set_names(names, in_place=False)[source]¶
Set the names of list elements.
- names:
New names, same as the number of rows.
May be None to remove names.
- in_place:
Whether to modify the
CompressedList
in place.
- Return type:
- Returns:
A modified
CompressedList
object, either as a copy of the original or as a reference to the (in-place-modified) original.
- set_unlist_data(unlist_data, in_place=False)[source]¶
Set new list elements.
- Parameters:
- Return type:
- Returns:
A modified
CompressedList
object, either as a copy of the original or as a reference to the (in-place-modified) original.
- property unlist_data: Any¶
Alias for
get_unlist_data
.
compressed_lists.biocframe_list module¶
- class compressed_lists.biocframe_list.CompressedBiocFrameList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedList
CompressedList for BiocFrames.
- __annotations__ = {}¶
- __init__(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Initialize a CompressedBiocFrameList.
- Parameters:
unlist_data (
BiocFrame
) – BiocFrame object.partitioning (
Partitioning
) – Partitioning object defining element boundaries.element_metadata (
Optional
[dict
]) – Optional metadata for elements.kwargs – Additional arguments.
- extract_range(start, end)[source]¶
Extract a range from unlist_data.
This method must be implemented by subclasses to handle type-specific extraction from unlist_data.
compressed_lists.bool_list module¶
- class compressed_lists.bool_list.CompressedBooleanList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedList
CompressedList implementation for lists of booleans.
- __annotations__ = {}¶
- __init__(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Initialize a CompressedBooleanList.
- Parameters:
unlist_data (
BooleanList
) – List of booleans.partitioning (
Partitioning
) – Partitioning object defining element boundaries.element_metadata (
Optional
[dict
]) – Optional metadata for elements.kwargs – Additional arguments.
compressed_lists.float_list module¶
- class compressed_lists.float_list.CompressedFloatList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedList
CompressedList implementation for lists of floats.
- __annotations__ = {}¶
compressed_lists.integer_list module¶
- class compressed_lists.integer_list.CompressedIntegerList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedList
CompressedList implementation for lists of integers.
- __annotations__ = {}¶
- __init__(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Initialize a CompressedIntegerList.
- Parameters:
unlist_data (
IntegerList
) – List of integers.partitioning (
Partitioning
) – Partitioning object defining element boundaries.element_metadata (
Optional
[dict
]) – Optional metadata for elements.kwargs – Additional arguments.
compressed_lists.numpy_list module¶
- class compressed_lists.numpy_list.CompressedNumpyList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedList
CompressedList implementation for lists of NumPy vectors.
- __annotations__ = {}¶
- __init__(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Initialize a CompressedNumpyList.
compressed_lists.partition module¶
- class compressed_lists.partition.Partitioning(ends, names=None, validate=True)[source]¶
Bases:
object
Represents partitioning information for a CompressedList.
This is similar to the
PartitioningByEnd
class in Bioconductor. It keeps track of where each element begins and ends in the unlisted data.- copy()[source]¶
Alias for
__copy__()
.
- element_lengths()[source]¶
Alias for
get_element_lengths
.- Return type:
- classmethod from_lengths(lengths, names=None)[source]¶
Create a Partitioning from a sequence of lengths.
- classmethod from_list(lst, names=None)[source]¶
Create a Partitioning from a list by using the lengths of each element.
- Parameters:
- Return type:
- Returns:
A new Partitioning object.
- set_names(names, in_place=False)[source]¶
Set the names of list elements.
- Parameters:
- Return type:
- Returns:
A modified
Partitioning
object, either as a copy of the original or as a reference to the (in-place-modified) original.
- property starts: ndarray¶
Alias for
get_starts
, provided for back-compatibility.
compressed_lists.split_generic module¶
- compressed_lists.split_generic.groups_to_partition(data, groups, names=None)[source]¶
Convert group membership vector to partitioned data and Partitioning object.
- Parameters:
- Return type:
Tuple
[List
[Any
],Partitioning
]- Returns:
Tuple of (partitioned_data_list, partitioning_object)
- compressed_lists.split_generic.splitAsCompressedList(data, groups_or_partitions, names=None, metadata=None)[source]¶
Generic function to split data into an appropriate CompressedList subclass.
This function can work in two modes: 1. Group-based splitting where a flat vector is split according to group membership. 2. Partition-based splitting where a flat vector is split according to explicit partitions.
- Parameters:
data (
Any
) – The data to split into a CompressedList.groups_or_partitions (
Union
[list
,Partitioning
]) – Optional group membership vector (same length as data) or explicit partitioning object.names (
Optional
[Sequence
[str
]]) – Optional names for the list elements.metadata (
Optional
[dict
]) – Optional metadata for the CompressedList.
- Return type:
- Returns:
An appropriate CompressedList subclass instance.
compressed_lists.string_list module¶
- class compressed_lists.string_list.CompressedCharacterList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedStringList
- __annotations__ = {}¶
- class compressed_lists.string_list.CompressedStringList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedList
CompressedList implementation for lists of strings.
- __annotations__ = {}¶
- __init__(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Initialize a CompressedStringList.
- Parameters:
unlist_data (
StringList
) – List of strings.partitioning (
Partitioning
) – Partitioning object defining element boundaries.element_metadata (
Optional
[dict
]) – Optional metadata for elements.kwargs – Additional arguments.