cf.Units.equals

Units.equals(other, rtol=None, atol=None)[source]

Return True if and only if numeric values in one unit are convertible to numeric values in the other unit and their conversion is a scale factor of 1.

Parameters :
other : Units

The other units.

Returns :
out : bool

True if the units are equal, False otherwise.

Examples

>>> u = Units(units='km')
>>> v = Units(units='1000m')
>>> u.equals(v)
True
>>> u = Units(units='m s-1')
>>> m = Units(units='m')
>>> s = Units(units='s')
>>> u.equals(m)
False
>>> u.equals(m/s)
True
>>> (m/s).equals(u)
True

Undefined units are considered equal:

>>> u = Units()
>>> v = Units()
>>> u.equals(v)
True

Previous topic

cf.Units.dump

Next topic

cf.Units.equivalent

This Page