Python API¶
Zarr Codec¶
cast_value.CastValueRustV1
dataclass
¶
Bases: _CastValueBaseV1
Cast-value codec backed by the cast-value-rs Rust implementation.
Source code in src/cast_value/zarr_compat/v1/rust_codec.py
cast_value.CastValueNumpyV1
dataclass
¶
Bases: _CastValueBaseV1
Cast-value codec backed by the pure-numpy implementation.
Source code in src/cast_value/zarr_compat/v1/numpy_codec.py
cast_value.cast_array ¶
cast_array(arr: ndarray, *, target_dtype: dtype, rounding_mode: RoundingMode, out_of_range_mode: OutOfRangeMode | None, scalar_map_entries: ScalarMapEntries | None = None) -> ndarray
Cast an array to target_dtype with rounding, out-of-range, and scalar_map handling.
Optimized to minimize allocations and passes over the data.
For the simple case (no scalar_map, no rounding needed, no out-of-range),
this is essentially just arr.astype(target_dtype).
All casts are performed under np.errstate(over='raise', invalid='raise')
so that numpy overflow or invalid-value warnings become hard errors instead
of being silently swallowed.
Source code in src/cast_value/impl/_numpy.py
cast_value.ScalarMapJSON ¶
Bases: TypedDict
JSON representation of the scalar_map codec configuration field.
This type models permitted values for the scalar_map field in the
configuration field of the cast_value codec metadata.
See the cast_value spec for details.
Source code in src/cast_value/types.py
cast_value.ScalarMapEntries
module-attribute
¶
ScalarMapEntries: TypeAlias = Iterable[ScalarMapEntry] | Mapping[NumericScalar, NumericScalar]