brainunit.has_same_unit

Contents

brainunit.has_same_unit#

brainunit.has_same_unit(obj1, obj2)#

Check whether two objects have the same unit.

Unlike have_same_dim, this function also checks that the scale matches (e.g. mV and V have the same dimension but different units).

Parameters:
  • obj1 ({Quantity, Unit, array-like, number}) – The first value.

  • obj2 ({Quantity, Unit, array-like, number}) – The second value.

Returns:

sameTrue if obj1 and obj2 have the same unit.

Return type:

bool

See also

have_same_dim

Check whether two objects share the same dimension.

Examples

>>> import saiunit as u
>>> u.has_same_unit(1.0 * u.mV, 2.0 * u.mV)
True
>>> u.has_same_unit(1.0 * u.mV, 2.0 * u.volt)
False
>>> u.has_same_unit(1.0, 2.0)
True