brainunit.split_mantissa_unit

brainunit.split_mantissa_unit#

brainunit.split_mantissa_unit(obj)[source]#

Split a Quantity into its mantissa and unit.

Plain numeric values are treated as unitless quantities.

Parameters:

obj (object) – The object to split. Can be a Quantity or a plain numeric type.

Returns:

  • mantissa (float or array_like) – The mantissa of obj.

  • unit (Unit) – The physical unit of obj.

See also

get_mantissa

Return only the mantissa.

get_unit

Return only the unit.

Examples

>>> import saiunit as u
>>> m, u = u.split_mantissa_unit(3.0 * u.mV)
>>> float(m)
3.0
>>> u
mV
>>> m, u = u.split_mantissa_unit(5.0)
>>> float(m)
5.0
>>> u == u.UNITLESS
True