Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only expose processor virtual ids #244

Merged
merged 1 commit into from
Mar 15, 2024
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
38 changes: 0 additions & 38 deletions spinn_machine/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,6 @@ def y(self) -> int:
"""
return self._y

@property
def processors(self) -> Iterator[Processor]:
"""
An iterable of available all processors.

Deprecated: There are many more efficient methods instead.
- all_processor_ids
- n_processors
- n_user_processors
- user_processors
- user_processors_ids
- n_monitor_processors
- monitor_processors
- monitor_processors_ids

:rtype: iterable(Processor)
"""
yield from self._monitor_processors.values()
yield from self._user_processors.values()

@property
def all_processor_ids(self) -> Iterator[int]:
"""
Expand All @@ -226,15 +206,6 @@ def n_processors(self) -> int:
"""
return len(self._monitor_processors) + len(self._user_processors)

@property
def user_processors(self) -> Iterator[Processor]:
"""
An iterable of available user processors.

:rtype: iterable(Processor)
"""
yield from self._user_processors.values()

@property
def user_processors_ids(self) -> Iterator[int]:
"""
Expand All @@ -253,15 +224,6 @@ def n_user_processors(self) -> int:
"""
return len(self._user_processors)

@property
def monitor_processors(self) -> Iterator[Processor]:
"""
An iterable of available monitor processors.

:rtype: iterable(Processor)
"""
return self._monitor_processors.values()

@property
def monitor_processors_ids(self) -> Iterator[int]:
"""
Expand Down
12 changes: 4 additions & 8 deletions unittests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,13 @@ def test_1_chip(self):
def test_processors(self):
new_chip = self._create_chip(self._x, self._y, self.n_processors,
self._router, self._sdram, self._ip)
all_p = set()
for id in new_chip.all_processor_ids:
all_p.add(new_chip[id])
all_p = set(new_chip.all_processor_ids)
self.assertEqual(len(all_p), new_chip.n_processors)
users = set(new_chip.user_processors)
users = set(new_chip.user_processors_ids)
self.assertEqual(len(users), new_chip.n_user_processors)
self.assertEqual(len(users), len(set(new_chip.user_processors_ids)))
monitors = set(new_chip.monitor_processors)
monitors = set(new_chip.monitor_processors_ids)
self.assertEqual(users.union(monitors), all_p)
self.assertEqual(len(monitors),
len(set(new_chip.monitor_processors_ids)))
self.assertEqual(len(monitors), new_chip.n_monitor_processors)


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def test_new_vm_with_max_cores(self):
self.assertEqual(n_cpus, _chip.n_processors)
self.assertEqual(n_cpus - 1, _chip.n_user_processors)
self.assertEqual(1, _chip.n_monitor_processors)
self.assertEqual(n_cpus - 1, len(list(_chip.user_processors)))
self.assertEqual(1, len(list(_chip.monitor_processors)))
self.assertEqual(n_cpus - 1, len(list(_chip.user_processors_ids)))
self.assertEqual(1, len(list(_chip.monitor_processors_ids)))
count = sum(_chip.n_processors for _chip in vm.chips)
self.assertEqual(count, 4 * n_cpus)

Expand Down
Loading