compressed_lists package¶
Submodules¶
compressed_lists.CompressedIntegerList module¶
- class compressed_lists.CompressedIntegerList.CompressedIntegerList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedList
CompressedList implementation for lists of integers.
- __abstractmethods__ = frozenset({})¶
- __init__(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Initialize a CompressedIntegerList.
- Parameters:
unlist_data (
ndarray
) – NumPy array of integers.partitioning (
Partitioning
) – Partitioning object defining element boundaries.element_metadata (
dict
) – Optional metadata for elements.metadata (
dict
) – Optional general metadata.kwargs – Additional arguments.
compressed_lists.CompressedList module¶
- class compressed_lists.CompressedList.CompressedList(unlist_data, partitioning, element_type=None, element_metadata=None, metadata=None, validate=True)[source]¶
Bases:
ABC
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.
- __abstractmethods__ = frozenset({'_extract_range', 'from_list'})¶
- __annotations__ = {}¶
- __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.element_type (
str
) – String identifier for the type of elements.element_metadata (
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_subset(indices)[source]¶
Extract a subset of elements by indices.
- Parameters:
indices – Sequence of indices to extract.
- Returns:
A new CompressedList with only the selected elements.
- abstractmethod 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.
- Parameters:
lst – List to convert.
names – Optional names for list elements.
metadata – Optional metadata.
- Returns:
A new CompressedList.
- 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 – Function to apply to each element.
- 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 – New unlisted data.
- 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.CompressedStringList module¶
- class compressed_lists.CompressedStringList.CompressedStringList(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Bases:
CompressedList
CompressedList implementation for lists of strings.
- __abstractmethods__ = frozenset({})¶
- __annotations__ = {}¶
- __init__(unlist_data, partitioning, element_metadata=None, metadata=None, **kwargs)[source]¶
Initialize a CompressedStringList.
- Parameters:
partitioning (
Partitioning
) – Partitioning object defining element boundaries.element_metadata (
dict
) – Optional metadata for elements.metadata (
dict
) – Optional general metadata.kwargs – Additional arguments.
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: Names | None¶
Alias for
get_starts
, provided for back-compatibility.