pyunitwizard.QuantityRecord#

class pyunitwizard.QuantityRecord[source]#

Values plus a verified description of their unit. Inert: it does not compute.

Build one with from_quantity() (or puw.convert(q, to_form="record")), store it with to_dict(), read it back with from_dict(), and get a computing quantity with to_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")
__init__()[source]#
Return type:

None

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

codes

Read-only per-value descriptor codes; tagged layouts only.

descriptors

Detached local unit/kind descriptors for a tagged record.

digest

field

kind

layout

homogeneous or tagged.

si

unit

values

they cannot change behind the seal.