Skip to content

Commit

Permalink
Remove Python 2.7 support
Browse files Browse the repository at this point in the history
PyPI and pip are forcing the issue; we can't keep going much longer.
SpiNNakerManchester/SpiNNUtils#132
  • Loading branch information
dkfellows committed Jan 25, 2021
1 parent 7f2e6b5 commit dff299b
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 266 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8]

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -45,11 +45,8 @@ jobs:
with:
repositories: SpiNNUtils
install: true
preinstall: ${{ matrix.python-version == 2.7 }}
- name: Setup
uses: ./support/actions/run-setup
with:
preinstall: ${{ matrix.python-version == 2.7 }}

- name: Test with pytest
uses: ./support/actions/pytest
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

six
SpiNNUtilities >= 1!5.1.1, < 1!6.0.0
SpiNNUtilities >= 1!5.1.1, < 1!6.0.0
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"Operating System :: MacOS",

"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
Expand Down
91 changes: 35 additions & 56 deletions spinn_machine/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from collections import OrderedDict
from six import iteritems, itervalues
from spinn_utilities.ordered_set import OrderedSet
from .processor import Processor

Expand All @@ -25,10 +24,10 @@ class Chip(object):
""" Represents a SpiNNaker chip with a number of cores, an amount of\
SDRAM shared between the cores, and a router.\
The chip is iterable over the processors, yielding\
(processor_id, processor) where:
``(processor_id, processor)`` where:
* processor_id is the ID of a processor
* processor is the processor with processor_id
* ``processor_id`` is the ID of a processor
* ``processor`` is the :py:class:`Processor` with ``processor_id``
"""

# tag 0 is reserved for stuff like IO STD
Expand All @@ -45,24 +44,18 @@ def __init__(self, x, y, n_processors, router, sdram, nearest_ethernet_x,
nearest_ethernet_y, ip_address=None, virtual=False,
tag_ids=None, down_cores=None, parent_link=None):
"""
:param x: the x-coordinate of the chip's position in the\
:param int x: the x-coordinate of the chip's position in the
two-dimensional grid of chips
:type x: int
:param y: the y-coordinate of the chip's position in the\
:param int y: the y-coordinate of the chip's position in the
two-dimensional grid of chips
:type y: int
:param n_processors: the number of processors including monitor\
processors.
:type n_processors: int
:param router: a router for the chip
:type router: :py:class:`~spinn_machine.Router`
:param sdram: an SDRAM for the chip
:type sdram: :py:class:`~spinn_machine.SDRAM`
:param ip_address: \
the IP address of the chip or None if no Ethernet attached
:type ip_address: str
:param virtual: boolean which defines if this chip is a virtual one
:type virtual: bool
:param int n_processors:
the number of processors including monitor processors.
:param ~spinn_machine.Router router: a router for the chip
:param ~spinn_machine.SDRAM sdram: an SDRAM for the chip
:param ip_address:
the IP address of the chip, or ``None`` if no Ethernet attached
:type ip_address: str or None
:param bool virtual: whether this chip is a virtual one
:param tag_ids: IDs to identify the chip for SDP can be empty to
define no tags or None to allocate tag automatically
based on if there is an ip_address
Expand All @@ -76,9 +69,9 @@ def __init__(self, x, y, n_processors, router, sdram, nearest_ethernet_x,
:param parent_link: The link down which the parent chips is found in
the tree of chips towards the root (boot) chip
:type parent_link: int or None
:raise spinn_machine.exceptions.SpinnMachineAlreadyExistsException: \
If processors contains any two processors with the same\
processor_id
:raise ~spinn_machine.exceptions.SpinnMachineAlreadyExistsException:
If processors contains any two processors with the same
``processor_id``
"""
self._x = x
self._y = y
Expand Down Expand Up @@ -122,26 +115,23 @@ def __generate_processors(self, n_processors, down_cores):

def is_processor_with_id(self, processor_id):
""" Determines if a processor with the given ID exists in the chip.\
Also implemented as __contains__(processor_id)
Also implemented as ``__contains__(processor_id)``
:param processor_id: the processor ID to check for
:type processor_id: int
:param int processor_id: the processor ID to check for
:return: Whether the processor with the given ID exists
:rtype: bool
:raise None: does not raise any known exceptions
"""
return processor_id in self._p

def get_processor_with_id(self, processor_id):
""" Return the processor with the specified ID or None if the\
""" Return the processor with the specified ID, or ``None`` if the\
processor does not exist.
:param processor_id: the ID of the processor to return
:type processor_id: int
:return: \
the processor with the specified ID, or None if no such processor
:rtype: Processor
:raise None: does not raise any known exceptions
:param int processor_id: the ID of the processor to return
:return:
the processor with the specified ID,
or ``None`` if no such processor
:rtype: Processor or None
"""
if processor_id in self._p:
return self._p[processor_id]
Expand All @@ -153,7 +143,6 @@ def x(self):
:return: the x-coordinate of the chip
:rtype: int
:raise None: does not raise any known exceptions
"""
return self._x

Expand All @@ -163,7 +152,6 @@ def y(self):
:return: the y-coordinate of the chip
:rtype: int
:raise None: does not raise any known exceptions
"""
return self._y

Expand All @@ -172,9 +160,8 @@ def processors(self):
""" An iterable of available processors
:rtype: iterable(Processor)
:raise None: does not raise any known exceptions
"""
return itervalues(self._p)
return iter(self._p.values())

@property
def n_processors(self):
Expand All @@ -194,11 +181,10 @@ def n_user_processors(self):

@property
def virtual(self):
""" Boolean which defines if the chip is virtual or not
""" Whether the chip is virtual or not
:return: if the chip is virtual
:rtype: boolean
:raise None: this method does not raise any known exceptions
:rtype: bool
"""
return self._virtual

Expand All @@ -208,7 +194,6 @@ def router(self):
:return: router associated with the chip
:rtype: Router
:raise None: does not raise any known exceptions
"""
return self._router

Expand All @@ -218,18 +203,16 @@ def sdram(self):
:return: SDRAM associated with the chip
:rtype: SDRAM
:raise None: does not raise any known exceptions
"""
return self._sdram

@property
def ip_address(self):
""" The IP address of the chip
:return: IP address of the chip, or None if there is no Ethernet\
:return: IP address of the chip, or ``None`` if there is no Ethernet
connected to the chip
:rtype: str
:raise None: does not raise any known exceptions
:rtype: str or None
"""
return self._ip_address

Expand All @@ -239,7 +222,6 @@ def nearest_ethernet_x(self):
:return: the x coordinate of the nearest Ethernet chip
:rtype: int
:raise None: does not raise any known exceptions
"""
return self._nearest_ethernet_x

Expand All @@ -249,7 +231,6 @@ def nearest_ethernet_y(self):
:return: the y coordinate of the nearest Ethernet chip
:rtype: int
:raise None: does not raise any known exceptions
"""
return self._nearest_ethernet_y

Expand All @@ -259,7 +240,6 @@ def tag_ids(self):
:return: the set of IDs.
:rtype: iterable(int)
:raise None: this method does not raise any exception
"""
return self._tag_ids

Expand All @@ -278,7 +258,7 @@ def get_first_none_monitor_processor(self):
def parent_link(self):
""" The link down which the parent is found in the tree of chips rooted
at the machine root chip (probably 0, 0 in most cases). This will
be None if the chip information didn't contain this value.
be ``None`` if the chip information didn't contain this value.
:rtype: int or None
"""
Expand All @@ -287,13 +267,12 @@ def parent_link(self):
def __iter__(self):
""" Get an iterable of processor identifiers and processors
:return: An iterable of (processor_id, processor) where:
* processor_id is the ID of a processor
* processor is the processor with the ID
:rtype: iterable(int,Processor)
:raise None: does not raise any known exceptions
:return: An iterable of ``(processor_id, processor)`` where:
* ``processor_id`` is the ID of a processor
* ``processor`` is the processor with the ID
:rtype: iterable(tuple(int,Processor))
"""
return iteritems(self._p)
return iter(self._p.items())

def __len__(self):
""" The number of processors associated with this chip.
Expand Down
7 changes: 3 additions & 4 deletions spinn_machine/core_subsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from collections import OrderedDict
from six import itervalues
from .core_subset import CoreSubset


Expand Down Expand Up @@ -111,7 +110,7 @@ def core_subsets(self):
:return: Iterable of core subsets
:rtype: iterable(CoreSubset)
"""
return itervalues(self._core_subsets)
return iter(self._core_subsets.values())

def get_core_subset_for_chip(self, x, y):
""" Get the core subset for a chip.
Expand All @@ -131,12 +130,12 @@ def get_core_subset_for_chip(self, x, y):
def __iter__(self):
""" Iterable of core_subsets
"""
return itervalues(self._core_subsets)
return iter(self._core_subsets.values())

def __len__(self):
""" The total number of processors that are in these core subsets
"""
return sum(len(subset) for subset in itervalues(self._core_subsets))
return sum(len(subset) for subset in self._core_subsets.values())

def __contains__(self, x_y_tuple):
""" True if the given coordinates are in the set
Expand Down
13 changes: 7 additions & 6 deletions spinn_machine/full_wrap_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ class FullWrapMachine(Machine):
def __init__(self, width, height, chips=None, origin=None):
""" Creates a fully wrapped machine.
:param width: The width of the machine excluding any virtual chips
:param height: The height of the machine excluding any virtual chips
:param int width: The width of the machine excluding any virtual chips
:param int height:
The height of the machine excluding any virtual chips
:param chips: An iterable of chips in the machine
:type chips: iterable of :py:class:`~spinn_machine.Chip`
:param origin: Extra information about how this mnachine was created \
to be used in the str method. Example "Virtual" or "Json"
:raise spinn_machine.exceptions.SpinnMachineAlreadyExistsException: \
:type chips: iterable(~spinn_machine.Chip)
:param str origin: Extra information about how this machine was
created to be used in the str method. Example "Virtual" or "Json"
:raise ~spinn_machine.exceptions.SpinnMachineAlreadyExistsException:
If any two chips have the same x and y coordinates
"""
super(FullWrapMachine, self).__init__(width, height, chips, origin)
Expand Down
13 changes: 7 additions & 6 deletions spinn_machine/horizontal_wrap_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ class HorizontalWrapMachine(Machine):
def __init__(self, width, height, chips=None, origin=None):
""" Creates a horizontally wrapped machine.
:param width: The width of the machine excluding any virtual chips
:param height: The height of the machine excluding any virtual chips
:param int width: The width of the machine excluding any virtual chips
:param int height:
The height of the machine excluding any virtual chips
:param chips: An iterable of chips in the machine
:type chips: iterable of :py:class:`~spinn_machine.Chip`
:param origin: Extra information about how this mnachine was created \
to be used in the str method. Example "Virtual" or "Json"
:raise spinn_machine.exceptions.SpinnMachineAlreadyExistsException: \
:type chips: iterable(~spinn_machine.Chip)
:param str origin: Extra information about how this mnachine was
created to be used in the str method. Example "Virtual" or "Json"
:raise ~spinn_machine.exceptions.SpinnMachineAlreadyExistsException:
If any two chips have the same x and y coordinates
"""
super(HorizontalWrapMachine, self).__init__(
Expand Down
Loading

0 comments on commit dff299b

Please sign in to comment.