# units package

The unit system.

Exported members: `DimensionMismatchError`, `Gamp`, `Gcoulomb`, `Gfarad`, `Ggram`, `Ggramme`, `Ghertz`, `Gjoule`, `Gliter`, `Glitre`, `Gmeter`, `Gmetre`, `Gmolar`, `Gmole`, `Gohm`, `Gpascal`, `Gsecond`, `Gsiemens`, `Gvolt`, `Gwatt`, `Hz`, `MHz`, `Mamp`, `Mcoulomb`, `Mfarad` … (219 more members)

## `allunits` module

THIS FILE IS AUTOMATICALLY GENERATED BY A STATIC CODE GENERATION TOOL DO NOT EDIT BY HAND

Instead edit the template:

> dev/tools/static_codegen/units_template.py

Exported members: `Eamp`, `Eamp2`, `Eamp3`, `Eampere`, `Eampere2`, `Eampere3`, `Ebecquerel`, `Ebecquerel2`, `Ebecquerel3`, `Ecandle`, `Ecandle2`, `Ecandle3`, `Ecoulomb`, `Ecoulomb2`, `Ecoulomb3`, `Efarad`, `Efarad2`, `Efarad3`, `Egram`, `Egram2`, `Egram3`, `Egramme`, `Egramme2`, `Egramme3`, `Egray` … (2045 more members)

Objects

`celsius` | A dummy object to raise errors when `celsius` is used.

## `constants` module

A module providing some physical units as `Quantity` objects. Note that these units are not imported by wildcard imports (e.g. `from brian2 import *`), they have to be imported explicitly. You can use `import ... as ...` to import them with shorter names, e.g.:

    from brian2.units.constants import faraday_constant as F

The available constants are:

Constant | Symbol(s) | Brian name | Value
--- | --- | --- | ---
Avogadro constant | \(N_A, L\) | `avogadro_constant` | \(6.022140857\times 10^{23}\,\mathrm{mol}^{-1}\)
Boltzmann constant | \(k\) | `boltzmann_constant` | \(1.38064852\times 10^{-23}\,\mathrm{J}\,\mathrm{K}^{-1}\)
Electric constant | \(\epsilon_0\) | `electric_constant` | \(8.854187817\times 10^{-12}\,\mathrm{F}\,\mathrm{m}^{-1}\)
Electron mass | \(m_e\) | `electron_mass` | \(9.10938356\times 10^{-31}\,\mathrm{kg}\)
Elementary charge | \(e\) | `elementary_charge` | \(1.6021766208\times 10^{-19}\,\mathrm{C}\)
Faraday constant | \(F\) | `faraday_constant` | \(96485.33289\,\mathrm{C}\,\mathrm{mol}^{-1}\)
Gas constant | \(R\) | `gas_constant` | \(8.3144598\,\mathrm{J}\,\mathrm{mol}^{-1}\,\mathrm{K}^{-1}\)
Magnetic constant | \(\mu_0\) | `magnetic_constant` | \(12.566370614\times 10^{-7}\,\mathrm{N}\,\mathrm{A}^{-2}\)
Molar mass constant | \(M_u\) | `molar_mass_constant` | \(1\times 10^{-3}\,\mathrm{kg}\,\mathrm{mol}^{-1}\)
0°C |  | `zero_celsius` | \(273.15\,\mathrm{K}\)

## `fundamentalunits` module

Defines physical units and quantities

Quantity | Unit | Symbol
Length | metre | m
Mass | kilogram | kg
Time | second | s
Electric current | ampere | A
Temperature | kelvin | K
Quantity of substance | mole | mol
Luminosity | candle | cd

Exported members: `DimensionMismatchError`, `Quantity`, `Unit`, `check_units()`, `get_dimensions()`, `get_or_create_dimension()`, `get_unit()`, `have_same_dimensions()`, `in_best_unit()`, `in_unit()`, `is_dimensionless()`, `is_scalar_type()`, `register_new_unit()`

Classes

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

`DimensionMismatchError`(description, *dims) | Exception class for attempted operations with inconsistent dimensions.

`Quantity`(arr[, dim, dtype, copy, force_quantity]) | A number with an associated physical dimension.

`Unit`(arr[, dim, scale, name, dispname, ...]) | A physical unit.

`UnitRegistry`() | Stores known units for printing in best units.

Functions

`check_units`(**au) | Decorator to check units of arguments passed to a function

`fail_for_dimension_mismatch`(obj1[, obj2, ...]) | Compare the dimensions of two objects.

`get_dimensions`(obj) | Return the dimensions of any object that has them.

`get_or_create_dimension`(*args, **kwds) | Create a new Dimension object or get a reference to an existing one.

`get_unit`(d) | Find an unscaled unit (e.g. `volt` but not `mvolt`) for a `Dimension`.

`get_unit_for_display`(d) | Return a string representation of an appropriate unscaled unit or `'1'` for a dimensionless quantity.

`have_same_dimensions`(obj1, obj2) | Test if two values have the same dimensions.

`in_best_unit`(x[, precision]) | Represent the value in the "best" unit.

`in_unit`(x, u[, precision]) | Display a value in a certain unit with a given precision.

`is_dimensionless`(obj) | Test if a value is dimensionless or not.

`is_scalar_type`(obj) | Tells you if the object is a 1d number type.

`quantity_with_dimensions`(floatval, dims) | Create a new `Quantity` with the given dimensions.

`register_new_unit`(u) | Register a new unit for automatic displaying of quantities

`wrap_function_change_dimensions`(func, ...) | Returns a new function that wraps the given function `func` so that it changes the dimensions of its input.

`wrap_function_dimensionless`(func) | Returns a new function that wraps the given function `func` so that it raises a DimensionMismatchError if the function is called on a quantity with dimensions (excluding dimensionless quantities).

`wrap_function_keep_dimensions`(func) | Returns a new function that wraps the given function `func` so that it keeps the dimensions of its input.

`wrap_function_remove_dimensions`(func) | Returns a new function that wraps the given function `func` so that it removes any dimensions from its input.

Objects

`DIMENSIONLESS` | The singleton object for dimensionless Dimensions.

`additional_unit_register` | `UnitRegistry` containing additional units (newton*metre, farad / metre, ...)

`standard_unit_register` | `UnitRegistry` containing all the standard units (metre, kilogram, um2...)

`user_unit_register` | `UnitRegistry` containing all units defined by the user

## `stdunits` module

Optional short unit names

This module defines the following short unit names:

mV, mA, uA (micro_amp), nA, pA, mF, uF, nF, nS, mS, uS, ms, Hz, kHz, MHz, cm, cm2, cm3, mm, mm2, mm3, um, um2, um3

Exported members: `Hz`, `MHz`, `cm`, `cm2`, `cm3`, `kHz`, `mA`, `mM`, `mS`, `mV`, `mm`, `mm2`, `mm3`, `ms`, `nA`, `nF`, `nM`, `nS`, `pA`, `pF`, `uA`, `uF`, `uM`, `uS`, `um` … (3 more members)

## `unitsafefunctions` module

Unit-aware replacements for numpy functions.

Exported members: `arange()`, `arccos()`, `arccosh()`, `arcsin()`, `arcsinh()`, `arctan()`, `arctanh()`, `cos()`, `cosh()`, `diagonal()`, `dot()`, `exp()`, `expm1()`, `exprel()`, `linspace()`, `log()`, `log10()`, `log1p()`, `ones_like()`, `ptp()`, `ravel()`, `sin()`, `sinh()`, `tan()`, `tanh()` … (3 more members)

Functions

`arange`([start,] stop[, step,][, dtype, ...]) | Return evenly spaced values within a given interval.

`arccos`(x, /[, out, where, casting, order, ...]) | Trigonometric inverse cosine, element-wise.

`arccosh`(x, /[, out, where, casting, order, ...]) | Inverse hyperbolic cosine, element-wise.

`arcsin`(x, /[, out, where, casting, order, ...]) | Inverse sine, element-wise.

`arcsinh`(x, /[, out, where, casting, order, ...]) | Inverse hyperbolic sine element-wise.

`arctan`(x, /[, out, where, casting, order, ...]) | Trigonometric inverse tangent, element-wise.

`arctanh`(x, /[, out, where, casting, order, ...]) | Inverse hyperbolic tangent element-wise.

`cos`(x, /[, out, where, casting, order, ...]) | Cosine element-wise.

`cosh`(x, /[, out, where, casting, order, ...]) | Hyperbolic cosine, element-wise.

`diagonal`(a[, offset, axis1, axis2]) | Return specified diagonals.

`dot`(a, b[, out]) | Dot product of two arrays.

`exp`(x, /[, out, where, casting, order, ...]) | Calculate the exponential of all elements in the input array.

`exprel`(x) |

`linspace`(start, stop[, num, endpoint, ...]) | Return evenly spaced numbers over a specified interval.

`log`(x, /[, out, where, casting, order, ...]) | Natural logarithm, element-wise.

`ravel`(a[, order]) | Return a contiguous flattened array.

`sin`(x, /[, out, where, casting, order, ...]) | Trigonometric sine, element-wise.

`sinh`(x, /[, out, where, casting, order, ...]) | Hyperbolic sine, element-wise.

`tan`(x, /[, out, where, casting, order, ...]) | Compute tangent element-wise.

`tanh`(x, /[, out, where, casting, order, ...]) | Compute hyperbolic tangent element-wise.

`trace`(a[, offset, axis1, axis2, dtype, out]) | Return the sum along diagonals of the array.

`where`(condition, [x, y], /) | Return elements chosen from `x` or `y` depending on `condition`.

`wrap_function_to_method`(func) | Wraps a function so that it calls the corresponding method on the Quantities object (if called with a Quantities object as the first argument).