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__()

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

digest

field

kind

si

unit

values

they cannot change behind the seal.