core package

Essential Brian modules, in particular base classes for all kinds of brian objects.

Built-in preferences

Core Brian preferences

core.default_float_dtype = float64

Default dtype for all arrays of scalars (state variables, weights, etc.).

core.default_integer_dtype = int32

Default dtype for all arrays of integer scalars.

core.outdated_dependency_error = True

Whether to raise an error for outdated dependencies (True) or just a warning (False).

base module

All Brian objects should derive from BrianObject.

Exported members: BrianObject, BrianObjectException

Classes

BrianObject(*args, **kw)

All Brian objects derive from this class, defines magic tracking and update.

BrianObjectException(message, brianobj)

High level exception that adds extra Brian-specific information to exceptions

Functions

brian_object_exception(message, brianobj, ...)

Returns a BrianObjectException derived from the original exception.

device_override(name)

Decorates a function/method to allow it to be overridden by the current Device.

weakproxy_with_fallback(obj)

Attempts to create a weakproxy to the object, but falls back to the object if not possible.

clocks module

Clocks for the simulator.

Exported members: Clock, defaultclock

Classes

Clock(*args, **kw)

An object that holds the simulation time and the time step.

DefaultClockProxy()

Method proxy to access the defaultclock of the currently active device

Functions

check_dt(new_dt, old_dt, target_t)

Check that the target time can be represented equally well with the new dt.

Objects

defaultclock

The standard clock, used for objects that do not specify any clock or dt

core_preferences module

Definitions, documentation, default values and validation functions for core Brian preferences.

Functions

default_float_dtype_validator(dtype)

dtype_repr(dtype)

functions module

Exported members: DEFAULT_FUNCTIONS, Function, implementation(), declare_types()

Classes

Function(pyfunc[, sympy_func, arg_units, ...])

An abstract specification of a function that can be used as part of model equations, etc.

FunctionImplementation([name, code, ...])

A simple container object for function implementations.

FunctionImplementationContainer(function)

Helper object to store implementations and give access in a dictionary-like fashion, using CodeGenerator implementations as a fallback for CodeObject implementations.

SymbolicConstant(name, sympy_obj, value)

Class for representing constants (e.g. pi) that are understood by sympy.

exprel(arg)

Represents (exp(x) - 1)/x.

Functions

declare_types(**types)

Decorator to declare argument and result types for a function

implementation(target[, code, namespace, ...])

A simple decorator to extend user-written Python functions to work with code generation in other languages.

timestep(t, dt)

Converts a given time to an integer time step.

magic module

Exported members: MagicNetwork, magic_network, MagicError, run(), stop(), collect(), store(), restore(), start_scope()

Classes

MagicError

Error that is raised when something goes wrong in MagicNetwork

MagicNetwork(*args, **kw)

Network that automatically adds all Brian objects

Functions

collect([level])

Return the list of BrianObjects that will be simulated if run() is called.

get_objects_in_namespace(level)

Get all the objects in the current namespace that derive from BrianObject.

restore([name, filename, restore_random_state])

Restore the state of the network and all included objects.

run(duration[, report, report_period, ...])

Runs a simulation with all "visible" Brian objects for the given duration.

start_scope()

Starts a new scope for magic functions

stop()

Stops all running simulations.

store([name, filename])

Store the state of the network and all included objects.

Objects

magic_network

Automatically constructed MagicNetwork of all Brian objects

names module

Exported members: Nameable

Classes

Nameable(*args, **kw)

Base class to find a unique name for an object

Functions

find_name(name[, names])

Determine a unique name.

namespace module

Implementation of the namespace system, used to resolve the identifiers in model equations of NeuronGroup and Synapses

Exported members: get_local_namespace(), DEFAULT_FUNCTIONS, DEFAULT_UNITS, DEFAULT_CONSTANTS

Functions

get_local_namespace(level)

Get the surrounding namespace.

network module

Module defining the Network object, the basis of all simulation runs.

Preferences

Network preferences

core.network.default_schedule = ['start', 'groups', 'thresholds', 'synapses', 'resets', 'end']

Default schedule used for networks that don’t specify a schedule.

Exported members: Network, profiling_summary(), scheduling_summary()

Classes

Network(*objs[, name])

The main simulation controller in Brian

ProfilingSummary(net[, show])

Class to nicely display the results of profiling.

SchedulingSummary(objects)

Object representing the schedule that is used to simulate the objects in a network.

TextReport(stream)

Helper object to report simulation progress in Network.run.

Functions

profiling_summary([net, show])

Returns a ProfilingSummary of the profiling info for a run.

schedule_propagation_offset([net])

Returns the minimal time difference for a post-synaptic effect after a spike.

scheduling_summary([net])

Returns a SchedulingSummary object, representing the scheduling information for all objects included in the given Network (or the "magic" network, if none is specified).

operations module

Exported members: NetworkOperation, network_operation()

Classes

NetworkOperation(*args, **kw)

Object with function that is called every time step.

Functions

network_operation([when])

Decorator to make a function get called every time step of a simulation.

preferences module

Brian global preferences are stored as attributes of a BrianGlobalPreferences object prefs.

Exported members: PreferenceError, BrianPreference, prefs, brian_prefs

Classes

BrianGlobalPreferences()

Class of the prefs object.

BrianGlobalPreferencesView(basename, all_prefs)

A class allowing for accessing preferences in a subcategory.

BrianPreference(default, docs[, validator, ...])

Used for defining a Brian preference.

DefaultValidator(value)

Default preference validator

ErrorRaiser()

PreferenceError

Exception relating to the Brian preferences system.

Functions

check_preference_name(name)

Make sure that a preference name is valid.

parse_preference_name(name)

Split a preference name into a base and end name.

Objects

brian_prefs

prefs

Preference categories:

spikesource module

Exported members: SpikeSource

Classes

SpikeSource()

A source of spikes.

tracking module

Exported members: Trackable

Classes

InstanceFollower()

Keep track of all instances of classes derived from Trackable

InstanceTrackerSet

A set of weakref.ref to all existing objects of a certain class.

Trackable(*args, **kw)

Classes derived from this will have their instances tracked.

variables module

Classes used to specify the type of a function, variable or common sub-expression.

Exported members: Variable, Constant, ArrayVariable, DynamicArrayVariable, Subexpression, AuxiliaryVariable, VariableView, Variables, LinkedVariable, linked_var()

Classes

ArrayVariable(name, owner, size, device[, ...])

An object providing information about a model variable stored in an array (for example, all state variables).

AuxiliaryVariable(name[, dimensions, dtype, ...])

Variable description for an auxiliary variable (most likely one that is added automatically to abstract code, e.g. _cond for a threshold condition), specifying its type and unit for code generation.

Constant(name, value[, dimensions, owner])

A scalar constant (e.g. the number of neurons N).

DynamicArrayVariable(name, owner, size, device)

An object providing information about a model variable stored in a dynamic array (used in Synapses).

LinkedVariable(group, name, variable[, index])

A simple helper class to make linking variables explicit.

Subexpression(name, owner, expr, device[, ...])

An object providing information about a named subexpression in a model.

Variable(name[, dimensions, owner, dtype, ...])

An object providing information about model variables (including implicit variables such as t or xi).

VariableView(name, variable, group[, dimensions])

A view on a variable that allows to treat it as an numpy array while allowing special indexing (e.g. with strings) in the context of a Group.

Variables(owner[, default_index])

A container class for storing Variable objects.

Functions

get_dtype(obj)

Helper function to return the numpy.dtype of an arbitrary object.

get_dtype_str(val)

Returns canonical string representation of the dtype of a value or dtype

linked_var(group_or_variable[, name, index])

Represents a link target for setting a linked variable.

variables_by_owner(variables, owner)