httk.core.vectors.vector_numpy_backend¶
Backend wrapping a numpy ndarray (numpy is an optional dependency, imported lazily).
Classes¶
Backend for a vector backed by a |
Module Contents¶
- class httk.core.vectors.vector_numpy_backend.VectorNumpyBackend(obj, **hints)[source]¶
Bases:
httk.core.vectors.vector_backend.VectorBackendBackend for a vector backed by a
numpy.ndarray.numpy is an optional dependency (
httk-core[numpy]) and is imported lazily; if numpy is not installed, this backend’s_backend_adoptreturns None so it is simply never selected.numpy float64 values are themselves binary rationals, so the
fractionsinterchange is produced exactly from the array (each float becomes its exact rational value). Only the reverse direction (building a numpy view) is lossy.unwrapreturns the wrapped array.- Parameters:
obj (Any) – The source data to wrap.
**hints (Any) – Optional backend-selection hints.
- property fractions: httk.core.vectors.vector_api.Fractions¶
Return the array in the exact Fraction interchange format.
- to_floats()[source]¶
Return floats through a numpy fast path for real numeric dtypes.
Other dtypes fall back to
to_floats()so the exact hub conversion and its error semantics are preserved.- Returns:
The rendered value.
- Return type:
Any
- to_float()[source]¶
Return a scalar float through numpy for real numeric 0-D arrays.
Non-scalar arrays raise the same
TypeErroras the hub implementation. Other scalar dtypes fall back toto_float()for its exact conversion and error semantics.