Skip to content

Commit

Permalink
Merge pull request #476 from SpiNNakerManchester/mvertex_label
Browse files Browse the repository at this point in the history
Mvertex label
  • Loading branch information
Christian-B committed Oct 17, 2022
2 parents f77678a + cdcda8f commit d46d6db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pacman/model/graphs/common/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,11 @@ def get_raster_ids(self, atoms_shape):
ids = numpy.arange(numpy.prod(atoms_shape)).reshape(
tuple(reversed(atoms_shape)))
return ids[slices].flatten()

def __str__(self):
if len(self.shape) <= 1:
return (f"({self.lo_atom}:{self.hi_atom})")
value = ""
for slice in self.slices:
value += f"({slice.start}:{slice.stop})"
return f"[{value}]"
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create_machine_vertices(self, chip_counter):
for vertex_slice in self.__fixed_slices:
sdram = app_vertex.get_sdram_used_by_atoms(vertex_slice)
chip_counter.add_core(sdram)
label = f"MachineVertex for {vertex_slice} of {app_vertex.label}"
label = f"{app_vertex.label}{vertex_slice}"
machine_vertex = app_vertex.create_machine_vertex(
vertex_slice, sdram, label)
app_vertex.remember_machine_vertex(machine_vertex)
Expand Down
5 changes: 5 additions & 0 deletions unittests/model_tests/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_basic(self):
assert s.lo_atom == 0 # As specified
assert s.hi_atom == 10 # As specified
assert s.as_slice == slice(0, 11) # Slice object supported by arrays
self.assertEqual("(0:10)", str(s))

def test_check_lo_atom_sanity(self):
# Check for value sanity
Expand Down Expand Up @@ -77,3 +78,7 @@ def test_immutability_as_slice(self):
s = Slice(0, 10)
with self.assertRaises(AttributeError):
s.as_slice = slice(2, 10)

def test_2d(self):
s = Slice(0, 10, (3, 3), (0, 6))
self.assertEqual("[(0:3)(6:9)]", str(s))

0 comments on commit d46d6db

Please sign in to comment.