get_or_create_dimension function¶
(Shortest import: from brian2 import get_or_create_dimension)
-
brian2.units.fundamentalunits.
get_or_create_dimension
(*args, **kwds)[source]¶ Create a new Dimension object or get a reference to an existing one. This function takes care of only creating new objects if they were not created before and otherwise returning a reference to an existing object. This allows to compare dimensions very efficiently using
is
.Parameters: args : sequence of
float
A sequence with the indices of the 7 elements of an SI dimension.
kwds : keyword arguments
a sequence of
keyword=value
pairs where the keywords are the names of the SI dimensions, or the standard unit.Notes
The 7 units are (in order):
Length, Mass, Time, Electric Current, Temperature, Quantity of Substance, Luminosity
and can be referred to either by these names or their SI unit names, e.g. length, metre, and m all refer to the same thing here.
Examples
The following are all definitions of the dimensions of force
>>> from brian2 import * >>> get_or_create_dimension(length=1, mass=1, time=-2) metre * kilogram * second ** -2 >>> get_or_create_dimension(m=1, kg=1, s=-2) metre * kilogram * second ** -2 >>> get_or_create_dimension([1, 1, -2, 0, 0, 0, 0]) metre * kilogram * second ** -2