UnitMismatchError

UnitMismatchError#

class saiunit.UnitMismatchError(description, *units)#

Exception for operations with incompatible physical units.

Raised when an operation requires matching units but receives mismatched ones. Similar to DimensionMismatchError but checks at the unit level (e.g., mV vs V).

Parameters:
  • description (str) – A description of the type of operation being performed, e.g., "Addition", "Subtraction".

  • *units (Unit) – The physical units of the objects involved in the operation.

See also

DimensionMismatchError

Exception for dimension-level mismatches.

Examples

>>> import saiunit as u
>>> e = u.UnitMismatchError("Addition", u.mvolt, u.volt)
>>> 'Addition' in str(e)
True