# brainpy.math.delayvars.TimeDelay#

class brainpy.math.delayvars.TimeDelay(delay_target, delay_len, before_t0=None, t0=0.0, dt=None, name=None, interp_method='linear_interp')[source]#

Delay variable which has a fixed delay time length.

For example, we create a delay variable which has a maximum delay length of 1 ms

>>> import brainpy.math as bm
>>> delay = bm.TimeDelay(bm.zeros(3), delay_len=1., dt=0.1)
>>> delay(-0.5)
[-0. -0. -0.]


This function supports multiple dimensions of the tensor. For example,

1. the one-dimensional delay data

>>> delay = bm.TimeDelay(bm.zeros(3), delay_len=1., dt=0.1, before_t0=lambda t: t)
>>> delay(-0.2)
[-0.2 -0.2 -0.2]

1. the two-dimensional delay data

>>> delay = bm.TimeDelay(bm.zeros((3, 2)), delay_len=1., dt=0.1, before_t0=lambda t: t)
>>> delay(-0.6)
[[-0.6 -0.6]
[-0.6 -0.6]
[-0.6 -0.6]]

1. the three-dimensional delay data

>>> delay = bm.TimeDelay(bm.zeros((3, 2, 1)), delay_len=1., dt=0.1, before_t0=lambda t: t)
>>> delay(-0.8)
[[[-0.8]
[-0.8]]
[[-0.8]
[-0.8]]
[[-0.8]
[-0.8]]]

Parameters
• delay_target (JaxArray, ndarray, Variable) – The initial delay data.

• t0 (float, int) – The zero time.

• delay_len (float, int) – The maximum delay length.

• dt (float, int) – The time precesion.

• before_t0 (callable, bm.ndarray, jnp.ndarray, float, int) –

The delay data before ::matht_0. - when before_t0 is a function, it should receive a time argument t - when before_to is a tensor, it should be a tensor with shape

of $$(num\_delay, ...)$$, where the longest delay data is aranged in the first index.

• name (str) – The delay instance name.

• interp_method (str) –

The way to deal with the delay at the time which is not integer times of the time step. For exameple, if the time step dt=0.1, the time delay length delay\_len=1., when users require the delay data at t-0.53, we can deal this situation with the following methods:

• "linear_interp": using linear interpolation to get the delay value at the required time (default).

• "round": round the time to make it is the integer times of the time step. For the above situation, we will use the time at t-0.5 to approximate the delay data at t-0.53.

New in version 2.1.1.

__init__(delay_target, delay_len, before_t0=None, t0=0.0, dt=None, name=None, interp_method='linear_interp')[source]#

Methods

 __init__(delay_target, delay_len[, ...]) load_states(filename[, verbose]) Load the model states. nodes([method, level, include_self]) Collect all children nodes. register_implicit_nodes(*nodes, **named_nodes) register_implicit_vars(*variables, ...) reset(delay_target, delay_len[, t0, before_t0]) Reset the delay variable. save_states(filename[, variables]) Save the model states. train_vars([method, level, include_self]) The shortcut for retrieving all trainable variables. unique_name([name, type_]) Get the unique name for this object. update(time, value) vars([method, level, include_self]) Collect all variables in this node and the children nodes.

Attributes

 name Name of the model.