{#
USES_VARIABLES { _synaptic_pre, _synaptic_post, sources, targets, N,
                 N_pre, N_post, _source_offset, _target_offset }
#}
{# WRITES_TO_READ_ONLY_VARIABLES { _synaptic_pre, _synaptic_post, N}
#}
{# This is to show that we don't need to index the sources/targets #}
{# ITERATE_ALL { _idx } #}

{# After this code has been executed, the arrays _real_sources and
   _real_variables contain the final indices. Having any code here it all is
   only necessary for supporting subgroups #}
import numpy as _numpy

{{vector_code|autoindent}}

_old_num_synapses = {{N}}
_new_num_synapses = _old_num_synapses + len({{sources}})
{{_dynamic__synaptic_pre}}.resize(_new_num_synapses)
{{_dynamic__synaptic_post}}.resize(_new_num_synapses)
{{_dynamic__synaptic_pre}}[_old_num_synapses:] = _real_sources
{{_dynamic__synaptic_post}}[_old_num_synapses:] = _real_targets

# Resize all dependent dynamic arrays (synaptic weights, delays, etc.) and set
# the total number of synapses
_owner._resize(_new_num_synapses)

# And update N_incoming, N_outgoing and synapse_number
_owner._update_synapse_numbers(_old_num_synapses)
