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__()from_dict(data)Read a stored record, refusing it unless every check passes.
from_quantity(quantity, *[, field, unit, kind])Seal a quantity.
to_dict(*[, encoding])The sealed, JSON-ready representation.
to_quantity(*[, field, unit, ...])A computing quantity, after the reader's handshake.
Attributes
digestfieldkindsiunitvaluesthey cannot change behind the seal.