# Clock class

(Shortest import: `from brian2 import Clock)`

class brian2.core.clocks.Clock(*args, **kw)

  Bases: `BaseClock`

  An object that holds the simulation time and the time step.

  Parameters:

    dt : float

    > The time step of the simulation as a float

    name : str, optional

    > An explicit name, if not specified gives an automatically generated name

  Notes

  Clocks are run in the same `Network.run` iteration if `t` is the same. The condition for two clocks to be considered as having the same time is `abs(t1-t2)<epsilon*abs(t1)`, a standard test for equality of floating point values. The value of `epsilon` is `1e-14`.

  Attributes

  `dt` | The time step of the simulation in seconds.
  `dt_` | The time step of the simulation as a float (in seconds)
  `epsilon_dt` | The relative difference for times (in terms of dt) so that they are considered identical.

  Methods

  `advance`() | Advance to the next time step.
  `same_time`(other) | Check if two clocks are at the same time (within epsilon_dt * dt).
  `set_interval`(start, end) | Set the start and end time of the simulation.

  Details

  dt

    The time step of the simulation in seconds.

  dt_

    The time step of the simulation as a float (in seconds)

  epsilon_dt

    The relative difference for times (in terms of dt) so that they are considered identical.

  advance()

    Advance to the next time step.

  same_time(other)

    Check if two clocks are at the same time (within epsilon_dt * dt).

    Parameters:

      other : BaseClock

      > The other clock to compare with

    Returns:

      bool :

      > True if both clocks are at the same time

  set_interval(start, end)

    Set the start and end time of the simulation.

    Sets the start and end value of the clock precisely if possible (using epsilon_dt) or rounding up if not. This assures that multiple calls to `Network.run` will not re-run the same time step.

    Parameters:

      start : second

      > The start time of the simulation

      end : second

      > The end time of the simulation

## Tutorials and examples using this

- Example COBAHH

- Example CUBA