Skip to content

Commit

Permalink
remove segment counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Dec 6, 2024
1 parent a5d760f commit 1cc624e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 83 deletions.
14 changes: 1 addition & 13 deletions spynnaker/pyNN/data/spynnaker_data_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class _SpynnakerDataModel(object):
"_min_delay",
"_neurons_per_core_set",
"_populations",
"_projections",
"_segment_counter")
"_projections")

def __new__(cls) -> '_SpynnakerDataModel':
if cls.__singleton is not None:
Expand All @@ -72,7 +71,6 @@ def _clear(self) -> None:
self._neurons_per_core_set: Set[Type[AbstractPyNNModel]] = set()
self._populations: Set[Population] = set()
self._projections: Set[Projection] = set()
self._segment_counter = 0

def _hard_reset(self) -> None:
"""
Expand Down Expand Up @@ -255,16 +253,6 @@ def set_number_of_neurons_per_dimension_per_core(
neuron_type.set_model_max_atoms_per_dimension_per_core(max_permitted)
cls.__spy_data._neurons_per_core_set.add(neuron_type)

@classmethod
def get_segment_counter(cls) -> int:
"""
The number of the current recording segment being generated.
:return: the segment counter
:rtype: int
"""
return cls.__spy_data._segment_counter

@classmethod
def get_sim_name(cls) -> str:
"""
Expand Down
4 changes: 0 additions & 4 deletions spynnaker/pyNN/data/spynnaker_data_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ def _mock(self) -> None:

@overrides(FecDataWriter._hard_reset)
def _hard_reset(self) -> None:
if not self.is_soft_reset():
# Only increase it if this is a hard not following a soft
self.__spy_data._segment_counter += 1
FecDataWriter._hard_reset(self)
self.__spy_data._hard_reset()

@overrides(FecDataWriter._soft_reset)
def _soft_reset(self) -> None:
self.__spy_data._segment_counter += 1
FecDataWriter._soft_reset(self)
self.__spy_data._soft_reset()

Expand Down
66 changes: 0 additions & 66 deletions unittests/data/test_simulator_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,72 +139,6 @@ def test_populations_and_projections(self):
with self.assertRaises(TypeError):
writer.add_projection("bacon")

def test_segment_counter(self):
writer = SpynnakerDataWriter.setup()
self.assertEqual(0, SpynnakerDataView.get_segment_counter())
self.assertEqual(0, SpynnakerDataView.get_reset_number())
# Not changed by running
writer.start_run()
self.assertEqual(0, SpynnakerDataView.get_segment_counter())
self.assertEqual(0, SpynnakerDataView.get_reset_number())
writer.finish_run()
self.assertEqual(0, SpynnakerDataView.get_segment_counter())
self.assertEqual(0, SpynnakerDataView.get_reset_number())

# Not changed by running again
writer.start_run()
writer.finish_run()
self.assertEqual(0, SpynnakerDataView.get_segment_counter())
self.assertEqual(0, SpynnakerDataView.get_reset_number())

# Changed by a soft reset
writer.soft_reset()
self.assertEqual(1, SpynnakerDataView.get_segment_counter())
self.assertEqual(1, SpynnakerDataView.get_reset_number())
writer.start_run()
writer.finish_run()
self.assertEqual(1, SpynnakerDataView.get_segment_counter())
self.assertEqual(1, SpynnakerDataView.get_reset_number())

# Changed by a hard reset
writer.hard_reset()
self.assertEqual(2, SpynnakerDataView.get_segment_counter())
self.assertEqual(2, SpynnakerDataView.get_reset_number())
writer.start_run()
writer.finish_run()

# Changed once by a soft than not by the hard reset before run
writer.soft_reset()
self.assertEqual(3, SpynnakerDataView.get_segment_counter())
self.assertEqual(3, SpynnakerDataView.get_reset_number())
writer.hard_reset()
self.assertEqual(3, SpynnakerDataView.get_segment_counter())
self.assertEqual(3, SpynnakerDataView.get_reset_number())
writer.start_run()
writer.finish_run()
self.assertEqual(3, SpynnakerDataView.get_segment_counter())
self.assertEqual(3, SpynnakerDataView.get_reset_number())

# Changed once by a soft than not by the hard reset in run
writer.soft_reset()
self.assertEqual(4, SpynnakerDataView.get_segment_counter())
self.assertEqual(4, SpynnakerDataView.get_reset_number())
writer.start_run()
writer.hard_reset()
self.assertEqual(4, SpynnakerDataView.get_segment_counter())
self.assertEqual(4, SpynnakerDataView.get_reset_number())
writer.finish_run()
self.assertEqual(4, SpynnakerDataView.get_segment_counter())
self.assertEqual(4, SpynnakerDataView.get_reset_number())

# shutting down does not change the value
writer.stopping()
self.assertEqual(4, SpynnakerDataView.get_segment_counter())
self.assertEqual(4, SpynnakerDataView.get_reset_number())
writer.shut_down()
self.assertEqual(4, SpynnakerDataView.get_segment_counter())
self.assertEqual(4, SpynnakerDataView.get_reset_number())

def test_sim_name(self):
self.assertEqual(SpynnakerDataView.get_sim_name(), sim.name())
self.assertIn("sPyNNaker", SpynnakerDataView.get_sim_name())

0 comments on commit 1cc624e

Please sign in to comment.