bioalpha.h5ad_map.BatchReader

class bioalpha.h5ad_map.BatchReader(dataset: Dataset | SparseDataset, batch_size: int | None = None, max_nnz_allow: int | None = None, shuffle: bool = False, seed: int = 42, row_mask: ndarray | None = None, col_mask: ndarray | None = None, keep_shape: bool = False)

BatchReader

The common reader of backed dataset.

Examples

>>> reader = BatchReader(f["X"])
>>> for loaded in reader:
...   # do some things here
>>> reader.n_loaded
2700
>>> # Another method for traversing reader
>>> reader.reset()
>>> reader.load()
>>> # do some things here
>>> reader.n_loaded
1000
>>> reader.size
2700

Methods

load()

Load next chunk of dataset.

n_loaded()

Time of loads with no shuffle.

reset()

Reset the loader.

Attributes

n_loads

Compute time of loads.

shuffle_ids

Get index of shuffle loader.

size

Size of loader (E.g n_cols if dataset is csc_matrix.).