Skip to main content

PropertyKind

A registered kind of property.

Usage

Source

PropertyKind()

Attributes

name: str

Unique property kind name (primary key of PropertyKindRow).

validation_fn: PropertyValidationProtocol

Function checking that a value has the expected shape.

units: str

Native units, as a pint unit string; values are stored in these.

dtype: type[np.floating]
NumPy dtype used to store values of this kind.

Methods

Name Description
from_native() Convert a stored value from native units to units.
quantity() Attach native units to a stored value.
to_native() Return value as an array in native units and the storage dtype.

from_native()

Convert a stored value from native units to units.

Usage

Source

from_native(value, units)

Molar units (e.g. kcal/mol for Hartree) are handled as in to_native.

Raises
ValueError
If units is incompatible with the native units.
Examples
>>> print(energy_property_kind.from_native(-1.0, "kcal/mol").round(2))
-627.51

quantity()

Attach native units to a stored value.

Usage

Source

quantity(value)

Plain pint conversions don’t handle molar units; use from_native for those.

Examples
>>> print(round(energy_property_kind.quantity(-1.0).m_as("eV"), 4))
-27.2114

to_native()

Return value as an array in native units and the storage dtype.

Usage

Source

to_native(value)

A pint.Quantity is converted to units, including molar quantities (e.g. kcal/mol for Hartree), which are scaled by Avogadro’s constant. Any other value is assumed to be in units already.

Raises
ValueError
If value has incompatible units, or is not numeric.