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

Classes

CodeString(code) A class for representing “code strings”, i.e.
Expression([code, sympy_expression]) Class for representing an expression.
Statements(code) Class for representing statements.

Functions

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

Classes

EquationError 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.

Functions

check_identifier_basic(identifier) Check an identifier (usually resulting from an equation string provided by the user) for conformity with the rules.
check_identifier_constants(identifier) Make sure that identifier names do not clash with function names.
check_identifier_functions(identifier) Make sure that identifier names do not clash with function names.
check_identifier_reserved(identifier) Check that an identifier is not using a reserved special variable name.
check_identifier_units(identifier) 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”.
dimensions_and_type_from_string(unit_string) 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.
extract_constant_subexpressions(eqs)
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_string_equations(eqns) Parse a string defining equations.

refractory module

Module implementing Brian’s refractory mechanism.

Exported members: add_refractoriness

Functions

add_refractoriness(eqs) Extends a given set of equations with the refractory mechanism.
check_identifier_refractory(identifier) 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: unit_from_expression, check_dimensions, check_units_statements

Functions

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.