Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
apdavison committed Oct 14, 2022
1 parent a79a351 commit df7568c
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 48 deletions.
1 change: 0 additions & 1 deletion test/system/scenarios/test_issue274.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

from pyNN.random import RandomDistribution as rnd
from .fixtures import run_with_simulators
import pytest


@run_with_simulators("nest", "neuron", "brian2")
Expand Down
1 change: 0 additions & 1 deletion test/system/scenarios/test_parameter_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from numpy import nan
from numpy.testing import assert_array_equal, assert_allclose
from .fixtures import run_with_simulators
import pytest


@run_with_simulators("nest", "neuron", "brian2")
Expand Down
1 change: 0 additions & 1 deletion test/system/scenarios/test_procedural_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from numpy.testing import assert_allclose
from pyNN.utility import init_logging
from .fixtures import run_with_simulators
import pytest


@run_with_simulators("nest", "neuron", "brian2")
Expand Down
1 change: 0 additions & 1 deletion test/system/scenarios/test_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from neo.io import get_io
from pyNN.utility import normalized_filename
from .fixtures import run_with_simulators
import pytest


@run_with_simulators("neuron", "brian2")
Expand Down
1 change: 0 additions & 1 deletion test/system/scenarios/test_scenario1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
from pyNN.random import NumpyRNG, RandomDistribution
from .fixtures import run_with_simulators
import pytest


@run_with_simulators("nest", "neuron", "brian2")
Expand Down
1 change: 0 additions & 1 deletion test/system/scenarios/test_scenario2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import numpy as np
from .fixtures import run_with_simulators
import pytest


@run_with_simulators("nest", "neuron", "brian2")
Expand Down
1 change: 0 additions & 1 deletion test/system/scenarios/test_scenario4.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pyNN.space import Space, Grid3D, RandomStructure, Cuboid
from pyNN.utility import init_logging
from .fixtures import run_with_simulators
import pytest


logger = logging.getLogger("TEST")
Expand Down
1 change: 0 additions & 1 deletion test/system/scenarios/test_synapse_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import numpy as np
from .fixtures import run_with_simulators
import pytest


@run_with_simulators("nest", "neuron")
Expand Down
1 change: 0 additions & 1 deletion test/system/scenarios/test_ticket166.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import numpy as np
from .fixtures import run_with_simulators
import pytest


@run_with_simulators("nest", "neuron", "brian2")
Expand Down
80 changes: 41 additions & 39 deletions test/system/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,47 @@
import pytest

def test():
if not HAVE_H5PY and HAVE_NEST:
pytest.skip("Either h5py or nest is not available")

sim.setup()

p1 = sim.Population(10,
sim.IF_cond_exp(
v_rest=-65,
tau_m=lambda i: 10 + 0.1*i,
cm=RD('normal', (0.5, 0.05))),
label="population_one")
p2 = sim.Population(20,
sim.IF_curr_alpha(
v_rest=-64,
tau_m=lambda i: 11 + 0.1*i),
label="population_two")

prj = sim.Projection(p1, p2,
sim.FixedProbabilityConnector(p_connect=0.5),
synapse_type=sim.StaticSynapse(weight=RD('uniform', [0.0, 0.1]),
delay=0.5),
receptor_type='excitatory')

net = Network(p1, p2, prj)

export_to_sonata(net, "tmp_serialization_test", overwrite=True)

net2 = import_from_sonata("tmp_serialization_test/circuit_config.json", sim)

for orig_population in net.populations:
imp_population = net2.get_component(orig_population.label)
assert orig_population.size == imp_population.size
for name in orig_population.celltype.default_parameters:
assert_array_almost_equal(orig_population.get(name), imp_population.get(name), 12)

w1 = prj.get('weight', format='array')
prj2 = net2.get_component(asciify(prj.label).decode('utf-8') + "-0")
w2 = prj2.get('weight', format='array')
assert_array_almost_equal(w1, w2, 12)
if not HAVE_H5PY:
pytest.skip("h5py not available")
elif not HAVE_NEST:
pytest.skip("nest not available")
else:
sim.setup()

p1 = sim.Population(10,
sim.IF_cond_exp(
v_rest=-65,
tau_m=lambda i: 10 + 0.1*i,
cm=RD('normal', (0.5, 0.05))),
label="population_one")
p2 = sim.Population(20,
sim.IF_curr_alpha(
v_rest=-64,
tau_m=lambda i: 11 + 0.1*i),
label="population_two")

prj = sim.Projection(p1, p2,
sim.FixedProbabilityConnector(p_connect=0.5),
synapse_type=sim.StaticSynapse(weight=RD('uniform', [0.0, 0.1]),
delay=0.5),
receptor_type='excitatory')

net = Network(p1, p2, prj)

export_to_sonata(net, "tmp_serialization_test", overwrite=True)

net2 = import_from_sonata("tmp_serialization_test/circuit_config.json", sim)

for orig_population in net.populations:
imp_population = net2.get_component(orig_population.label)
assert orig_population.size == imp_population.size
for name in orig_population.celltype.default_parameters:
assert_array_almost_equal(orig_population.get(name), imp_population.get(name), 12)

w1 = prj.get('weight', format='array')
prj2 = net2.get_component(asciify(prj.label).decode('utf-8') + "-0")
w2 = prj2.get('weight', format='array')
assert_array_almost_equal(w1, w2, 12)


if __name__ == "__main__":
Expand Down

0 comments on commit df7568c

Please sign in to comment.