fail_for_dimension_mismatch function

(Shortest import: from brian2.units.fundamentalunits import fail_for_dimension_mismatch)

brian2.units.fundamentalunits.fail_for_dimension_mismatch(obj1, obj2=None, error_message=None)[source]

Compare the dimensions of two objects.

Parameters:

obj1, obj2 : {array-like, Quantity}

The object to compare. If obj2 is None, assume it to be dimensionless

error_message : str, optional

An error message that is used in the DimensionMismatchError

Raises

DimensionMismatchError
If the dimensions of obj1 and obj2 do not match (or, if obj2 is None, in case obj1 is not dimensionsless).

Notes

Implements special checking for 0, treating it as having “any dimensions”.