brainunit.get_dim

Contents

brainunit.get_dim#

brainunit.get_dim(obj)#

Return the dimension of any object that has them.

Slightly more general than Array.dimensions because it will return DIMENSIONLESS if the object is of number type but not a Quantity (e.g. a float or int).

Parameters:

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

Returns:

dim – The physical dimensions of obj.

Return type:

Dimension

See also

get_unit

Return the unit of an object.

get_mantissa

Return the mantissa (numeric value) of an object.

Examples

>>> import saiunit as u
>>> u.get_dim(1.0 * u.mV)
metre ** 2 * kilogram * second ** -3 * amp ** -1
>>> u.get_dim(5.0)
1
>>> u.get_dim(u.volt)
metre ** 2 * kilogram * second ** -3 * amp ** -1