brian2 package

Brian 2


clear_cache(target) Clears the on-disk cache with the compiled files for a given code generation target.

hears module

This is only a bridge for using Brian 1 hears with Brian 2.


  • Slicing sounds with Brian 2 units doesn’t work, you need to either use Brian 1 units or replace calls to sound[:20*ms] with sound.slice(None, 20*ms), etc.

TODO: handle properties (e.g. sound.duration)

Not working examples:

  • time_varying_filter1 (care with units)

Exported members: convert_unit_b1_to_b2, convert_unit_b2_to_b1


BridgeSound We add a new method slice because slicing with units can’t work with Brian 2 units.
FilterbankGroup(filterbank, targetvar, …)


Sound alias of brian2.hears.BridgeSound
WrappedSound alias of brian2.hears.new_class


modify_arg(arg) Modify arguments to make them compatible with Brian 1.
wrap_units(f) Wrap a function to convert units into a form that Brian 1 can handle.
wrap_units_class(_C) Wrap a class to convert units into a form that Brian 1 can handle in all methods

numpy_ module

A dummy package to allow importing numpy and the unit-aware replacements of numpy functions without having to know which functions are overwritten.

This can be used for example as import brian2.numpy_ as np

Exported members: add_newdocs, ModuleDeprecationWarning, VisibleDeprecationWarning, __version__, pkgload(), PackageLoader, show_config(), char, rec, memmap, newaxis, ndarray, flatiter, nditer, nested_iters, ufunc, arange(), array, zeros, count_nonzero(), empty, broadcast, dtype, fromstring, fromfile … (625 more members)

only module

A dummy package to allow wildcard import from brian2 without also importing the pylab (numpy + matplotlib) namespace.

Usage: from brian2.only import *


restore_initial_state() Restores internal Brian variables to the state they are in when Brian is imported