bellini.quantity.Quantity¶
- class bellini.quantity.Quantity(value, unit=None, name=None)[source]¶
Bases:
pint.quantity.QuantityA class that describes physical quantity, which contains numeric value and units.
- __init__()¶
Methods
__init__()check(dimension)Return true if the quantity's dimension matches passed dimension.
clip([first, second, out])compare(*args, **kwargs)compatible_units(*contexts)compute(**kwargs)Compute the Dask array wrapped by pint.Quantity.
dot(b)Dot product of two arrays.
fill(value)format_babel([spec])from_list(quant_list[, units])Transforms a list of Quantities into an numpy.array quantity.
from_sequence(seq[, units])Transforms a sequence of Quantities into an numpy.array quantity.
from_tuple(tup)is_compatible_with(other, *contexts, ...)check if the other object is compatible
ito([other])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.
jnp()return self but jnp.ndarray
m_as(units)Quantity's magnitude expressed in particular units.
persist(**kwargs)Persist the Dask Array wrapped by pint.Quantity.
plus_minus(error[, relative])prod([axis, dtype, out, keepdims, initial, ...])Return the product of quantity elements over a given axis
put(indices, values[, mode])searchsorted(v[, side, sorter])to([other])Return Quantity rescaled to different units.
Return Quantity rescaled to base units.
to_compact([unit])"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.
to_timedelta()to_tuple()to_units(new_units[, force])tolist()unitless()return self but unitless
visualize(**kwargs)Produce a visual representation of the Dask graph.
Attributes
TUnitsContainerdebug_useddefault_formatDefault formatting string.
- returns
Dimensionality of the Quantity, e.g.
{length: 1, time: -1}
dimensionlessflatforce_ndarrayforce_ndarray_likegimagQuantity's magnitude.
Quantity's magnitude.
realshapeQuantity's units.
Quantity's units.
- compute(**kwargs)[source]¶
Compute the Dask array wrapped by pint.Quantity.
- Parameters
**kwargs (dict) – Any keyword arguments to pass to
dask.compute.- Returns
A pint.Quantity wrapped numpy array.
- Return type
pint.Quantity
- property dimensionality¶
- Returns
Dimensionality of the Quantity, e.g.
{length: 1, time: -1}- Return type
dict
- classmethod from_list(quant_list, units=None)[source]¶
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 of pint.Quantity) – list of pint.Quantity
units (UnitsContainer, str or pint.Quantity) – units of the physical quantity to be created (Default value = None)
- Returns
- Return type
pint.Quantity
- classmethod from_sequence(seq, units=None)[source]¶
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 of pint.Quantity) – sequence of pint.Quantity
units (UnitsContainer, str or pint.Quantity) – units of the physical quantity to be created (Default value = None)
- Returns
- Return type
pint.Quantity
- is_compatible_with(other, *contexts, **ctx_kwargs)[source]¶
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 or pint.Context) – Contexts to use in the transformation.
**ctx_kwargs – Values for the Context/s
- Returns
- Return type
bool
- ito(other=None, *contexts, **ctx_kwargs)[source]¶
Inplace rescale to different units.
- Parameters
other (pint.Quantity, str or dict) – Destination units. (Default value = None)
*contexts (str or pint.Context) – Contexts to use in the transformation.
**ctx_kwargs – Values for the Context/s
- ito_reduced_units()[source]¶
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.
- property m¶
Quantity’s magnitude. Short form for magnitude
- m_as(units)[source]¶
Quantity’s magnitude expressed in particular units.
- Parameters
units (pint.Quantity, str or dict) – destination units
- property magnitude¶
Quantity’s magnitude. Long form for m
- persist(**kwargs)[source]¶
Persist the Dask Array wrapped by pint.Quantity.
- Parameters
**kwargs (dict) – Any keyword arguments to pass to
dask.persist.- Returns
A pint.Quantity wrapped Dask array.
- Return type
pint.Quantity
- prod(axis=None, dtype=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]¶
Return the product of quantity elements over a given axis
Wraps np.prod().
- to(other=None, *contexts, **ctx_kwargs)[source]¶
Return Quantity rescaled to different units.
- Parameters
other (pint.Quantity, str or dict) – destination units. (Default value = None)
*contexts (str or pint.Context) – Contexts to use in the transformation.
**ctx_kwargs – Values for the Context/s
- Returns
- Return type
pint.Quantity
- to_compact(unit=None)[source]¶
“Return Quantity rescaled to compact, human-readable units.
To get output in terms of a different unit, use the unit parameter.
Example
>>> 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()[source]¶
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.
- property u¶
Quantity’s units. Short form for units
- property units¶
Quantity’s units. Long form for u