httk.core.vectors.vector_native_view

A view presenting any vector backend as nested tuples, with a selectable leaf codec.

Classes

VectorNativeView

A view presenting an underlying vector backend as nested tuples, with a selectable leaf codec.

Module Contents

class httk.core.vectors.vector_native_view.VectorNativeView(obj, **hints)

Bases: httk.core.vectors.vector_view.VectorView, tuple

A view presenting an underlying vector backend as nested tuples, with a selectable leaf codec.

The leaf codec is the element-domain axis (see httk.core.vectors.leaf_codecs); it is chosen with the leaf= hint plus any codec options (rounding=, digits=, …). There are three modes:

  • preserve-original (leaf=None, and the source is natively-held data): the backend’s original nested leaves are presented verbatim — the same objects, only containers tuple-ized (Decimal\ s in, the same Decimal\ s out).

  • exact default (leaf=None, source crossing from a frac/numpy backend): the "exact" codec — int when integral, else fractions.Fraction, never a float.

  • explicit codec (leaf="int"/"float"/"decimal"/"fraction"/…): every element is converted from the backend’s exact fractions interchange through that codec.

The codec name and its options are validated eagerly at construction (an unknown codec name or invalid option raises ValueError); a codec never raises on the data — a value it cannot represent exactly takes the codec’s documented default conversion, because the backend keeps the exact original. A scalar source is presented as a single-element tuple.

Parameters:
unwrap()

Return the underlying unwrapped vector.

unview()

Return a plain tuple containing the presented leaves.