Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[[tool.mypy.overrides]]
module = ["csa", "docstring_parser", "matplotlib", "matplotlib.*", "pyNN.*", "quantities", "neo", "neo.*", "scipy", "scipy.*", "lazyarray", "testfixtures"]
module = ["csa", "docstring_parser", "matplotlib", "matplotlib.*", "parameterized", "pyNN.*", "quantities", "neo", "neo.*", "scipy", "scipy.*", "lazyarray", "testfixtures"]
ignore_missing_imports = true
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ spynnaker.pyNN.model_binaries =
[options.extras_require]
test =
SpiNNakerTestBase == 1!7.4.2
parameterized
# pytest will be brought in by pytest-cov
pytest-cov
testfixtures
Expand Down
1 change: 1 addition & 0 deletions spynnaker/pyNN/data/spynnaker_data_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def _setup(self) -> None:

@overrides(FecDataWriter._mock)
def _mock(self) -> None:
self.__spy_data._clear()
FecDataWriter._mock(self)
self.set_min_delay(1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ def is_same_as(
# pylint: disable=unidiomatic-typecheck
(type(self.partner_selection) == # noqa: E721
type(synapse_dynamics.partner_selection)) and
(type(self.formation) ==
(type(self.formation) is
type(synapse_dynamics.formation)) and
(type(self.elimination) ==
(type(self.elimination) is
type(synapse_dynamics.elimination)))

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, isyn_exc: ModelParameter, isyn_inh: ModelParameter):
[Struct([
(DataType.S1615, ISYN_EXC), # isyn_exc
(DataType.S1615, ISYN_INH)])], # isyn_inh
{ISYN_EXC: "", ISYN_EXC: ""})
{ISYN_EXC: "", ISYN_INH: ""})
self.__isyn_exc = isyn_exc
self.__isyn_inh = isyn_inh

Expand Down
49 changes: 35 additions & 14 deletions unittests/model_tests/neuron/test_synaptic_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
import struct
from typing import Any, BinaryIO, List, Optional, Sequence, Tuple
import unittest

from parameterized import parameterized
from tempfile import mkdtemp
import numpy
import pytest

from spinn_utilities.overrides import overrides
from spinn_utilities.config_holder import set_config
from spinn_machine.version.version_strings import VersionStrings
from spinn_machine.version import MANY_BOARD_TYPES, FIVE, SPIN2_48CHIP
from spinnman.transceiver.mockable_transceiver import MockableTransceiver
from spinnman.transceiver import Transceiver
from pacman.model.placements import Placement
Expand Down Expand Up @@ -103,9 +105,10 @@ def say_false(*args: Any, **kwargs: Any) -> bool:
return False


def test_write_data_spec() -> None:
@parameterized.expand(MANY_BOARD_TYPES)
def test_write_data_spec(_: str, ver_num: str) -> None:
unittest_setup()
set_config("Machine", "versions", VersionStrings.ANY.text)
set_config("Machine", "version", ver_num)
writer = SpynnakerDataWriter.mock()
# UGLY but the mock transceiver NEED generate_on_machine to be False
AbstractGenerateConnectorOnMachine.\
Expand Down Expand Up @@ -408,33 +411,51 @@ def test_set_synapse_dynamics() -> None:

@pytest.mark.parametrize(
"undelayed_indices_connected,delayed_indices_connected,n_pre_neurons,"
"neurons_per_core,max_delay", [
"neurons_per_core,max_delay,version_number", [
# Only undelayed, all edges exist
(range(10), [], 1000, 100, None, FIVE),
# Only delayed, all edges exist
([], range(10), 1000, 100, 200, FIVE),
# All undelayed and delayed edges exist
(range(10), range(10), 1000, 100, 200, FIVE),
# Only undelayed, some connections missing but app keys can still work
([0, 1, 2, 3, 4], [], 1000, 100, None, FIVE),
# Only delayed, some connections missing but app keys can still work
([], [5, 6, 7, 8, 9], 1000, 100, 200, FIVE),
# Both delayed and undelayed, some undelayed edges don't exist
# (app keys work because undelayed aren't filtered)
([3, 4, 5, 6, 7], range(10), 1000, 100, 200, FIVE),
# Both delayed and undelayed, some delayed edges don't exist
# (app keys work because all undelayed exist)
(range(10), [4, 5, 6, 7], 1000, 100, 200, FIVE),
# Should work but number of cores doesn't work out
(range(100), [], 10000, 5, None, FIVE),
# Only undelayed, all edges exist
(range(10), [], 1000, 100, None),
(range(10), [], 1000, 100, None, SPIN2_48CHIP),
# Only delayed, all edges exist
([], range(10), 1000, 100, 200),
([], range(10), 1000, 100, 200, SPIN2_48CHIP),
# All undelayed and delayed edges exist
(range(10), range(10), 1000, 100, 200),
(range(10), range(10), 1000, 100, 200, SPIN2_48CHIP),
# Only undelayed, some connections missing but app keys can still work
([0, 1, 2, 3, 4], [], 1000, 100, None),
([0, 1, 2, 3, 4], [], 1000, 100, None, SPIN2_48CHIP),
# Only delayed, some connections missing but app keys can still work
([], [5, 6, 7, 8, 9], 1000, 100, 200),
([], [5, 6, 7, 8, 9], 1000, 100, 200, SPIN2_48CHIP),
# Both delayed and undelayed, some undelayed edges don't exist
# (app keys work because undelayed aren't filtered)
([3, 4, 5, 6, 7], range(10), 1000, 100, 200),
([3, 4, 5, 6, 7], range(10), 1000, 100, 200, SPIN2_48CHIP),
# Both delayed and undelayed, some delayed edges don't exist
# (app keys work because all undelayed exist)
(range(10), [4, 5, 6, 7], 1000, 100, 200),
(range(10), [4, 5, 6, 7], 1000, 100, 200, SPIN2_48CHIP),
# Should work but number of cores doesn't work out
(range(100), [], 10000, 5, None)
(range(100), [], 10000, 5, None, SPIN2_48CHIP)
])
def test_pop_based_master_pop_table_standard(
undelayed_indices_connected: Sequence[int],
delayed_indices_connected: Sequence[int],
n_pre_neurons: int, neurons_per_core: int,
max_delay: Optional[int]) -> None:
max_delay: Optional[int], version_number: int) -> None:
unittest_setup()
set_config("Machine", "versions", VersionStrings.FOUR_PLUS.text)
set_config("Machine", "version", str(version_number))
writer = SpynnakerDataWriter.mock()

# Build a from list connector with the delays we want
Expand Down
2 changes: 0 additions & 2 deletions unittests/test_integration_using_virtual_board/spynnaker.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[Machine]
machine_spec_file = None
version = None
versions = Any
virtual_board = True
machine_name = None
spalloc_server = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from parameterized import parameterized
import pyNN.spiNNaker as sim

from spinn_utilities.config_holder import set_config

from spinn_machine.version import MANY_BOARD_TYPES

from spinnaker_testbase import BaseTestCase


class SSANeuronClassNoEdgeTest(BaseTestCase):

# NO unittest_setup() as sim.setup is called

def test_run(self) -> None:
@parameterized.expand(MANY_BOARD_TYPES)
def test_run(self, _: str, ver_num: str) -> None:
sim.setup()
set_config("Machine", "version", ver_num)

sim.Population(3, sim.SpikeSourceArray,
{"spike_times": [1.0, 2.0, 3.0]})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from parameterized import parameterized
import pyNN.spiNNaker as sim

from spinn_utilities.config_holder import set_config

from spinn_machine.version import MANY_BOARD_TYPES

from spinnaker_testbase import BaseTestCase


class SSPNeuronClassNoEdgeTest(BaseTestCase):

# NO unittest_setup() as sim.setup is called

def test_run(self) -> None:
@parameterized.expand(MANY_BOARD_TYPES)
def test_run(self, _: str, ver_num: str) -> None:
sim.setup()
set_config("Machine", "version", ver_num)

sim.Population(3, sim.SpikeSourcePoisson, {"rate": 100})
p2 = sim.Population(3, sim.SpikeSourceArray,
Expand All @@ -34,11 +42,3 @@ def test_run(self) -> None:
sim.run(100.0)

sim.end()


if __name__ == "__main__":
"""
main entrance method
"""
blah = SSPNeuronClassNoEdgeTest()
blah.test_run()
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from parameterized import parameterized
import pyNN.spiNNaker as p

from spinn_utilities.config_holder import set_config

from spinn_machine.version import MANY_BOARD_TYPES

from spinnaker_testbase import BaseTestCase


def do_run() -> None:
def do_run(ver_num: str) -> None:
p.setup(1.0)
set_config("Machine", "version", ver_num)
n_neurons = 2

pop_a = p.Population(n_neurons, p.extra_models.SpikeSourcePoissonVariable(
Expand Down Expand Up @@ -109,9 +117,6 @@ class TestCreatePoissons(BaseTestCase):

# NO unittest_setup() as sim.setup is called

def test_run(self) -> None:
do_run()


if __name__ == '__main__':
do_run()
@parameterized.expand(MANY_BOARD_TYPES)
def test_run(self, _: str, ver_num: str) -> None:
do_run(ver_num)
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from parameterized import parameterized
import pyNN.spiNNaker as p

from spinn_utilities.config_holder import set_config

from spinn_machine.version import MANY_BOARD_TYPES

from spinnaker_testbase import BaseTestCase


def do_run() -> None:
def do_run(ver_num: str) -> None:
p.setup(0.1)
set_config("Machine", "version", ver_num)
runtime = 50
populations = []

Expand Down Expand Up @@ -46,9 +53,6 @@ class TestAlpha(BaseTestCase):

# NO unittest_setup() as sim.setup is called

def test_run(self) -> None:
do_run()


if __name__ == '__main__':
do_run()
@parameterized.expand(MANY_BOARD_TYPES)
def test_run(self, _: str, ver_num: str) -> None:
do_run(ver_num)
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.


from parameterized import parameterized
import pyNN.spiNNaker as p

from spinn_utilities.config_holder import set_config

from spinn_machine.version import MANY_BOARD_TYPES

from spinnaker_testbase import BaseTestCase


def do_run(nNeurons: int) -> None:
def do_run(nNeurons: int, ver_num: str) -> None:

p.setup(timestep=1.0, min_delay=1.0)
set_config("Machine", "version", ver_num)

cell_params_lif_in = {'tau_m': 333.33, 'cm': 208.33, 'v': 0.0,
'v_rest': 0.1, 'v_reset': 0.0, 'v_thresh': 1.0,
Expand All @@ -46,11 +54,7 @@ class OnePopLifExample(BaseTestCase):

# NO unittest_setup() as sim.setup is called

def test_run(self) -> None:
@parameterized.expand(MANY_BOARD_TYPES)
def test_run(self, _: str, ver_num: str) -> None:
nNeurons = 255 # number of neurons in each population
do_run(nNeurons)


if __name__ == '__main__':
nNeurons = 255 # number of neurons in each population
do_run(nNeurons)
do_run(nNeurons, ver_num)
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from parameterized import parameterized
from pyNN.random import RandomDistribution
import pyNN.spiNNaker as p

from spinn_utilities.config_holder import set_config

from spinn_machine.version import MANY_BOARD_TYPES

from spinnaker_testbase import BaseTestCase


def do_run(nNeurons: int) -> None:
def do_run(nNeurons: int, ver_num: str) -> None:

p.setup(timestep=1.0, min_delay=1.0)
set_config("Machine", "version", ver_num)

p.set_number_of_neurons_per_core(p.IF_curr_exp, 100)

Expand Down Expand Up @@ -97,9 +104,6 @@ class ParamsSetAsList(BaseTestCase):

# NO unittest_setup() as sim.setup is called

def test_run(self) -> None:
do_run(225) # number of neurons in each population


if __name__ == '__main__':
do_run(225) # number of neurons in each population
@parameterized.expand(MANY_BOARD_TYPES)
def test_run(self, _: str, ver_num: str) -> None:
do_run(255, ver_num)
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@
"""
Synfirechain-like example
"""
from parameterized import parameterized
import pyNN.spiNNaker as p

from spinn_utilities.config_holder import set_config

from spinn_machine.version import MANY_BOARD_TYPES

from spinnaker_testbase import BaseTestCase


def do_run(nNeurons: int) -> None:
def do_run(nNeurons: int, ver_num: str) -> None:
p.setup(timestep=1.0, min_delay=1.0)
set_config("Machine", "version", ver_num)

p.set_number_of_neurons_per_core(p.Izhikevich, 100)

cell_params_izk = {
Expand Down Expand Up @@ -77,11 +85,7 @@ class SynfireIzhikevich(BaseTestCase):

# NO unittest_setup() as sim.setup is called

def test_run(self) -> None:
@parameterized.expand(MANY_BOARD_TYPES)
def test_run(self, _: str, ver_num: str) -> None:
nNeurons = 200 # number of neurons in each population
do_run(nNeurons)


if __name__ == '__main__':
x = SynfireIzhikevich()
x.test_run()
do_run(nNeurons, ver_num)
3 changes: 0 additions & 3 deletions unittests/test_sata_connectors/spynnaker.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
machine_spec_file = None

machine_name = None
version = None
versions = With FPGAs

remote_spinnaker_url = None

spalloc_server = None
Expand Down
Loading
Loading