# Buggy code
def initialise_queue(self):
    if self.queue is None:
        self.queue = get_device().spike_queue(self.source.start, self.source.stop)

    # Update the dt (might have changed between runs)

    self.queue.prepare(
        self._delays.get_value(),
        self.source.clock.dt_,
        self.synapse_sources.get_value(),
    )

    if (
        len(
            set([self.source.clock.dt_, self.synapses.clock.dt_, self.target.clock.dt_])
        )
        > 1
    ):
        logger.warn(
            (
                "Note that the synaptic pathway '{pathway}' will run on the "
                "clock of the group '{source}' using a dt of {dt}. Either "
                "the Synapses object '{synapses}' or the target '{target}' "
                "(or both) are using a different dt. This might lead to "
                "unexpected results. In particular, all delays will be rounded to "
                "multiples of {dt}. If in doubt, try to ensure that "
                "'{source}', '{synapses}', and '{target}' use the "
                "same dt."
            ).format(
                pathway=self.name,
                source=self.source.name,
                target=self.target.name,
                dt=self.source.clock.dt,
                synapses=self.synapses.name,
            ),
            "synapses_dt_mismatch",
            once=True,
        )


# Traceback (IndexError)
SG = SpikeGeneratorGroup(1, [0], [0*ms])
G = NeuronGroup(1, 'v:1')
S = Synapses(SG, G, pre='v+=1')
run(0.1*ms)
Traceback (most recent call last):
...
File "/home/marcel/programming/brian2/brian2/synapses/spikequeue.py", line 254, in push
self._insert_homogeneous(self._delays[0], indices)
IndexError: index 0 is out of bounds for axis 0 with size 0

# Fixed code
def initialise_queue(self):
    if self.synapse_sources.get_len() == 0:
        logger.warn(
            (
                "Synapses object '%s' does not have any synapses. Did "
                "you forget a 'connect'?"
            )
            % self.synapses.name,
            "no_synapses",
            once=True,
        )
    if self.queue is None:
        self.queue = get_device().spike_queue(self.source.start, self.source.stop)

    # Update the dt (might have changed between runs)

    self.queue.prepare(
        self._delays.get_value(),
        self.source.clock.dt_,
        self.synapse_sources.get_value(),
    )

    if (
        len(
            set([self.source.clock.dt_, self.synapses.clock.dt_, self.target.clock.dt_])
        )
        > 1
    ):
        logger.warn(
            (
                "Note that the synaptic pathway '{pathway}' will run on the "
                "clock of the group '{source}' using a dt of {dt}. Either "
                "the Synapses object '{synapses}' or the target '{target}' "
                "(or both) are using a different dt. This might lead to "
                "unexpected results. In particular, all delays will be rounded to "
                "multiples of {dt}. If in doubt, try to ensure that "
                "'{source}', '{synapses}', and '{target}' use the "
                "same dt."
            ).format(
                pathway=self.name,
                source=self.source.name,
                target=self.target.name,
                dt=self.source.clock.dt,
                synapses=self.synapses.name,
            ),
            "synapses_dt_mismatch",
            once=True,
        )