Skip to content
Snippets Groups Projects
Commit c1c7f692 authored by Simon Oehrl's avatar Simon Oehrl
Browse files

Merge branch 'feature/Fix_spikes_per_population' into 'develop'

Remove redundant code and use existing functions

See merge request VR-Group/in-situ-pipeline/access-node!7
parents 8352d3c5 c1cee84c
No related branches found
No related tags found
1 merge request!7Remove redundant code and use existing functions
Pipeline #163402 passed
...@@ -321,60 +321,7 @@ def nest_get_spikes_by_population(population_id, _from=None, to=None, offset=Non ...@@ -321,60 +321,7 @@ def nest_get_spikes_by_population(population_id, _from=None, to=None, offset=Non
:rtype: Spikes :rtype: Spikes
""" """
con = connect_to_database() gids = nest_get_gids_in_population(population_id)
cur = con.cursor() return nest_get_spikes(_from, to, gids, offset, limit)
cur.execute("SELECT address FROM nest_simulation_node")
nodes.nest_simulation_nodes = [i[0] for i in cur.fetchall()]
con.close()
print("Updated simumlation nodes: " + str(nodes.nest_simulation_nodes))
spikes = Spikes([], [])
for node in nodes.nest_simulation_nodes:
response = requests.get(
node+'/spikes', params={"from": _from, "to": to, "population": population_id})
try:
response_json = response.json()
spikes.simulation_times.extend(response_json['simulation_times'])
spikes.gids.extend(response_json['gids'])
except:
pass
# # sort
# sorted_ids = [x for _, x in sorted(
# zip(spikes.simulation_times, spikes.gids))]
# spikes.gids = sorted_ids
# spikes.simulation_times.sort()
# # offset and limit
# if (offset is None):
# offset = 0
# if (limit is None or (limit + offset) > len(spikes.gids)):
# limit = len(spikes.gids) - offset
# spikes.gids = spikes.gids[offset:offset+limit]
# spikes.simulation_times = spikes.simulation_times[offset:offset+limit]
return spikes
# spikes = Spikes([], [])
# for node in nodes.nest_simulation_nodes:
# response = requests.get(
# node+'/population/$'+str(population_id)+'/spikes', params={"from": _from, "to": to}).json()
# for x in range(len(response['simulation_times'])):
# spikes.simulation_times.append(response['simulation_times'][x])
# spikes.gids.append(response['gids'][x])
# # sort
# sorted_ids = [x for _, x in sorted(
# zip(spikes.simulation_times, spikes.gids))]
# spikes.gids = sorted_ids
# spikes.simulation_times.sort()
# # offset and limit
# if (offset is None):
# offset = 0
# if (limit is None or (limit + offset) > len(spikes.gids)):
# limit = len(spikes.gids) - offset
# spikes.gids = spikes.gids[offset:offset+limit]
# spikes.simulation_times = spikes.simulation_times[offset:offset+limit]
# return spikes
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment