Skip to content

Commit

Permalink
Duplicate here
Browse files Browse the repository at this point in the history
  • Loading branch information
rowleya committed Nov 27, 2023
1 parent 3cdffda commit 3f8a463
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions pacman/model/graphs/application/application_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,7 @@ def __init__(
self.splitter = splitter
# Keep the name for simplicity but move to new internal representation
self._max_atoms_per_dimension_per_core: Optional[Tuple[int, ...]]

if max_atoms_per_core is None:
self._max_atoms_per_dimension_per_core = None
elif numpy.isscalar(max_atoms_per_core):
max_atoms_int: int = int(cast(int, max_atoms_per_core))
self._max_atoms_per_dimension_per_core = (max_atoms_int, )
else:
max_atoms_tuple: Tuple[int, ...] = cast(
Tuple[int, ...], max_atoms_per_core)
self._max_atoms_per_dimension_per_core = max_atoms_tuple
self._set_max_atoms_per_dimension_per_core(max_atoms_per_core)

def __str__(self):
return self.label
Expand Down Expand Up @@ -253,8 +244,8 @@ def get_max_atoms_per_dimension_per_core(self) -> Tuple[int, ...]:
self.__check_atoms_per_core()
return self._max_atoms_per_dimension_per_core

def set_max_atoms_per_dimension_per_core(
self, new_value: Union[None, int, Tuple[int, ...]]):
def _set_max_atoms_per_dimension_per_core(
self, new_value: Optional[Union[int, Tuple[int, ...]]]):
"""
Set the maximum number of atoms per dimension per core.
Expand All @@ -268,10 +259,32 @@ def set_max_atoms_per_dimension_per_core(
vertex will have atoms_shape as the maximum.
:type new_value: None or int or tuple(int,...)
"""
if isinstance(new_value, int):
self._max_atoms_per_dimension_per_core = (new_value, )
if new_value is None:
self._max_atoms_per_dimension_per_core = None
elif numpy.isscalar(new_value):
max_atoms_int: int = int(cast(int, new_value))
self._max_atoms_per_dimension_per_core = (max_atoms_int, )
else:
self._max_atoms_per_dimension_per_core = new_value
max_atoms_tuple: Tuple[int, ...] = cast(
Tuple[int, ...], new_value)
self._max_atoms_per_dimension_per_core = max_atoms_tuple

def set_max_atoms_per_dimension_per_core(
self, new_value: Optional[Union[int, Tuple[int, ...]]]):
"""
Set the maximum number of atoms per dimension per core.
Can be used to raise or lower the maximum number of atoms per core
or per dimension per core.
:param new_value:
Value to set. If the vertex is n-dimensional where n > 1, a tuple
of n values must be given. If the vertex is 1 dimensional,
a 1-tuple or integer can be given. If this is set to `None` the
vertex will have atoms_shape as the maximum.
:type new_value: None or int or tuple(int,...)
"""
self._set_max_atoms_per_dimension_per_core(new_value)
self.__check_atoms_per_core()

def reset(self) -> None:
Expand Down

0 comments on commit 3f8a463

Please sign in to comment.