This release is a pre-release and may not be stable for production use.
pycatch22-rs
A Rust implementation of the catch22 time-series feature set, with Python bindings.
25 features: the 22 catch22 features, the two catch24 additions (mean and standard deviation), and the slope of a linear fit.
- Verified against the original C over the entire UCR archive — 128
datasets, 191,158 series, 4.78 million feature values. See
docs/parity.mdfor exactly what was compared, at what tolerance, and where the two still differ. - ~6x faster than the original C, single-threaded, on the same machine and
data, with C built at
-O3 -march=native. SeeBENCHMARKS.md. - Zero-copy numpy interface, with a batch entry point that releases the GIL and processes series in parallel.
Installation
Requires Python 3.11 or later.
pip install pycatch22-rs
From source:
git clone https://github.com/irazza/pycatch22-rs
cd pycatch22-rs
python -m venv .venv && source .venv/bin/activate
pip install maturin numpy
maturin develop --release
Usage
import numpy as np
import pycatch22_rs
x = np.random.default_rng(0).standard_normal(500)
# All 25 features at once.
values = pycatch22_rs.compute_all(x) # -> ndarray, shape (25,)
dict(zip(pycatch22_rs.FEATURE_NAMES, values))
# Any single feature, by name.
pycatch22_rs.SP_Summaries_welch_rect_centroid(x)
pycatch22_rs.CO_f1ecac(x)
# ...or by index, in FEATURE_NAMES order.
pycatch22_rs.compute(x, 19)
# A batch of series: GIL released, rows processed in parallel.
batch = np.random.default_rng(0).standard_normal((1000, 500))
pycatch22_rs.compute_batch(batch) # -> ndarray, shape (1000, 25)
Normalisation
By default, compute_all and compute_batch reproduce the reference pipeline:
features 0–21 are computed on the z-scored series, and 22–24 (mean, standard
deviation, slope) on the raw series, which is the catch24 convention. Pass
normalize=False to compute everything on the series exactly as given.
The z-score uses the sample standard deviation (ddof=1), matching the
reference implementation's zscore_norm2. This is not cosmetic: several
features are not scale-invariant, so normalising with the population standard
deviation shifts their values.
The individually named functions take the series as given and do no normalisation, so z-score first if you want the reference values:
z = pycatch22_rs.zscore(x)
pycatch22_rs.DN_HistogramMode_5(z)
Input handling
Lists, non-float64 dtypes, and non-contiguous views are all accepted and converted once. Input is never modified.
Series shorter than 4 samples, and series containing NaN or infinity, raise
ValueError. This is a deliberate departure from C, which propagates NaN
through its feature functions. Note that a constant series z-scores to
NaN (its standard deviation is zero), so compute_all(constant, normalize=True)
raises as well.
Rust
The kernel is a standalone crate with no Python dependency:
[dependencies]
catch22 = { path = "crates/catch22" }
let values = catch22::compute_all_normalized(&series)?; // [f64; 25]
let centroid = catch22::sp_summaries_welch_rect_centroid(&z);
FEATURES and FEATURE_NAMES are parallel arrays over the same 25 indices.
Development
cargo test --workspace # Rust: parity, consistency, edge cases
maturin develop --release
pytest tests/ # Python: API surface and parity
Checking against the C reference
Parity is enforced at two levels. The committed fixture in tests/data/ holds
C's expected output for a sample of series plus hand-picked edge cases, and is
checked by both test suites on every run. The full archive sweep is opt-in and
needs a local copy of the UCR archive:
bash tools/c_reference/fetch.sh # clone catch22 C at the pinned commit
make -C tools/c_reference # build the reference driver
cargo run --release -p ucr_check -- --ucr-root ~/DATA/ucr --report docs/parity-report.md
The same tool produces the benchmark table:
cargo run --release -p ucr_check -- --ucr-root <subset> \
--driver tools/c_reference/driver_native --bench BENCHMARKS.md
License
GPL-3.0-or-later. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycatch22_rs-0.1.0rc1.tar.gz.
File metadata
- Download URL: pycatch22_rs-0.1.0rc1.tar.gz
- Upload date:
- Size: 192.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e2ddb38e65a2f6295ff46b7734baaed9d6b4344f0d974ebd4796723a37548f4
|
|
| MD5 |
8d1d5f7fc754625ab4ad91b532262ce4
|
|
| BLAKE2b-256 |
9747851e7c9f82b71215f88194eab1e406d408af955262a3152edd820dec469a
|
File details
Details for the file pycatch22_rs-0.1.0rc1-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: pycatch22_rs-0.1.0rc1-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 289.8 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f6149243f7c96f52b6a91907f5143ac3ff74a477f83a6d108e62cff249e200d
|
|
| MD5 |
d72679874e6580730c15fef3cc2db248
|
|
| BLAKE2b-256 |
1e5f4dfee3b2fdbd0376f3573e05b3e3deaf7fb664626e9cb77928d70316cdef
|
File details
Details for the file pycatch22_rs-0.1.0rc1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pycatch22_rs-0.1.0rc1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 411.2 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e76e9a50800f20097eb5a652c4f0dbf5415bbf439e8e419a5de01bd85c881f7
|
|
| MD5 |
33cf4bee12d528ea6cc3cc8caea28a03
|
|
| BLAKE2b-256 |
01e52f5e640990832a9049a4bd14dd251f6bfd4cba5825b8a1bc605aab6ea2c5
|
File details
Details for the file pycatch22_rs-0.1.0rc1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pycatch22_rs-0.1.0rc1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 399.5 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e5f34f4bf56af98418606a47159bb7e2adf2280de23fec1ffce608eae0575af
|
|
| MD5 |
12ef6d80623c8ea759faf7bfe6680aa5
|
|
| BLAKE2b-256 |
a2f1d2d9c0b40a961c29dc8765ca23f8eaede1a9f5f354a9e79b6058ef9b66fd
|
File details
Details for the file pycatch22_rs-0.1.0rc1-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pycatch22_rs-0.1.0rc1-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 365.1 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8781f4bc66029e66519201286d75a5cee29bdf9e40eac3b788c4e1f3550a5d8a
|
|
| MD5 |
63ec40b50cd8f9cd7acb50b060c08f12
|
|
| BLAKE2b-256 |
bea0079ea7cd644fb9fbd7fe8be275d3fe2189a806578ccc4afbcf75f1dfa108
|
File details
Details for the file pycatch22_rs-0.1.0rc1-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pycatch22_rs-0.1.0rc1-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 379.0 kB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d36fb60da47bae4e3647fabcede02f661d647609b4ddaedd29fbc32eecb8a512
|
|
| MD5 |
77a22c2fe30a92cfeaf53f18c8e7409b
|
|
| BLAKE2b-256 |
654a8019749bb3663afead92a4d9cbb6d07a1635a5d3006a9634a65cdc257b88
|