StreamParity
Test research-to-production consistency in numerical streaming pipelines.
StreamParity is an offline testing toolkit for comparing batch calculations with incremental, stateful implementations. Applications include quantitative trading, numerical risk models, sensor processing and production ML. It is currently an early-stage Python package, not a certified production validation system.
Install from source
Requires Python 3.10+ and NumPy. From the repository root:
python -m pip install -e ".[dev]"
python -m pytest -q
python examples/trading_replay.py
The name streamparity is proposed; public PyPI publication is not yet confirmed.
Quick start
import numpy as np
from streamparity import audit
def streaming():
total = 0.0
def update(chunk):
nonlocal total
out = total + np.cumsum(chunk)
total = out[-1]
return out
return update
report = audit(np.cumsum, streaming, [1., -2., 3., -1.],
random_trials=5, seed=42, max_chunk=3,
decision=lambda y: y > 0)
print(report.summary())
report.assert_passed() # raises AssertionError if a check fails
Checks
| Function | Comparison |
|---|---|
check_batch_stream |
Batch output vs single-row incremental replay |
check_chunks |
Fixed-size partitions vs single-row replay |
check_lookahead |
Full-run historical outputs vs prefix-only executions |
check_random_chunks |
Seeded random partitions vs single-row replay |
check_restart |
Uninterrupted replay vs checkpoint/restart replay |
check_decisions |
Exact discrete decisions from batch vs single-row streaming outputs |
audit |
Combined checks; optional random, restart and decision checks |
AuditReport provides .passed, .checks, .summary(), .assert_passed(), .to_dict() and .to_json(). Each check reports its scenario, status, count of mismatched rows and zero-based first mismatch. Shape mismatches are reported separately (row mismatch count is zero and index is null). No raw inputs or output values are included in reports. User-selected scenarios are not exhaustive.
Checkpoint recovery
A checkpoint callback serializes the updater's state to immutable bytes. A restore callback loads those bytes into a fresh updater in place. Test the same serialization callbacks used by the real application whenever possible.
from streamparity import check_restart
results = check_restart(
streaming_factory, data,
checkpoint=lambda updater: updater.save_state(),
restore=lambda updater, state: updater.load_state(state),
points=(10, 50), # restart after this many consumed rows
)
assert all(r.passed for r in results)
See examples/trading_replay.py for a complete runnable implementation and an intentional recovery failure. This simulates state restoration within a process; it does not kill processes, simulate network failures or verify durability on disk.
Contracts and numerical semantics
batch(data)is deterministic and stateless or freshly reset;streaming()returns a fresh stateful callableupdate(chunk)for each replay. State is retained across calls to that updater only.- Axis 0 is time. Both transforms return one nonempty numerical output row per input row, in identical order. Input and output arrays are copied to isolate ordinary in-place mutations.
- Real numeric and boolean arrays are supported. Inputs must be nonempty; lookahead, restart and combined audits require at least two rows.
- Integer/boolean pairs compare exactly; floating or mixed outputs use NumPy
isclose(actual, expected, rtol, atol, equal_nan). Mixed integer/floating comparisons may lose precision; return matching discrete dtypes for exact decisions. Matching NaNs are equal by default; setequal_nan=Falseto reject them. Equal infinities compare equal. decision(outputs)must be a deterministic row-wise mapping to integer or boolean labels. It is evaluated separately on complete batch and incremental output arrays and compared exactly, not with numerical tolerances. The library cannot verify causality of the user-supplied decision function.- Exceptions from user code propagate. Random trials use a nonnegative integer seed and bounded random partitions; a seed and scenario identify a replay within the same NumPy environment.
Limits
Passing tests are evidence on the supplied data, scenarios and tolerances, not proof of equivalence, causality or profitable trading. Future-derived features, externally fitted parameters and untested prefixes can evade lookahead checks. Fixed and random partitions preserve input ordering. No asynchronous or late-event replay, timestamp alignment, dataframe metadata, stochastic transform support, distributed execution, or process-crash simulation. The current implementation replays and stores complete outputs; benchmark before large-scale use.
Release preparation
See RELEASING.md. MIT licence is proposed; review the copyright attribution before distributing. Contributions should include regression tests.
Metadata
Release files for streamparity 0.2.0
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 |
|---|---|---|---|---|
| streamparity-0.2.0.tar.gz | 11.7 kB | With provenance | Details for streamparity-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| streamparity-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for streamparity-0.2.0-py3-none-any.whl |
Total release size: 20.2 kB
Release files / streamparity-0.2.0.tar.gz
| Download URL | streamparity-0.2.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
43036ad30c662764a6a8204f17d07411bf5d607aa5cd2404422cd3f1d423358b
|
|
BLAKE2b-256 checksum How to use checksums |
0b3095fcf3511d19d8fad3ee043181d7a3db949516880c4af56dce319b412d94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 25, 2026.
Transparency logRelease files / streamparity-0.2.0-py3-none-any.whl
| Download URL | streamparity-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe0899fc88945bb391c285ed6e7a18d8156c4a65cfca0044c44b92e0354e9942
|
|
BLAKE2b-256 checksum How to use checksums |
ba30e37c75550ceb4bc0022422dbb1cc6aef04eaab3a167dca0862d4830b8c3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 25, 2026.
Transparency logSecurity for streamparity 0.2.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for streamparity-0.2.0.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 Nov 25, 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.