Skip to main content

Module npy

Module npy 

Source
Expand description

NumPy .npy file I/O.

This module provides functions to read and write NumPy .npy files, enabling interoperability with Python-based analysis tools.

§Example

ⓘ
use pedalkernel_validate::npy;

// Write test output
let output = vec![0.1, 0.2, 0.3, 0.4, 0.5];
npy::write_f64("output.npy", &output).unwrap();

// Read reference data
let reference = npy::read_f64("golden.npy").unwrap();

// Check if a file exists
if npy::exists("reference.npy") {
    // Load and compare
}

§Python Interoperability

Files written by this module can be loaded in Python:

import numpy as np
data = np.load("output.npy")

And Python-generated files can be read:

import numpy as np
golden = np.sin(np.linspace(0, 2*np.pi, 1000))
np.save("golden.npy", golden)

Enums§

NpyError

Functions§

exists
Check if an NPY file exists.
read_f64
Read a 1D float64 array from an NPY file.
write_f64
Write a 1D float64 array to an NPY file.