Skip to main content

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.2.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.2.0.tar.gz --no-deps -w /tmp/metricchrono-wheel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metricchrono-0.2.0.tar.gz (51.2 kB view details)

Uploaded Source

File details

Details for the file metricchrono-0.2.0.tar.gz.

File metadata

  • Download URL: metricchrono-0.2.0.tar.gz
  • Upload date:
  • Size: 51.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for metricchrono-0.2.0.tar.gz
Algorithm Hash digest
SHA256 01183cc8a1bf937ffee6da424af6fa2b4e7e2b74da058661258eedc5c24f8b00
MD5 51de5a0c8662422790663eb719daedb3
BLAKE2b-256 6aede6cf0f98f349bc5bfc8cfda3e55cfae8f551f345b9cd6575903beec4acec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page