Skip to content

Commit

Permalink
typing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Nov 27, 2023
1 parent fac3d79 commit c8d5fce
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
7 changes: 6 additions & 1 deletion pacman/model/graphs/machine/simple_machine_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations
from typing import TYPE_CHECKING
from .machine_vertex import MachineVertex
from spinn_utilities.overrides import overrides

if TYPE_CHECKING:
from pacman.model.resources import AbstractSDRAM


class SimpleMachineVertex(MachineVertex):
"""
Expand All @@ -41,7 +46,7 @@ def __init__(self, sdram, label=None,

@property
@overrides(MachineVertex.sdram_required)
def sdram_required(self):
def sdram_required(self) -> AbstractSDRAM:
return self._sdram

@property
Expand Down
7 changes: 4 additions & 3 deletions pacman/model/resources/constant_sdram.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional
from typing import Optional, TextIO
from spinn_utilities.overrides import overrides
from .abstract_sdram import AbstractSDRAM

Expand Down Expand Up @@ -66,7 +66,7 @@ def __sub__(self, other):
return other.sub_from(self)

@overrides(AbstractSDRAM.sub_from)
def sub_from(self, other):
def sub_from(self, other: AbstractSDRAM) -> AbstractSDRAM:
if isinstance(other, ConstantSDRAM):
return ConstantSDRAM(
other.fixed - self._sdram)
Expand All @@ -75,5 +75,6 @@ def sub_from(self, other):
return other - self

@overrides(AbstractSDRAM.report)
def report(self, timesteps, indent="", preamble="", target=None):
def report(self, timesteps: Optional[int], indent: str = "",
preamble: str = "", target: Optional[TextIO] = None):
print(indent, preamble, f"Constant {self._sdram} bytes", file=target)
5 changes: 3 additions & 2 deletions pacman/model/resources/multi_region_sdram.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from enum import Enum
import math
import numpy
from typing import Dict, Union
from typing import Dict, Optional, TextIO, Union
from typing_extensions import TypeAlias
from spinn_utilities.overrides import overrides
from .abstract_sdram import AbstractSDRAM
Expand Down Expand Up @@ -132,7 +132,8 @@ def merge(self, other: MultiRegionSDRAM):
self.__regions[region] = other.regions[region]

@overrides(AbstractSDRAM.report)
def report(self, timesteps, indent="", preamble="", target=None):
def report(self, timesteps: Optional[int], indent: str = "",
preamble: str = "", target: Optional[TextIO] = None):
super().report(timesteps, indent, preamble, target)
for region in self.__regions:
self.__regions[region].report(
Expand Down
5 changes: 3 additions & 2 deletions pacman/model/resources/variable_sdram.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import math
import numpy
from typing import Optional, Union
from typing import Optional, TextIO, Union
from spinn_utilities.overrides import overrides
from pacman.exceptions import PacmanConfigurationException
from .abstract_sdram import AbstractSDRAM
Expand Down Expand Up @@ -87,7 +87,8 @@ def sub_from(self, other: AbstractSDRAM) -> 'VariableSDRAM':
other.per_timestep - self._per_timestep_sdram)

@overrides(AbstractSDRAM.report)
def report(self, timesteps, indent="", preamble="", target=None):
def report(self, timesteps: Optional[int], indent: str = "",
preamble: str = "", target: Optional[TextIO] = None):
print(indent, preamble,
f"Fixed {self._fixed_sdram} bytes "
f"Per_timestep {self._per_timestep_sdram} bytes "
Expand Down

0 comments on commit c8d5fce

Please sign in to comment.