saiunit.is_unit_equal_math

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, and factor — i.e. they convert quantities the same way. The display name and dispname are ignored, so e.g. metre and meter (different aliases of the SI meter) are equivalent, and a freshly-composed A * ohm is equivalent to volt.

This is distinct from Unit.__eq__, which also requires name/dispname to match — that operator treats two aliases as different units. Use is_unit_equal_math when you only care that two units convert the same way.

Parameters:
  • u1 (Unit) – The units to compare.

  • u2 (Unit) – The units to compare.

Returns:

True if u1 and u2 are mathematically equivalent.

Return type:

bool

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