Appearance
Python API reference
Start with the object that owns your result: a matrix view, a Tensor batch, or a leased NumPy batch. The module pages explain parameters, returns and ownership; their declaration sections come from current Python source and the native type stub. Use the guides for complete programs and expected output.
Find your entry point
- Read or write a matrixStoreLazy selections; decoding returns NumPy or CSR arrays.
- Feed a training loopScDataLoaderCorpus sampling and dictionaries of CPU or CUDA Tensors.
- Control native batch deliveryLoaderExplicit sources, schemas, planning and leased NumPy output.
- Build a custom encoded containerscansChunk and record codecs with explicit metadata and buffers.
Browse by responsibility
| Area | Main interfaces | Reference |
|---|---|---|
| Matrix storage and file tools | Store, File, Writer, CSR, read/write/compress, io CPK tools | Storage |
| Training Tensor batches | ScDataset, corpus Accesses, ScDataLoader | Training |
| Native NumPy loading | DataSource, OutputSchema, LoaderConfig, Loader | Loader |
| Sample sequences | Native Accesses and AccessFn | Access functions |
| Output memory and execution | RingLayout, Ring, Batch, Consumer, Run | Rings and lifecycle |
| Cache planning | PlanOptions, Plan, PageTrace, CostModel | Planning |
| Native row processing | ProcessFn, OutputLayout, model presets, compiler | Process functions |
| One-host shared loading | SharedRing, DistributedLoader, DistributedRun | Distributed |
| Diagnostics and calibration | RunStats, MemoryEstimate, profile reports, costs | Statistics |
| Chunk and record codecs | scans functions, metadata, tables, reusable encoder/decoder | Codecs |
| Annotated matrices | read_h5, write_h5cp, write_h5ad, open_matrix, AnnData | AnnData |
Imports and dependencies
The distribution and import name are both pycellpack. Common storage, training, planning and loading classes are re-exported at the root. Advanced ring/statistics interfaces live under pycellpack.loader; codecs live under pycellpack.cellpack.scans. The compiled _cellpack module is private.
Importing the root does not load SciPy, AnnData, h5py, pandas, PyTorch or Numba. Install the optional integration before using it. Torch is installed separately. See installation.
Conventions
Unless noted, counts are integers and byte sizes are bytes. Store selections are orthogonal and retain axes. Output IDs define column order; supply gene identity explicitly rather than relying on names or matching column positions.
| Name | Import | Identity space |
|---|---|---|
| Corpus sample order | from pycellpack import Accesses | Dataset ID and row within the dataset's Store view |
| Native access sequence | from pycellpack.loader import Accesses | Global cell ID assigned by DataSource |
These two Accesses types serve different layers. Use corpus accesses with ScDataLoader and native accesses with Loader.
Native validation uses ValueError (and Python input type errors use TypeError), I/O uses OSError, and worker/cancellation/busy-state failures use RuntimeError. Async execution errors can arise while iterating or joining. Callback build errors have the process-function exception classes.
For NumPy batch retention, read rings and lifecycle before starting a long run. For Tensor transfer and application integration, continue with the training programs.