Python Binding
Distribution name: nirs4all-core
Import name: nirs4all_core
This binding intentionally avoids the nirs4all import name so it can be
installed next to the full Python nirs4all package during parity checks.
The canonical source repository is nirs4all-core; only the Python
distribution carries the -core suffix because the production nirs4all
Python package already owns the bare name.
An additive import facade is available for governed topology work:
n4amirrors the fullnirs4all_coreaggregate surface.
Native archive bridge
nirs4all_core.read_portable_predictor_package_v2(path) invokes the embedded
Rust Archive V2 reader and returns the exact validated DAG-ML Package V2 bytes.
It does not parse ZIP members in Python, deserialize the package, or execute a
prediction. Pass the returned bytes to DAG-ML's typed package/replay surface;
the aggregate remains only the container and integrity boundary.
read_archive_v2_payloads(path) returns the native-validated manifest and
exact opaque members (a path-to-bytes mapping). Archive V2 also transports
the explicitly declared RAW Methods RolePipeline family: signed DAG-ML
packages retain every captured N4ME state, binding and controller trust
requirement in SHA-addressed artifacts/<sha256>.json members. Existing N4MM
archives retain their original profile and declarations.
Storage validation does not authorize a controller or interpret the models.
Pass this inventory to DAG-ML's validate_archive_v2_portable_payloads before
using its replay driver, with explicit trusted manifests and a signed current
cohort. The full Python SDK exposes write_portable_predictor_archive_v2,
read_portable_predictor_archive_v2 and replay_portable_predictor_archive_v2
for that composition. This adds portable transport, not N-D encoders or a
generalization of the existing callback-free N4MM replay functions.
Archive V3 host view
nirs4all_core.read_archive_v3_view(path) invokes the Rust Archive V3 reader
and returns validated replay references and N4MM inventory. It does not parse
ZIP members in Python or execute a replay.
replay_methods_archive_v2(...) and replay_methods_archive_v3(...) provide
the callback-free execution path. Rust validates the complete archive before
DAG-ML parses the signed request and numeric Methods inputs or opens the
invocation-local N4MM runtime. These functions do not accept Python callbacks,
estimator handles, pickle, or joblib sidecars; unsupported host controllers are
refused rather than hydrated implicitly.
For calibrated scalar Package V2 archives,
replay_methods_archive_v2_conformal_presentation_v1(...) returns the exact
self-validating presentation built by DAG-ML from the native replay. The
Python layer only transports strict JSON; it does not calculate quantiles,
interval endpoints, fingerprints, or sample joins.
For named multi-target outputs,
replay_methods_archive_v2_conformal_presentation_v2(...) returns the
additive, archive-bound ConformalPresentationV2. It preserves predictor,
archive, calibration and presentation fingerprints and applies the same
no-recalculation rule. V1 remains the scalar compatibility surface.
Archive replay accepts raw PLS N4MM format 1 and the exact embedded format 2
SNV(ddof=0) -> Savitzky-Golay(mode=interp) -> PLS profile. Format 2 requires
its typed ABI 2.5 descriptor and never falls back to Python preprocessing.
Training an IO DatasetPackage into Archive V2 is currently a Rust aggregate
surface, not a Python API.
Portable Execution
nirs4all_core.run_portable_pipeline(source, dataset) executes the shared
portable JSON/YAML subset through the nirs4all-methods Python bindings:
KennardStoneSplitterStandardNormalVariate/SNVSavitzkyGolaysklearn.cross_decomposition.PLSRegression_range_sweeps overn_components
Savitzky-Golay defaults to mode="interp" for full Python nirs4all parity and
preserves explicit methods-backed modes (mirror, constant, nearest,
wrap, interp) plus cval.
The aggregate does not implement numerical kernels. Install the optional
methods extra, or make n4m and pls4all importable, before calling it:
python -m pip install "nirs4all-core[methods]"
The strict local parity gate compares all shared fixtures against the full
Python nirs4all oracle and reports max prediction/RMSE deltas on failure:
PYTHONPATH=bindings/python/src:/path/to/nirs4all-methods/bindings/python/src \
N4M_LIB_PATH=/path/to/libn4m.so \
NIRS4ALL_CORE_REQUIRE_METHODS_PARITY=1 \
python -m unittest bindings/python/tests/test_execution_parity.py -v
Generic n4m role recipes (trained envelope v8)
Any Methods estimator is a recipe step through the language-neutral token
"n4m:<catalog method id>" (or {"class": "n4m:<id>", "params": {...}}),
shared with the full Python nirs4all, the R package, the Rust binding and the
npm package. load_pipeline_definition accepts these tokens when they resolve
in the Methods manifest (n4m.roles.method_class); n4m_role_capabilities()
lists the usable steps from that manifest.
N4mRolePipeline fits such a recipe (sample filters on training rows only,
transformers and selectors, then one regressor or classifier) in the native
Methods role pipeline (n4m.roles.RolePipeline) and reads/writes the
nirs4all.n4m.trained_pipeline.v8 envelope, so a pipeline trained in any
binding predicts identically here:
import nirs4all_core as n4core
fitted = n4core.N4mRolePipeline.fit_recipe(recipe, X_train_frame, y_train)
fitted.to_json("trained-v8.json")
predictions = n4core.N4mRolePipeline.from_json("trained-v8.json").predict(X_new_frame)
Every target column reaches the steps that need y. DataFrame column names are
stored (feature_names in the envelope) and a DataFrame with renamed or
reordered columns is refused; arrays are positional. The native import refuses
states that contradict the recipe. A state that embeds training rows (kernel
PLS, LW-PLS, ...) is written only with to_json(..., allow_training_rows=True)
and flagged contains_training_rows. Envelopes written before these two fields
still load. The import also refuses an n_features that is not a positive JSON
integer equal to the native width, a column name holding NUL, and a
class_names table that is not a non-empty list of unique strings or finite
numbers labelling every fitted class id (index = id); missing or non-finite
labels are refused at fit. recipe is a copy of the recipe the states attest,
which is also the one exported. Core 0.4.1's Methods extra requires
nirs4all-methods 1.3.2 or later (ABI 2.17). The role envelope's native format
remains compatible with ABI 2.14.
Metadata
Release files for nirs4all-core 0.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nirs4all_core-0.4.3.tar.gz | 353.2 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nirs4all_core-0.4.3-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| nirs4all_core-0.4.3-cp311-abi3-manylinux_2_28_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| nirs4all_core-0.4.3-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 32.7 MB
Release files / nirs4all_core-0.4.3.tar.gz
| Download URL | nirs4all_core-0.4.3.tar.gz |
|---|---|
| Size | 353.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da91e67f99f17a32541cca8d9e6c5f1414aab7f7e6f3fafc0a2740ae573d58f1
|
|
BLAKE2b-256 checksum How to use checksums |
e54df26d11608fa92caf0b268701bdf922a9fb8c53a55f9ee2a6ef35bc1e6b00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency logRelease files / nirs4all_core-0.4.3-cp311-abi3-win_amd64.whl
| Download URL | nirs4all_core-0.4.3-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 10.6 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9176e6a1387557bfbd5955dd48c867c49003fee133ff1f4b2377c068f50189bc
|
|
BLAKE2b-256 checksum How to use checksums |
8033b3be2c091bcff9f5ce58e8255e56be55070e7d6e26d1c700da59b26451c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency logRelease files / nirs4all_core-0.4.3-cp311-abi3-manylinux_2_28_x86_64.whl
| Download URL | nirs4all_core-0.4.3-cp311-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.7 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
628cf8307bcc4d74eba39338db870ecaaf7d5e62eb58977d93d40bda32297597
|
|
BLAKE2b-256 checksum How to use checksums |
bd42b648a562cf92e19ce1a949e2321124d0968dd2a06216d901d0ab1ea97cef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency logRelease files / nirs4all_core-0.4.3-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | nirs4all_core-0.4.3-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 10.1 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f892dabe5480aa552f7b73cee823e99346a850b9241694c67ef35bf55f107fab
|
|
BLAKE2b-256 checksum How to use checksums |
2df434488c440f517db63d99a486edaf5ed1e505ffb15cf8187bad80ec7bf833
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency log