Unit handling¶
- metatrain.utils.units.get_gradient_units(base_unit: str, gradient_name: str, length_unit: str) str[source]¶
Get the gradient units based on the unit of the base quantity.
For example, if the base unit is “<unit>” and the gradient name is “positions”, the gradient unit will be “<unit>/<length_unit>”.
- metatrain.utils.units.ev_to_mev(value: float, unit: str) Tuple[float, str][source]¶
If the unit starts with eV, converts the value and its corresponding unit to meV. Otherwise, returns the input.
- metatrain.utils.units.units_are_equivalent(unit: str, other_unit: str) bool[source]¶
Check whether two unit expressions represent the same numerical unit.
Equivalent units have a conversion factor of exactly one, so their data can be combined without rescaling. Unknown units (empty strings) are only equivalent to other unknown units.