Skip to main content

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.md for 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. See BENCHMARKS.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.

Metadata

Release files for pycatch22-rs 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycatch22-rs 0.1.0
File Size Uploaded Provenance Actions
pycatch22_rs-0.1.0.tar.gz 192.5 kB Without provenance Details for pycatch22_rs-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pycatch22-rs 0.1.0
File Actions
pycatch22_rs-0.1.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for pycatch22_rs-0.1.0-cp311-abi3-win_amd64.whl
pycatch22_rs-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for pycatch22_rs-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pycatch22_rs-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for pycatch22_rs-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
pycatch22_rs-0.1.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for pycatch22_rs-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
pycatch22_rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for pycatch22_rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 2.0 MB

Release files / pycatch22_rs-0.1.0.tar.gz

Download URL pycatch22_rs-0.1.0.tar.gz
Size 192.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fadb0ed6b19e6549e98ec44de48d7186343501a40c06ed56e6060690f23da20e
BLAKE2b-256 checksum
How to use checksums
5b6af910730bbda888e39eba99bb19723a433b1d50e6721e63c23c8bd25debfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / pycatch22_rs-0.1.0-cp311-abi3-win_amd64.whl

Download URL pycatch22_rs-0.1.0-cp311-abi3-win_amd64.whl
Size 289.7 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
6ecd15ef75fffe0784a6bf6cdd4c5a91b69d2d1127d218f28ee5f8ec381e84f2
BLAKE2b-256 checksum
How to use checksums
7aeeb444a6ef2250b8c7c54f0c49e5c6b1f560285c91d0c0c672811f847b60a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / pycatch22_rs-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pycatch22_rs-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 411.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7fb0840f7001cb1277f0892570cfb8117640ddb47539eced64fb72c4c6ce2248
BLAKE2b-256 checksum
How to use checksums
a19a67a7a84cb22cf08226f7e7ef63860b4b09d2ae063070554e2b2ea2c3f349
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / pycatch22_rs-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pycatch22_rs-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 399.5 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
470eab6ccd29b1d6b764d4d716bcf51aa0968b244b473c847a49708bb2123352
BLAKE2b-256 checksum
How to use checksums
5cb99351317a0f0e34f0494be27a4fe26554d8ecd304047a0e4ba42530001d46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / pycatch22_rs-0.1.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL pycatch22_rs-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Size 365.0 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f767fe63970aec72956b83cb6c7a0ecd9af9a22ccbee756f52492e4a90b7081d
BLAKE2b-256 checksum
How to use checksums
fbe3442ec298680c0cadf5e1eb6805340309ab2b005875d76ce2b8d8be415a9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / pycatch22_rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL pycatch22_rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 379.0 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b20e1ef0f49c0e517201a04ecbc1a9b8284dae47a1784a366aef99893b1be068
BLAKE2b-256 checksum
How to use checksums
8dd30a26bc7529b191c1a05fdd23780379894b8cb663bbcd063a09761a5d2e60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Security for pycatch22-rs 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page