# Dimension class¶

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

class brian2.units.fundamentalunits.Dimension(dims)[source]

Bases: object

Stores the indices of the 7 basic SI unit dimension (length, mass, etc.).

Provides a subset of arithmetic operations appropriate to dimensions: multiplication, division and powers, and equality testing.

Parameters

dims : sequence of float

The dimension indices of the 7 basic SI unit dimensions.

Notes

Users shouldn’t use this class directly, it is used internally in Quantity and Unit. Even internally, never use Dimension(...) to create a new instance, use get_or_create_dimension() instead. This function makes sure that only one Dimension instance exists for every combination of indices, allowing for a very fast dimensionality check with is.

Attributes

 dim Returns the Dimension object itself. is_dimensionless Whether this Dimension is dimensionless.

Methods

 Return a specific dimension.

Details

dim

Returns the Dimension object itself. This can be useful, because it allows to check for the dimension of an object by checking its dim attribute – this will return a Dimension object for Quantity, Unit and Dimension.

is_dimensionless

Whether this Dimension is dimensionless.

Notes

Normally, instead one should check dimension for being identical to DIMENSIONLESS.

get_dimension(d)[source]

Return a specific dimension.

Parameters

A string identifying the SI basic unit dimension. Can be either a description like “length” or a basic unit like “m” or “metre”.

Returns

dim : float

The dimensionality of the dimension d.