const e=`{{ #simulation.code.importModules }}
import nest
import numpy
import pyNN.nest as sim
{{ /simulation.code.importModules }}
{{ #simulation.code.setKernelStatus }}

sim = pyNN.nest    # Only for NEST Server

# Initialize simulation setup (reset kernel)
sim.setup(
  threads={{ simulation.kernel.localNumThreads }},
  timestep={{ simulation.kernel.resolution }},
  rng_seed={{ simulation.kernel.rngSeed }}
)
{{ /simulation.code.setKernelStatus }}
{{ #simulation.code.createNodes }}

# Create populations
{{ #network.stimulators }}
{{ view.label }}_model = sim.native_cell_type('{{ modelId }}')
{{ view.label }} = sim.Population({{ n }}, {{ view.label }}_model({{ #hasSomeVisibleParams }}
{{ #filteredParams }}
  {{ id }}={{ code }},
{{ /filteredParams }}{{ /hasSomeVisibleParams }}))
{{ /network.stimulators }}
{{ #network.neurons }}
{{ view.label }}_model = sim.native_cell_type('{{ modelId }}')
{{ view.label }} = sim.Population({{ n }}, {{ view.label }}_model({{ #hasSomeVisibleParams }}{{ #filteredParams }}
  {{ id }}={{ code }},
{{ /filteredParams }}{{ /hasSomeVisibleParams }}))
{{ #recordSpikes }}{{ view.label }}.record('spikes'){{ /recordSpikes }}
{{ #recordAnalogSignals }}{{ view.label }}.record(){{ /recordAnalogSignals }}
{{ /network.neurons }}
{{ /simulation.code.createNodes }}
{{ #simulation.code.connectNodes }}

# Connect nodes
{{ #network.connectionsExcludeRecorders }}
conn_spec = sim.{{ rule.toPyNN }}Connector({{ #hasSomeVisibleParams }}{{ #filteredParams }}
  {{ PyNNParamId }}={{ code }},
{{ /filteredParams }}{{ /hasSomeVisibleParams }})
syn_spec = sim.StaticSynapse(weight={{ synapse.weight }})
sim.Projection({{ source.view.label }}{{ sourceSlice.indices }}, {{ target.view.label }}{{ targetSlice.indices }}, conn_spec, syn_spec)
{{ /network.connectionsExcludeRecorders }}
{{ /simulation.code.connectNodes }}

{{ #simulation.code.runSimulation }}
# Run simulation
sim.run({{ simulation.time }})

response = {
  "events": [
    {{ #network.recorders }}n.events for n in nest.GetNodes()
    if n.element_type == 'recorder' and n.n_events>0{{ /network.recorders }}
  ]
}
{{ /simulation.code.runSimulation }}
`;export{e as default};
