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 ofdt
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, int
The time step corresponding to the given time.
Notes
This function can handle infinity values, it will return a value equal to half of the maximal integer value. This assures that an expression such as
timestep(t) - timestep(lastspike)
will result in a reasonable value even iflastspike
is-inf
. Iftimestep(lastspike)
were equal to the minimal representable integer value, this expression would overflow.