Skip to content
Get started

eqiora.data

← Python API index

Explicit numeric adapters and canonical resolved-array artifacts.

View source

Example: explicitly mapped measurement columns

Section titled “Example: explicitly mapped measurement columns”
python
from pathlib import Path
import eqiora
from eqiora import data, units as u
text = "elapsed_ms,force_mN\n0,0\n500,2000\n1000,0\n"
array, dimensions = data.csv_array(text, columns=(
("elapsed_ms", u.s.prefixed("m")),
("force_mN", u.N.prefixed("m")),
))
assert dimensions == (eqiora.Dimension(time=1),
eqiora.Dimension(mass=1, length=1, time=-2))
Path("force_samples.json").write_bytes(array.to_bytes())
reopened = data.ResolvedArray.from_bytes(Path("force_samples.json").read_bytes())
assert reopened.digest == array.digest

Use the file as a package’s data/force_samples.json asset. Its property release declares the time and force dimensions, validity, interpolation and extrapolation policy. CSV conversion preserves row order and rejects missing selected cells; the property-table owner rejects duplicate or unordered times. See numeric inputs.

Immutable row-major values with the native resolved-array identity and codec.

python
@final
class ResolvedArray:
@staticmethod
def from_f64(shape: Sequence[int], values: Sequence[float]) -> ResolvedArray: ...
@staticmethod
def from_u64(shape: Sequence[int], values: Sequence[int]) -> ResolvedArray: ...
@staticmethod
def from_bytes(data: bytes) -> ResolvedArray: ...
def to_bytes(self) -> bytes: ...
@property
def digest(self) -> str: ...
@property
def scalar(self) -> Literal['f64', 'u64']: ...
@property
def shape(self) -> tuple[int, ...]: ...
@property
def values(self) -> tuple[float, ...] | tuple[int, ...]: ...

Map numeric CSV columns explicitly through exact Unit normalization.

python
def csv_array(text: str, *, columns: Sequence[tuple[str, Unit]], delimiter: str=',') -> tuple[ResolvedArray, tuple[Dimension, ...]]: ...

Write selected typed observation components through the shared native exporter.

python
def export_observations_csv(path: str | PathLike[str], observations: Iterable[Observation], *, unit: Unit, projection: str='real', component: int=0, decimal_places: int=6, locale: str='C') -> None: ...