saiunit.is_unit_equal_math#
- saiunit.is_unit_equal_math(u1, u2)#
Check whether two units are mathematically equivalent.
Two units are mathematically equivalent when they have the same
dim,scale,base, andfactor— i.e. they convert quantities the same way. The displaynameanddispnameare ignored, so e.g.metreandmeter(different aliases of the SI meter) are equivalent, and a freshly-composedA * ohmis equivalent tovolt.This is the same comparison
Unit.__eq__performs (nameanddispnameare not part of either comparison), sois_unit_equal_math(u1, u2)andu1 == u2agree for twoUnitoperands; this function additionally tolerates non-Unitarguments by returningFalseinstead of raising.- Parameters:
- Returns:
Trueif u1 and u2 are mathematically equivalent.- Return type:
Examples
>>> import saiunit as u >>> u.is_unit_equal_math(u.metre, u.meter) True >>> u.is_unit_equal_math(u.amp * u.ohm, u.volt) True >>> u.is_unit_equal_math(u.mV, u.volt) False