scanpy-kernels
Rust-accelerated, numerically-verified kernels for Scanpy — single-cell RNA-seq analysis.
Correctness-first: every kernel must reproduce the reference Scanpy/NumPy
output within a strict tolerance (rtol=1e-7 for float64, rtol=1e-4 for
float32), be deterministic, and be validated against both synthetic and real
data.
Implemented kernels
| Kernel | Status |
|---|---|
pp.scale (per-gene standardization) |
✅ dense + sparse (CSR/CSC), float32/float64/integer |
pp.highly_variable_genes (Seurat flavor) |
✅ dense + sparse (CSR/CSC), float32/float64/integer |
Install
For researchers (prebuilt wheels, from PyPI)
pip install scanpy-kernels
No Rust or compiler needed. Prebuilt wheels are built for Linux, macOS (Intel + Apple Silicon) and Windows via GitHub Actions on every tagged release.
Then add two lines to any existing Scanpy script:
import scanpy_kernels
scanpy_kernels.install() # pp.scale & pp.highly_variable_genes now use Rust
For development (from source)
python -m venv .venv
source .venv/bin/activate
pip install maturin
maturin develop --release
Usage
import numpy as np
import scanpy_kernels
X = np.random.default_rng(0).standard_normal((1000, 100))
X_scaled = scanpy_kernels.scale(X, zero_center=True, max_value=10.0)
# Highly variable genes (Seurat flavor) on log1p data
hvg = scanpy_kernels.hvg_seurat(np.log1p(X), n_bins=20)
The public functions mirror Scanpy and accept dense NumPy arrays or scipy sparse (CSR/CSC) matrices:
scanpy_kernels.scale(x, *, zero_center=True, max_value=None, return_mean_std=False)
scanpy_kernels.hvg_seurat(x, *, n_bins=20, n_top_genes=None, min_disp=0.5,
max_disp=inf, min_mean=0.0125, max_mean=3.0, log_base=None)
Drop-in integration
Make existing Scanpy pipelines use the kernels transparently (with automatic fallback to Scanpy for anything unsupported):
import scanpy_kernels
scanpy_kernels.install() # patches scanpy.pp.scale and scanpy.pp.highly_variable_genes
# ... your normal scanpy.pp.scale(...) / scanpy.pp.highly_variable_genes(...) calls ...
scanpy_kernels.uninstall()
Verify
pytest tests/
Real-data validation
bench/validate_pbmc3k.py runs the kernels end-to-end on the published PBMC 3k
dataset and confirms identical results: same HVG selection, bit-identical
scaled matrix, and identical Leiden clusters (13 clusters).
Benchmark
python bench/bench_scale.py
python bench/bench_hvg.py
First-milestone results (Apple Silicon, release build) — see
BENCHMARKS.md for full details:
pp.scaledense: ~5× (float64), ~8–10× (float32)pp.highly_variable_genesdense: ~7–9×
Correctness notes
The kernel reproduces the reference exactly, including two non-obvious
behaviours of Scanpy 1.12.3's scale (documented and covered by tests):
- Variance uses the naive
E[X^2] - E[X]^2formula (not two-pass), which can round to a tiny negative number for constant genes with non-exactly representable values — the reference then emitsNaN, and so does this kernel. - For
float32input,x**2is computed infloat32before being summed infloat64; the kernel matches this dtype behaviour.
Release files for scanpy-kernels 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 6.8 MB
Release files / scanpy_kernels-0.1.0-cp313-cp313-win_amd64.whl
| Download URL | scanpy_kernels-0.1.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 220.2 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a44ca1a22f65441e87a67d9975ceef0d95ada4425d8c80569b3416a14696f05f
|
|
BLAKE2b-256 checksum How to use checksums |
ee02953d0fd73222837c44e18a6e2e98a79f7a01b64953997d55cf77c97ce7c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp313-cp313-win32.whl
| Download URL | scanpy_kernels-0.1.0-cp313-cp313-win32.whl |
|---|---|
| Size | 200.6 kB |
| Tags | CPython 3.13 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
0eb5406ca0d8b847b958aeca6409540236466d8bb30d41370a2841bf895ceaa7
|
|
BLAKE2b-256 checksum How to use checksums |
9d4fd7b09df4d8ef53db24741cfe96093d1ac170379cd05428f3d871c381f035
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 330.0 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
4a44cda691517052f189c7fb86f49b4768d4dda9f8986ea27327cb0a8214e92f
|
|
BLAKE2b-256 checksum How to use checksums |
f15ba5a44a4fe5ddfdaff7d217b5873d34723d0f31e88d8c74577f47162b0cb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp313-cp313-macosx_11_0_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp313-cp313-macosx_11_0_x86_64.whl |
|---|---|
| Size | 306.7 kB |
| Tags | CPython 3.13 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
618eb58c24e30815b82ab658047433a72f305b337a004766903d83392e453eba
|
|
BLAKE2b-256 checksum How to use checksums |
6f0927d944d937634bc230c3d49b1d359a756f7f11265c6f4926455ab92f74fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | scanpy_kernels-0.1.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 292.3 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fb38d3ffbd8412ca8136dc4a54f85f1eded909ec921dfa8af959a355964e7674
|
|
BLAKE2b-256 checksum How to use checksums |
bfd75e62a20d6a644d3b8aa0ed89e5be3831f9282288967284c0c73aacbb6c24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp312-cp312-win_amd64.whl
| Download URL | scanpy_kernels-0.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 220.6 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b5b896ca36c76617a6e10237a7584b73df9549818622b7e6df0bf8bc7398623f
|
|
BLAKE2b-256 checksum How to use checksums |
03926242b0f38af812331aae1041560e24e334537739241eb356ac4b5611eca1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp312-cp312-win32.whl
| Download URL | scanpy_kernels-0.1.0-cp312-cp312-win32.whl |
|---|---|
| Size | 201.2 kB |
| Tags | CPython 3.12 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
10f71387a0aa56d9bc324b0e795793c52398b0970a95d680ffeb7f5cfc91489c
|
|
BLAKE2b-256 checksum How to use checksums |
f08d015e642192764090fdeadd98deac844198e5455ab34dd80d27ed3a6b4d32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 330.7 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
c827e19e2fcaffea5d0b7fc02ff507b3c279c1f55f04b2b255f5d64097e95e3e
|
|
BLAKE2b-256 checksum How to use checksums |
04503e4ef10eae1d6b2f60b533f8f02b6d3ba15b5df46813ae2d6b43a93211f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp312-cp312-macosx_11_0_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp312-cp312-macosx_11_0_x86_64.whl |
|---|---|
| Size | 307.1 kB |
| Tags | CPython 3.12 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
686536859604c81d7e6d5e371332389051c807c2f53618ce4ca4806701903ac4
|
|
BLAKE2b-256 checksum How to use checksums |
bb776d19766f1567505d8da56d74c377384ee812f143521d535404d6b4ffa4be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | scanpy_kernels-0.1.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 292.8 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
73de77468c73161bfe7cd0d241894a7ed5502c99913c9683a63f0fb5e4fe83ff
|
|
BLAKE2b-256 checksum How to use checksums |
015c90a741eb95ee6a380a5d3676300ec8186f16a0cb70de3c7a25c46762e748
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp311-cp311-win_amd64.whl
| Download URL | scanpy_kernels-0.1.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 219.5 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3fa4ad598e8088f04c667a09fef9e416808c7515400f58f396234c3418d59b24
|
|
BLAKE2b-256 checksum How to use checksums |
9b6e81a19f9f485302be44ae31dfcab38f28a98668b0ea7c0467d1ea84b7c41f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp311-cp311-win32.whl
| Download URL | scanpy_kernels-0.1.0-cp311-cp311-win32.whl |
|---|---|
| Size | 201.0 kB |
| Tags | CPython 3.11 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
a0ce3c3d5ef70c7ddaa4a9ee8650c87bc4f76ec522fa85cc6b25cfecbd6e2324
|
|
BLAKE2b-256 checksum How to use checksums |
0006725ef8fd88b55e577f1070e5e9972cbed72ed2d043f07451b08f8002f695
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 331.4 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ce4acc3f3c9698eb3311b38629cca8999c80d8aa0213555f41d94133f91cfe0c
|
|
BLAKE2b-256 checksum How to use checksums |
eced487f519a97433b83d1abd6a2c3c6c56d5df6bcd5b47c0f806d66e7ec55a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp311-cp311-macosx_11_0_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp311-cp311-macosx_11_0_x86_64.whl |
|---|---|
| Size | 307.5 kB |
| Tags | CPython 3.11 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
d22c092d97c9212021784c512f7f4a9de7c8a49067d1533fe7969f0074f6e0ef
|
|
BLAKE2b-256 checksum How to use checksums |
e341ec77716c5e501760f3cee7a2bb6f83d2037a99186d281e0ccdc51a15e351
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | scanpy_kernels-0.1.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 293.3 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
25df54ba18e9c96ec014acdaf518018eb42d6f98c7404681dfd5168086a65ca5
|
|
BLAKE2b-256 checksum How to use checksums |
e43b91e6316ae4639f5a697a684cc86784b9115191cbabf83a8c15aa4dfa4f1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp310-cp310-win_amd64.whl
| Download URL | scanpy_kernels-0.1.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 219.6 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8f00ea629152700aae544ca47d8bf58ffc3f84788bc7e518c87305dccb01067a
|
|
BLAKE2b-256 checksum How to use checksums |
44415bd158084e0de06a27c2e208cc39986be9076c376e151dbe90aa52ddf1fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp310-cp310-win32.whl
| Download URL | scanpy_kernels-0.1.0-cp310-cp310-win32.whl |
|---|---|
| Size | 200.9 kB |
| Tags | CPython 3.10 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
572fb2d1a4721e74ad7a6e0e327615600cded7ed3dba1101260969de13e71d7f
|
|
BLAKE2b-256 checksum How to use checksums |
8898821c6874eca1a84482f49fa2a934b04449bcd8a1dff6239eac7515deb886
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 331.4 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3f776431dd3187afd6652e8b6aa5e1531f3c238e463fe0f3c8086f95343c12ca
|
|
BLAKE2b-256 checksum How to use checksums |
3ffef78b734f9ccf01bfa1152da2d63f2d2f19f22397c8b568e3637208d3d392
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp310-cp310-macosx_11_0_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp310-cp310-macosx_11_0_x86_64.whl |
|---|---|
| Size | 307.5 kB |
| Tags | CPython 3.10 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
9f3742d340835143ba1714897f8c09ab414a81f9653f0cd1b5151a6839c380b0
|
|
BLAKE2b-256 checksum How to use checksums |
b8bc7c3860b52776f98654e7bd15c7f6083d7e078fc108741f3a755b54db28ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | scanpy_kernels-0.1.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 293.3 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3f690b342661ed7d66bc0c902cdbb3e88a9f432e9cb8487df2d4d7c361c05d55
|
|
BLAKE2b-256 checksum How to use checksums |
bdf0c1b9a2fa6e55c91386fabdccfd486826ea1e151dc4e38e3670eea3314885
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp39-cp39-win_amd64.whl
| Download URL | scanpy_kernels-0.1.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 220.2 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6376cc37a9457e0d291a7d159d3c7e0d58345ea573f1e164e383b25814e843ca
|
|
BLAKE2b-256 checksum How to use checksums |
39c956989488473867197836a744582275f920b8b94a771c2b15142b86e437df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp39-cp39-win32.whl
| Download URL | scanpy_kernels-0.1.0-cp39-cp39-win32.whl |
|---|---|
| Size | 201.3 kB |
| Tags | CPython 3.9 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
4ce4bcf3340f3862e0d6ff1c299f5b44875d2157bfbb87dd34a90d85496176d1
|
|
BLAKE2b-256 checksum How to use checksums |
510441bbc178163f25f7223327b7e461da8d7829f41c46deb20c310b1742dc0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 332.1 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a8366cbdaa4fe59f848ff54ad9f2540b50510ddb41b20705b63234389a3da77e
|
|
BLAKE2b-256 checksum How to use checksums |
da980c9517e2427e27b4b121156f34fce504da49f68520733a655e141d9d7586
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp39-cp39-macosx_11_0_x86_64.whl
| Download URL | scanpy_kernels-0.1.0-cp39-cp39-macosx_11_0_x86_64.whl |
|---|---|
| Size | 308.2 kB |
| Tags | CPython 3.9 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
7069f8b8ea467df697ebc438cedd444803486bbe6d827e09da8509dfd8698d3e
|
|
BLAKE2b-256 checksum How to use checksums |
54dfaa48650f545c8a779cea57448b16dcc200a9da2d4f806c69553394380b66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / scanpy_kernels-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | scanpy_kernels-0.1.0-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 294.0 kB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
af05c2a80cd137865725e469d87d0decf942bf74c891474cd16d44e16ea42f88
|
|
BLAKE2b-256 checksum How to use checksums |
3146c0f748a4a96f4bc9927b4ba346210f7cab26c6edd5f8ca581a82d35ac88b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|