class brainpy.math.environment(mode=None, membrane_scaling=None, dt=None, x64=None, complex_=None, float_=None, int_=None, bool_=None)[source]#

Context-manager that sets a computing environment for brain dynamics computation.

In BrainPy, there are several basic computation settings when constructing models, including mode for controlling model computing behavior, dt for numerical integration, int_ for integer precision, and float_ for floating precision. environment` provides a context for model construction and computation. In this temporal environment, models are constructed with the given mode, dt, int_, etc., environment settings.

For instance:

>>> import brainpy as bp
>>> import brainpy.math as bm
>>> with bm.environment(mode=bm.training_mode, dt=0.1):
>>>   lif1 = bp.neurons.LIF(1)
>>> with bm.environment(mode=bm.nonbatching_mode, dt=0.05, float_=bm.float64):
>>>   lif2 = bp.neurons.LIF(1)