PROS
Partitioned and Refined Oversampling Sketches
Partition. Sample. Refine.
PROS selects a small, diversity-preserving subset of rows from a large real-valued coordinate matrix. It builds an oversampled candidate pool within partitions and performs one global refinement pass over that pool. The returned subset is represented by indices into the original matrix.
The package is domain-agnostic. It can be used with reduced single-cell embeddings, as well as other feature matrices where Euclidean distance is a meaningful geometry.
Installation
PROS requires Python 3.10 or newer. Install from PyPI:
pip install pros-sketch
The distribution name is pros-sketch; the Python import remains pros.
To install a local checkout for development:
python -m pip install -e .
Optional AnnData support:
python -m pip install -e ".[adata]"
For testing and linting:
python -m pip install -e ".[dev]"
Quick start
import numpy as np
from pros import sketch
X = np.random.default_rng(0).random((5_000, 50))
result = sketch(X, n=500, seed=0)
indices = result.indices
X_sketch = X[indices]
print(result.timings)
result.indices is a sorted, unique int64 array of length n. By default,
PROS uses k-means partitioning, water-filling allocation, an oversampling ratio
of r=10.0, and global farthest-first refinement. Pass an explicit seed to
make a stochastic configuration reproducible.
To discover the available knobs from Python, use the built-in help tools and the package option summary:
import inspect
import pros
help(pros.sketch)
print(inspect.signature(pros.sketch))
pros.options()
pros.options("partitioner")
Certification
Set certify=True to compute the final covering radius, the candidate-pool
radius, and bounds derived from a full-data farthest-first traversal:
result = sketch(X, n=500, seed=0, certify=True)
print(result.radius) # R(X, S): final covering radius
print(result.rho) # R(X, P): candidate-pool covering radius
print(result.opt_lower) # lower bound on the optimal n-centre radius
print(result.ratio_upper) # upper bound on R(X, S) / OPT_n(X)
Certification performs additional full-data work and is not included in
result.timings["total"]. Degenerate data may have opt_lower == 0; in that
case a finite approximation-ratio bound is not defined.
For an existing set of indices, use pros.certificate. pros.opt_bounds,
pros.estimate_opt_scale, and pros.choose_r are available for certificate
and oversampling-ratio workflows.
AnnData
from pros import sketch_adata
result = sketch_adata(adata, n=5_000, use_rep="X_pca", seed=0)
subset = adata[result.indices].copy()
sketch_adata also accepts an .h5ad path and reads it in backed mode before
extracting the requested representation.
Configuration
result = sketch(
X,
n=1_000,
partitioner="kmeans",
n_blocks="auto",
allocator="water_filling",
r=10.0,
selector="fft",
refiner="fft",
seed=0,
)
The partitioner, within-partition selector, allocator, and global
refiner are modular. Run pros.options() to print every configurable
category, or pass a category such as pros.options("allocator") to focus on
one family. See docs/configuration.md for the
supported values and docs/theory.md for the covering
objective and certificate definitions.
In the current source, scsampler_maximin is available for both selector
and refiner and calls upstream scSampler. The maximin refiner is a separate
PROS swap heuristic initialized by FFT. For all four FFT/scSampler
combinations, use proportional allocation and see
examples/05_compare_optimizers.py.
The scSampler refiner is not included in the published 0.1.0 wheel; use the
checkout and follow the upstream dependency and NumPy compatibility notes in
docs/configuration.md.
Repository layout
pros/: installable library code.tests/: automated package tests.examples/: small runnable examples using synthetic data indata/.test_para/: standalone parameter experiments and their generated outputs; this reproduction material is intentionally not packaged with the library.docs/: MkDocs source pages.
Run the examples from the repository root after installation:
python examples/01_basic_numpy.py
python examples/03_certification.py
Citation
See CITATION.cff for software citation metadata.
License
PROS is distributed under the MIT License.
Validated behavior and limits
- Water-filling is fused with FFT and requires
selector="fft". Choose another allocator to use random or scSampler selection. Missing or broken scSampler installations raise an error; no alternate algorithm is substituted. mix>0currently requiresrefiner="fft"so reserved points are retained.refiner="none"uniformly downsamples the candidate pool tonrows.certificatecomputes the a posteriori ratio for any valid sketch. Itstheory_boundandbound_slackare NaN unless FFT refinement is explicitly asserted;sketchsets this assertion only for unmixed FFT refinement. Caches are tied to the exact data and sketch size. Floating-point results are numerical bounds, not interval-arithmetic certificates.- Internal stage timings exclude input conversion, validation, AnnData I/O, and certification. Measure an external wall clock for runtime comparisons.
sketch_adata(..., return_adata=True, copy=False)returns an in-memory view without attaching metadata. Backed subset returns requirecopy=True. Sparseuse_rep="X"is rejected; supply a dense reduced embedding instead.- Distances use SciPy directly and nearest-center evaluation tiles both axes.
Full input and block copies still require memory proportional to
N*d; optional swap refiners may allocate much larger matrices.
After installing development dependencies, run python -m pytest. Install
.[dev,adata] to include the optional AnnData integration regression test.
Metadata
Release files for pros-sketch 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pros_sketch-0.1.2.tar.gz | 1.6 MB | With provenance | Details for pros_sketch-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pros_sketch-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for pros_sketch-0.1.2-py3-none-any.whl |
Total release size: 1.6 MB
Release files / pros_sketch-0.1.2.tar.gz
| Download URL | pros_sketch-0.1.2.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7352427cf1265978eff5dd51cd4e3c58c6a7080bac7b3decd50fddc12f08664
|
|
BLAKE2b-256 checksum How to use checksums |
9890564602b69994ab24f5b9c900dac42e5bb576314296bc48568d5d690fb28e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / pros_sketch-0.1.2-py3-none-any.whl
| Download URL | pros_sketch-0.1.2-py3-none-any.whl |
|---|---|
| Size | 33.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e9595b33b17018ed820c84dcff90992d8edf15849e977c8831ec2f164121e32
|
|
BLAKE2b-256 checksum How to use checksums |
6accf63ccd492c3d6461fe31593264d3fceb3e4f4a9e9bd9e20228239312ccc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logSecurity for pros-sketch 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pros_sketch-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.