PropertyKind
A registered kind of property.
Usage
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
pintunit 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()
Usage
from_native(value, units)Raises
ValueError- If units is incompatible with the native units.
Examples
>>> print(energy_property_kind.from_native(-1.0, "kcal/mol").round(2))
-627.51quantity()
Attach native units to a stored value.
Usage
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.2114to_native()
Return value as an array in native units and the storage dtype.
Usage
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.