Measurement
- class openff.units.Measurement(value, error, units=MISSING)[source]
Bases:
Measurement
A value with associated units and uncertainty.
Methods
Return true if the quantity's dimension matches passed dimension.
Compute the Dask array wrapped by pint.Quantity.
Dot product of two arrays.
Transforms a list of Quantities into an numpy.array quantity.
Transforms a sequence of Quantities into an numpy.array quantity.
check if the other object is compatible
Inplace rescale to different units.
Return Quantity rescaled to base units.
Return Quantity scaled in place to reduced units, i.e. one unit per dimension.
Return Quantity rescaled to root units.
Quantity's magnitude expressed in particular units.
Persist the Dask Array wrapped by pint.Quantity.
Return the product of quantity elements over a given axis
Return Quantity rescaled to different units.
Return Quantity rescaled to base units.
"Return Quantity rescaled to compact, human-readable units.
Return Quantity scaled in place to reduced units, i.e. one unit per dimension.
Return Quantity rescaled to root units.
Produce a visual representation of the Dask graph.
Attributes
Default formatting string.
returns:
dict
-- Dimensionality of the Quantity, e.g.Quantity's magnitude.
Quantity's magnitude.
Quantity's units.
Quantity's units.
- check(dimension: UnitLike) bool
Return true if the quantity’s dimension matches passed dimension.
- compute(**kwargs)
Compute the Dask array wrapped by pint.Quantity.
- Parameters
**kwargs (
dict
) – Any keyword arguments to pass todask.compute
.- Returns
pint.Quantity
– A pint.Quantity wrapped numpy array.
- default_format: str = ''
Default formatting string.
- property dimensionality: UnitsContainerT
returns:
dict
– Dimensionality of the Quantity, e.g.{length: 1, time: -1}
- property dimensionless: bool
- fill(value) None
- property force_ndarray: bool
- property force_ndarray_like: bool
- classmethod from_list(quant_list: List[Quantity], units=None) Quantity[ndarray]
Transforms a list of Quantities into an numpy.array quantity. If no units are specified, the unit of the first element will be used. Same as from_sequence.
If units is not specified and list is empty, the unit cannot be determined and a ValueError is raised.
- Parameters
quant_list (
list
ofpint.Quantity
) – list of pint.Quantityunits (
UnitsContainer
,str
orpint.Quantity
) – units of the physical quantity to be created (Default value = None)
- Returns
- classmethod from_sequence(seq: Sequence[Quantity], units=None) Quantity[ndarray]
Transforms a sequence of Quantities into an numpy.array quantity. If no units are specified, the unit of the first element will be used.
If units is not specified and sequence is empty, the unit cannot be determined and a ValueError is raised.
- Parameters
seq (
sequence
ofpint.Quantity
) – sequence of pint.Quantityunits (
UnitsContainer
,str
orpint.Quantity
) – units of the physical quantity to be created (Default value = None)
- Returns
- property imag: Quantity[pint._typing._MagnitudeType]
- 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, Unit or str.
*contexts (
str
orpint.Context
) – Contexts to use in the transformation.**ctx_kwargs – Values for the Context/s
- Returns
- ito(other=None, *contexts, **ctx_kwargs) None
Inplace rescale to different units.
- Parameters
other (
pint.Quantity
,str
ordict
) – Destination units. (Default value = None)*contexts (
str
orpint.Context
) – Contexts to use in the transformation.**ctx_kwargs – Values for the Context/s
- ito_base_units() None
Return Quantity rescaled to base units.
- ito_reduced_units() None
Return Quantity scaled in place to reduced units, i.e. one unit per dimension. This will not reduce compound units (e.g., ‘J/kg’ will not be reduced to m**2/s**2), nor can it make use of contexts at this time.
- ito_root_units() None
Return Quantity rescaled to root units.
- m_as(units) _MagnitudeType
Quantity’s magnitude expressed in particular units.
- Parameters
units (
pint.Quantity
,str
ordict
) – destination units
- persist(**kwargs)
Persist the Dask Array wrapped by pint.Quantity.
- Parameters
**kwargs (
dict
) – Any keyword arguments to pass todask.persist
.- Returns
pint.Quantity
– A pint.Quantity wrapped Dask array.
- prod(axis=None, dtype=None, out=None, keepdims=np._NoValue, initial=np._NoValue, where=np._NoValue)
Return the product of quantity elements over a given axis
Wraps np.prod().
- put(indices, values, mode='raise') None
- property real: Quantity[pint._typing._MagnitudeType]
- property shape: Tuple[int, ...]
- to(other=None, *contexts, **ctx_kwargs) Quantity[_MagnitudeType]
Return Quantity rescaled to different units.
- Parameters
other (
pint.Quantity
,str
ordict
) – destination units. (Default value = None)*contexts (
str
orpint.Context
) – Contexts to use in the transformation.**ctx_kwargs – Values for the Context/s
- Returns
- to_base_units() Quantity[_MagnitudeType]
Return Quantity rescaled to base units.
- to_compact(unit=None) Quantity[_MagnitudeType]
“Return Quantity rescaled to compact, human-readable units.
To get output in terms of a different unit, use the unit parameter.
Examples
>>> import pint >>> ureg = pint.UnitRegistry() >>> (200e-9*ureg.s).to_compact() <Quantity(200.0, 'nanosecond')> >>> (1e-2*ureg('kg m/s^2')).to_compact('N') <Quantity(10.0, 'millinewton')>
- to_reduced_units() Quantity[_MagnitudeType]
Return Quantity scaled in place to reduced units, i.e. one unit per dimension. This will not reduce compound units (intentionally), nor can it make use of contexts at this time.
- to_root_units() Quantity[_MagnitudeType]
Return Quantity rescaled to root units.
- to_timedelta() timedelta
- property u: Unit
Quantity’s units. Short form for units
- property unitless: bool
- property units: Unit
Quantity’s units. Long form for u
- visualize(**kwargs)
Produce a visual representation of the Dask graph.
The graphviz library is required.
- Parameters
**kwargs (
dict
) – Any keyword arguments to pass todask.visualize
.