Skip to content

Commit

Permalink
Fix types of moved code
Browse files Browse the repository at this point in the history
  • Loading branch information
dkfellows committed Aug 7, 2023
1 parent 2466ba1 commit b1976fa
Show file tree
Hide file tree
Showing 9 changed files with 270 additions and 233 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

[[tool.mypy]]
exclude = ["doc", "setup.py"]
16 changes: 8 additions & 8 deletions spinnman/extended/bmp_set_led.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Iterable, Union
from spinn_utilities.overrides import overrides
from spinnman.messages.scp import SCPRequestHeader
from spinnman.messages.scp.abstract_messages import (
AbstractSCPRequest, BMPRequest)
from spinnman.messages.scp.enums import SCPCommand
from spinnman.messages.scp.impl.check_ok_response import CheckOKResponse
from spinnman.messages.scp.enums.led_action import LEDAction


class BMPSetLed(BMPRequest):
Expand All @@ -27,9 +29,10 @@ class BMPSetLed(BMPRequest):
This class is currently deprecated and untested as there is no
known use except for Transceiver.set_led which is itself deprecated.
"""
__slots__ = []
__slots__ = ()

def __init__(self, led, action, boards):
def __init__(self, led: Union[int, Iterable[int]], action: LEDAction,
boards: Union[int, Iterable[int]]):
"""
:param led: Number of the LED or an iterable of LEDs to set the
state of (0-7)
Expand All @@ -42,12 +45,9 @@ def __init__(self, led, action, boards):
"""
# set up the led entry for arg1
if isinstance(led, int):
leds = [led]
arg1 = action.value << (led * 2)
else:
leds = led

# LED setting actions
arg1 = sum(action.value << (led * 2) for led in leds)
arg1 = sum(action.value << (a_led * 2) for a_led in led)

# Bitmask of boards to control
arg2 = self.get_board_mask(boards)
Expand All @@ -59,5 +59,5 @@ def __init__(self, led, action, boards):
argument_1=arg1, argument_2=arg2)

@overrides(AbstractSCPRequest.get_scp_response)
def get_scp_response(self):
def get_scp_response(self) -> CheckOKResponse:
return CheckOKResponse("Set the LEDs of a board", "CMD_LED")
43 changes: 23 additions & 20 deletions spinnman/extended/de_alloc_sdram_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional
from spinnman.messages.scp.impl import SDRAMDeAlloc
from spinnman.processes.abstract_multi_connection_process import (
AbstractMultiConnectionProcess)
from spinnman.processes import AbstractMultiConnectionProcess
from spinnman.processes import ConnectionSelector


class DeAllocSDRAMProcess(AbstractMultiConnectionProcess):
Expand All @@ -25,40 +25,43 @@ class DeAllocSDRAMProcess(AbstractMultiConnectionProcess):
known use except for Transceiver.free_sdram and free_sdram_by_app_id
which are both themselves deprecated.
"""
__slots__ = [
"_no_blocks_freed"]
__slots__ = ("_no_blocks_freed", )

def __init__(self, connection_selector):
def __init__(self, connection_selector: ConnectionSelector):
"""
:param connection_selector:
:type connection_selector:
AbstractMultiConnectionProcessConnectionSelector
:param ConnectionSelector connection_selector:
"""
super().__init__(connection_selector)
self._no_blocks_freed = None
self._no_blocks_freed: Optional[int] = None

def de_alloc_sdram(self, x, y, app_id, base_address=None):
def de_alloc_all_app_sdram(self, x: int, y: int, app_id: int):
"""
:param int x:
:param int y:
:param int app_id:
:param base_address:
:type base_address: int or None
"""
callback = None
# deallocate space in the SDRAM
if base_address is None:
callback = self._handle_sdram_alloc_response
self._send_request(SDRAMDeAlloc(x, y, app_id, base_address),
callback=callback)
self._finish()
self.check_for_error()
with self._collect_responses():
self._send_request(SDRAMDeAlloc(x, y, app_id=app_id),
callback=self.__handle_sdram_alloc_response)

def de_alloc_sdram(self, x: int, y: int, base_address: int):
"""
:param int x:
:param int y:
:param int base_address:
"""
with self._collect_responses():
self._send_request(SDRAMDeAlloc(x, y, base_address=base_address),
callback=None)

def _handle_sdram_alloc_response(self, response):
def __handle_sdram_alloc_response(self, response):
self._no_blocks_freed = response.number_of_blocks_freed

@property
def no_blocks_freed(self):
def no_blocks_freed(self) -> Optional[int]:
"""
:rtype: int
"""
Expand Down
Loading

0 comments on commit b1976fa

Please sign in to comment.