cfunits.Units.equivalent

Units.equivalent(other, verbose=False)[source]

Tests whether two units are numerically convertible.

Returns True if numeric values in one unit are convertible to numeric values in the other unit.

See also

equals

Parameters
other: Units

The other units.

Returns
bool

True if the units are equivalent, False otherwise.

Examples

>>> u = Units('m')
>>> v = Units('km')
>>> w = Units('s')
>>> u.equivalent(v)
True
>>> u.equivalent(w)
False
>>> u = Units('days since 2000-1-1')
>>> v = Units('days since 2000-1-1', calendar='366_day')
>>> w = Units('seconds since 1978-3-12', calendar='standard')
>>> u.equivalent(v)
False
>>> u.equivalent(w)
True

Invalid units are not equivalent:

>>> Units('bad units').equivalent(Units('bad units'))
False