Unit
- class openff.units.Unit(*args, **kwargs)
Bases:
Unit
Methods
Converts a numerical value or quantity to this unit
check if the other object is compatible
Converts a numerical value or quantity to this unit, then returns the magnitude of the converted value
Attributes
Default formatting string.
returns:
dict
-- Dimensionality of the PlainUnit, e.g.Return True if the PlainUnit is dimensionless; False otherwise.
- compare(other, op) bool
- default_format: str = ''
Default formatting string.
- property dimensionality: UnitsContainer
returns:
dict
– Dimensionality of the PlainUnit, e.g.{length: 1, time: -1}
- property dimensionless: bool
Return True if the PlainUnit is dimensionless; False otherwise.
- from_(value, strict=True, name='value')
Converts a numerical value or quantity to this unit
- Parameters
value – a Quantity (or numerical value if strict=False) to convert
strict – boolean to indicate that only quantities are accepted (Default value = True)
name – descriptive name to use if an exception occurs (Default value = “value”)
- Returns
type
– The converted value as this unit
- is_compatible_with(other: Any, *contexts: Union[str, Context], **ctx_kwargs: Any) bool
check if the other object is compatible
- Parameters
other – The object to check. Treated as dimensionless if not a Quantity, PlainUnit or str.
*contexts (
str
orpint.Context
) – Contexts to use in the transformation.**ctx_kwargs – Values for the Context/s
- Returns
- m_from(value, strict=True, name='value')
Converts a numerical value or quantity to this unit, then returns the magnitude of the converted value
- Parameters
value – a Quantity (or numerical value if strict=False) to convert
strict – boolean to indicate that only quantities are accepted (Default value = True)
name – descriptive name to use if an exception occurs (Default value = “value”)
- Returns
type
– The magnitude of the converted value