equations package

Module handling equations and “code strings”, expressions or statements, used for example for the reset and threshold definition of a neuron.

Exported members: Equations, Expression, Statements

codestrings module

Module defining CodeString, a class for a string of code together with information about its namespace. Only serves as a parent class, its subclasses Expression and Statements are the ones that are actually used.

Exported members: Expression, Statements



A class for representing "code strings", i.e. a single Python expression or a sequence of Python statements.

Expression([code, sympy_expression])

Class for representing an expression.


Class for representing statements.


is_constant_over_dt(expression, variables, ...)

Check whether an expression can be considered as constant over a time step.

equations module

Differential equations for Brian models.

Exported members: Equations



Exception type related to errors in an equation definition.

Equations(eqns, **kwds)

Container that stores equations from which models can be created.

SingleEquation(type, varname, dimensions[, ...])

Class for internal use, encapsulates a single equation or parameter.



Check an identifier (usually resulting from an equation string provided by the user) for conformity with the rules.


Make sure that identifier names do not clash with function names.


Make sure that identifier names do not clash with function names.


Check that an identifier is not using a reserved special variable name.


Make sure that identifier names do not clash with unit names.

check_subexpressions(group, equations, ...)

Checks the subexpressions in the equations and raises an error if a subexpression refers to stateful functions without being marked as "constant over dt".


Returns the physical dimensions that results from evaluating a string like "siemens / metre ** 2", allowing for the special string "1" to signify dimensionless units, the string "boolean" for a boolean and "integer" for an integer variable.


is_stateful(expression, variables)

Whether the given expression refers to stateful functions (and is therefore not guaranteed to give the same result if called repetively).


Parse a string defining equations.

refractory module

Module implementing Brian’s refractory mechanism.

Exported members: add_refractoriness



Extends a given set of equations with the refractory mechanism.


Check that the identifier is not using a name reserved for the refractory mechanism.

unitcheck module

Utility functions for handling the units in Equations.

Exported members: check_dimensions, check_units_statements


check_dimensions(expression, dimensions, ...)

Compares the physical dimensions of an expression to expected dimensions in a given namespace.

check_units_statements(code, variables)

Check the units for a series of statements.