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.13.tar.gz (363.8 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.13-cp311-abi3-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

nirs4all_io-0.1.13-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.13-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.13.tar.gz.

File metadata

  • Download URL: nirs4all_io-0.1.13.tar.gz
  • Upload date:
  • Size: 363.8 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.13.tar.gz
Algorithm Hash digest
SHA256 6dc338066a1ad36dbd3e2af973076682c607df7c23f795fd681a5b243f4ce556
MD5 c5b968394586bfe080927a21893a97e1
BLAKE2b-256 7366242b9718e5a73433fb8396f56f2a01055535c52f5181b407fa1672423c85

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.13.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.13-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.13-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 38e9fb48bc801445959cbacb007e8001f5bbc32d24e2e8653045dcb1063b165c
MD5 7925b2203a7837b63ea8c4b9d41a3a4d
BLAKE2b-256 33361410755498c557985a26b177edba2bfff46ade3aae20d186cf6b1134ace1

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.13-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.13-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.13-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c0ad56ea160d79f5646bfaffc5a6c4e47af7b782f736aaf098a7141157ba23e5
MD5 9e3d4571ec0844f98d04aa1c26aa4b7d
BLAKE2b-256 2df165f24476ed7b8c16382c77e38ef904e2d15b4bee19c67fe3f8ccb529d5ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.13-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.13-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nirs4all_io-0.1.13-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4937d9779a82ef78169e64da4681934043a93c96dabae145fdfc3729ae46ed66
MD5 3f7b3a2a3c7f1fd2e1a4f0ae8f72e8a7
BLAKE2b-256 a325764657fc0c3123089a2f4eefd8371d871be70033d01cc2272a0085a62dab

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_io-0.1.13-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

0.1.14

4 files

This release

0.1.13 This release

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