pyunitwizard.QuantityRecord#
- class pyunitwizard.QuantityRecord[source]#
Values plus a verified description of their unit. Inert: it does not compute.
Build one with
from_quantity()(orpuw.convert(q, to_form="record")), store it withto_dict(), read it back withfrom_dict(), and get a computing quantity withto_quantity().Examples
>>> import pyunitwizard as puw >>> from pyunitwizard.record import QuantityRecord >>> record = QuantityRecord.from_quantity(puw.quantity(3.0, "nM"), field="ic50") >>> data = record.to_dict() # JSON-ready, sealed >>> q = QuantityRecord.from_dict(data).to_quantity(field="ic50", unit="uM")
Methods
__init__()append(quantity)Append first-axis rows as a new immutable homogeneous snapshot.
from_array(values, *, metadata)Restore a typed payload only when its existing codec seal verifies.
from_dict(data)Read a stored record, refusing it unless every check passes.
from_quantity(quantity, *[, field, unit, kind])Seal a quantity.
from_tagged(quantities, *[, field, kinds])Seal equal-shaped quantities while retaining their individual units.
select(selection)Seal an independent contiguous first-axis subset.
split()Return homogeneous flattened groups keyed by descriptor code.
to_dict(*[, encoding])The sealed, JSON-ready representation.
to_metadata()Return detached sealed metadata without encoding the numeric payload.
to_quantity(*[, field, unit, ...])A computing quantity, after the reader's handshake.
validate_metadata(metadata)Check homogeneous unit metadata and its binding to block digests.
Attributes
codesRead-only per-value descriptor codes; tagged layouts only.
descriptorsDetached local unit/kind descriptors for a tagged record.
digestfieldkindlayouthomogeneous or tagged.
siunitvaluesthey cannot change behind the seal.