DimensionMismatchError class

(Shortest import: from brian2 import DimensionMismatchError)

class brian2.units.fundamentalunits.DimensionMismatchError(description, *dims)[source]

Bases: exceptions.Exception

Exception class for attempted operations with inconsistent dimensions.

For example, 3*mvolt + 2*amp raises this exception. The purpose of this class is to help catch errors based on incorrect units. The exception will print a representation of the dimensions of the two inconsistent objects that were operated on.


description : str

A description of the type of operation being performed, e.g. Addition, Multiplication, etc.

dims : Dimension

The dimensions of the objects involved in the operation, any number of them is possible

Tutorials and examples using this