class brainpy.running.Monitor(variables, intervals=None)[source]#

The basic Monitor class to store the past variable trajectories.

Currently, brainpy.simulation.Monitor support to specify:

  • variable key by strings.

  • variable index by None, int, list, tuple, 1D array/tensor (==> all will be transformed into a 1D array/tensor)

  • variable monitor interval by None, int, float

Users can instance a monitor object by multiple ways:

  1. list of strings.

>>> Monitor(variables=['a', 'b', 'c'])

1.1. list of strings and list of intervals

>>> Monitor(variables=['a', 'b', 'c'],
>>>         intervals=[None, 1, 2] # ms
>>>        )
  1. list of strings and string + indices

>>> Monitor(variables=['a', ('b', bm.array([1,2,3])), 'c'])

2.1. list of string (+ indices) and list of intervals

>>> Monitor(variables=['a', ('b', bm.array([1,2,3])), 'c'],
>>>         intervals=[None, 2, 3])
  1. a dictionary with the format of {key: indices}

>>> Monitor(variables={'a': None, 'b': bm.array([1,2,3])})

3.1. a dictionary of variable and indexes, and a dictionary of time intervals

>>> Monitor(variables={'a': None, 'b': bm.array([1,2,3])},
>>>         intervals={'b': 2.})


brainpy.simulation.Monitor records any target variable with an two-dimensional array/tensor with the shape of (num_time_step, variable_size). This means for any variable, no matter what’s the shape of the data (int, float, vector, matrix, 3D array/tensor), will be reshaped into a one-dimensional vector.

__init__(variables, intervals=None)[source]#


__init__(variables[, intervals])