Skip to main content

Python binding (pyo3 / maturin)

A thin pyo3 wrapper over the single nirs4all-io Rust core (the facade crate) — all RESOLVE → INFER → CONFIGURE → MATERIALIZE logic lives in Rust; Python only adapts the results.

Layout (mixed maturin)

  • Native extension nirs4all_io._native (the pyo3 module, built from src/lib.rs).
  • Python package nirs4all_io (under python/) that wraps _native and adds the lazy SpectroDataset adapter (_adapter.py).

numpy and pandas are wheel runtime dependencies — they back the full-array SpectroDataset reconstruction and are not nirs4all.

Build & install

maturin develop          # build + install into the active venv (dev)
maturin build            # build an abi3 wheel (abi3-py311)
pip install <wheel>      # install the built wheel

Requires Python ≥ 3.11. See PACKAGING.md for the abi3 wheel / nirs4all-formats reuse details.

API

All functions are re-exported from nirs4all_io.

Function Signature Returns
infer infer(input, conventions=None) a DatasetPlan (data input only)
to_spec to_spec(input, conventions=None, name=None) a DatasetSpec
validate validate(spec) None; raises ValueError if invalid
load load(input, *, target="assembled", conventions=None, name=None, base_dir=None, spectro_dataset_cls=None) summary dict, DatasetPackage, or a SpectroDataset
to_dataset_package to_dataset_package(input, *, conventions=None, base_dir=None, name=None) a target-agnostic DatasetPackage
describe_dataset_package describe_dataset_package(input, *, conventions=None, base_dir=None, name=None, canonical=False) package summary dict or canonical JSON
to_spectrodataset to_spectrodataset(full, *, spectro_dataset_cls=None) a SpectroDataset

Inputs (input) accept a str path, a pathlib.Path, a sequence of either (file list), or a dict (a spec). validate additionally accepts a JSON string.

Typed results. infer returns a DatasetPlan and to_spec a DatasetSpec. Both subclass dict — they stay subscriptable, JSON-serializable, and valid inputs to validate / load — and add a readable repr plus convenience accessors:

  • DatasetSpec: .name, .schema_version, .sources.
  • DatasetPlan: .overall_score, .resolved_spec (a DatasetSpec), .recommendations, .warnings, and .decisions() (the scored structure/signal_type/task_type decisions, keyed by kind).
>>> plan = nio.infer("/data/run")
>>> plan
DatasetPlan(overall_score=0.883, structure='x_y_separate'(0.85), ...)
>>> plan.decisions().keys()
dict_keys(['structure', 'signal_type', 'task_type'])
>>> plan.resolved_spec
DatasetSpec(name='data', schema_version=1, sources=[data:mixed])

load targets:

  • target="assembled" → the rounded structural summary dict (no nirs4all).
  • target="dataset_package" / target="package" → a target-agnostic DatasetPackage with payload manifest hashes and an assembled view.
  • target="spectrodataset" → a real nirs4all SpectroDataset, built via a lazy nirs4all import inside the adapter. This is the only nirs4all touch-point; import nirs4all_io never imports nirs4all (enforced by tests/test_import_boundary.py). Inject spectro_dataset_cls= to drive the builder with a double (testing without nirs4all).

Usage

from pathlib import Path
import nirs4all_io as nio

plan = nio.infer(Path("/data/run"))            # DatasetPlan (typed dict)
spec = nio.to_spec("/data/run")                # DatasetSpec (typed dict)
nio.validate(spec)                             # raises ValueError if invalid

print(spec.schema_version, len(spec.sources))  # convenience accessors
print(plan.decisions())                        # scored inference decisions

summary = nio.load("/data/run")                # target="assembled" (default)
package = nio.to_dataset_package("/data/run")  # target-agnostic package
ds = nio.load("/data/run", target="spectrodataset")   # nirs4all SpectroDataset

Test

pytest bindings/python/tests

Download files

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

Source Distribution

nirs4all_io-0.1.14.tar.gz (364.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nirs4all_io-0.1.14-cp311-abi3-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

nirs4all_io-0.1.14-cp311-abi3-manylinux_2_34_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ x86-64

nirs4all_io-0.1.14-cp311-abi3-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file nirs4all_io-0.1.14.tar.gz.

File metadata

  • Download URL: nirs4all_io-0.1.14.tar.gz
  • Upload date:
  • Size: 364.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nirs4all_io-0.1.14.tar.gz
Algorithm Hash digest
SHA256 960ad7946d446f8dd011a2ffcb493c479092b638f13b08241debb23e33653ae8
MD5 51c1b117e1bb619d64b9710036332215
BLAKE2b-256 7f8fdcdc7298a490496d41493c9fe2a5919a003d06a904aa50a41bbe93286d16

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.14.tar.gz:

Publisher: release.yml on GBeurier/nirs4all-io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nirs4all_io-0.1.14-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.14-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 63f7ed1366b7bac4c26ca1e49b67d06ea52554aa5b6b99387010106ceef78009
MD5 9f60304cb066b915c77039232dfedbee
BLAKE2b-256 8eaf4dcf404d7cfe62925b80c3c245db5f0317369e2b319c1086b9e529b9bcda

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.14-cp311-abi3-win_amd64.whl:

Publisher: release.yml on GBeurier/nirs4all-io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nirs4all_io-0.1.14-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.14-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 24298b9e53b67e1a2bde7639871bf0de8fa7f2eb95e4f3b68afececc895454e1
MD5 839ef8ba6c9a15d53e21e88cfb1b3e21
BLAKE2b-256 9a0f5c7459cac81903f04b1d9cb36cbfc8c867565cd9aeddba1b550d68eb7d69

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.14-cp311-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on GBeurier/nirs4all-io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nirs4all_io-0.1.14-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.14-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c59eb8d8ecf40269b76064eddb4d8aee8ce9661649ebc356fb6ded707fe45f52
MD5 03b5296afc382eb80958bb09df8bfb4e
BLAKE2b-256 80b7f42646ff93180f8c97a689fcf6d450bdf84de8ccd46ddf97e1ee02ec57b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.14-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on GBeurier/nirs4all-io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.18

4 files

This release

0.1.14 This release

4 files

0.1.13

4 files

0.1.12

4 files

0.1.11

4 files

0.1.10

4 files

0.1.9

4 files

0.1.7

4 files

0.1.6

4 files

0.1.5

4 files

0.1.4

4 files

0.1.3

4 files

0.1.2

4 files

0.1.1

4 files

0.1.0

4 files

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