Python bindings for the MetricChrono Rust C ABI
Project description
MetricChrono Python
Production Python bindings for the same metricchrono-ffi native library used
by the Rust and C APIs.
When building a wheel from the repository, the package build runs Cargo and bundles the platform native library into the wheel:
python3 -m pip wheel bindings/python --no-deps -w /tmp/metricchrono-wheel
python3 -m pip install /tmp/metricchrono-wheel/metricchrono-0.1.0-*.whl
Cargo must be available for source builds. To use the wrapper directly from the source tree without installing a wheel, build the native library from the repository root:
cargo build -p metricchrono-ffi --release
Then point Python at the library if it is not installed in a standard dynamic loader path:
export METRICCHRONO_FFI_LIB=target/release/libmetricchrono_ffi.dylib
Use .so on Linux and .dll on Windows.
Example
import metricchrono as mc
ladder = mc.geometric_ladder(0.5, 1.0, 2.0, 4, 0.5, 1.0)
print(mc.ladder_distance(3.0, ladder))
with mc.EventLog(2) as log:
log.append(10, [1.0, 0.0])
log.append(11, [1.0, 1.0])
print(log.next_event(0, 0))
API Surface
- Kernel and ladders:
Tier,tick_distance,ladder_distance,geometric_ladder,Ladder. - Serialization:
tier_from_schema,tier_to_schema,ladder_from_schema,ladder_to_schema,tick_vector_from_schema,tick_vector_to_schema,consensus_result_from_schema. - Smooth and adaptive helpers:
smooth_tick_distance,smooth_ladder_distance,adaptive_ladder_distance,ZoomDecision. - Event memory:
EventLog. - Consensus:
weighted_consensus,coherence_residuals,simple_weight_update.
Verify
PYTHONPATH=bindings/python METRICCHRONO_FFI_LIB=target/release/libmetricchrono_ffi.dylib \
python3 bindings/python/tests/golden.py
python3 -m pip install build
python3 -m build bindings/python --sdist --outdir /tmp/metricchrono-sdist
python3 -m pip wheel /tmp/metricchrono-sdist/metricchrono-0.1.0.tar.gz --no-deps -w /tmp/metricchrono-wheel
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file metricchrono-0.1.0.tar.gz.
File metadata
- Download URL: metricchrono-0.1.0.tar.gz
- Upload date:
- Size: 34.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a9f0ae71eeb87218a5286f08a9f5248caddcb941449d4df173a727e12423378
|
|
| MD5 |
97f565e73ab281a6fcd5a56d35c7e932
|
|
| BLAKE2b-256 |
1f0b69da0a54f9863acb073bdd1c645c5c8f2c443ba528fac1160a45f7b418f6
|