saiunit.get_unit

Contents

saiunit.get_unit#

saiunit.get_unit(obj)#

Return the unit of any object that has them.

Parameters:

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

Returns:

unit – The physical unit of obj.

Return type:

saiunit.Unit

See also

get_dim

Return the dimension of an object.

get_mantissa

Return the mantissa (numeric value) of an object.

Examples

>>> import saiunit as u
>>> u.get_unit(3.0 * u.mV)
mV
>>> u.get_unit(5.0)
1
>>> u.get_unit(u.volt)
V