timestep function

(Shortest import: from brian2.core.functions import timestep)

brian2.core.functions.timestep(t, dt)[source]

Converts a given time to an integer time step. This function slightly shifts the time before dividing it by dt to make sure that multiples of dt do not end up in the preceding time step due to floating point issues. This function is used in the refractoriness calculation.

New in version 2.1.3.

Parameters

t : np.ndarray, float, Quantity

The time to convert.

dt : float or Quantity

The length of a simulation time step.

Returns

ts : np.ndarray, np.int64

The time step corresponding to the given time.

Notes

This function cannot handle infinity values, use big values instead (e.g. a NeuronGroup will use -1e4*second as the value of the lastspike variable for neurons that never spiked).