Skip to content

Commit 3800ffc

Browse files
committed
Remove some support for older Python versions, which simplifies some code.
1 parent 3f683a6 commit 3800ffc

2 files changed

Lines changed: 5 additions & 16 deletions

File tree

pyrtl/rtllib/matrix.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,6 @@ def __imatmul__(self, other):
584584
585585
Is used with ``a @= b``.
586586
587-
Note: The matmul symbol (``@``) only works in Python 3.5+. Otherwise you must
588-
call ``__imatmul__(other)``.
589587
'''
590588
new_value = self.__matmul__(other)
591589
self.columns = new_value.columns
@@ -602,8 +600,6 @@ def __matmul__(self, other):
602600
603601
Is used with ``a @ b``.
604602
605-
Note: The matmul symbol (`@`) only works in Python 3.5+. Otherwise you must
606-
call ``__matmul__(other)``.
607603
'''
608604
if not isinstance(other, Matrix):
609605
raise PyrtlError('error: expecting a Matrix, '
@@ -736,16 +732,15 @@ def get_value(ix):
736732
col = mat_ix % self.columns
737733
self[row, col] = get_value(v_ix)
738734

739-
def reshape(self, *newshape, **order):
740-
''' Create a matrix of the given shape from the current matrix.
735+
def reshape(self, *newshape, order: str = "C"):
736+
'''Create a matrix of the given shape from the current matrix.
741737
742738
:param int/ints/tuple[int] newshape: shape of the matrix to return;
743739
if a single int, will result in a 1-D row-vector of that length;
744740
if a tuple, will use values for number of rows and cols. Can also
745741
be a varargs.
746-
:param str order: ``C`` means to read from self using
747-
row-major order (C-style), and ``F`` means to read from self
748-
using column-major order (Fortran-style).
742+
:param order: ``C`` means to read from self using row-major order (C-style), and
743+
``F`` means to read from self using column-major order (Fortran-style).
749744
:return: A copy of the matrix with same data, with a new number of rows/cols
750745
751746
One shape dimension in newshape can be -1; in this case, the value
@@ -766,10 +761,8 @@ def reshape(self, *newshape, **order):
766761
matrix.reshape(4, 2) == [[0, 1], [2, 3], [4, 5], [6, 7]]
767762
matrix.reshape(-1, 2) == [[0, 1], [2, 3], [4, 5], [6, 7]]
768763
matrix.reshape(4, -1) == [[0, 1], [2, 3], [4, 5], [6, 7]]
764+
769765
'''
770-
# python2 does not support named arguments after *args, so we use
771-
# **kwargs for 'order' and set the default here.
772-
order = order.get('order', 'C')
773766
count = self.rows * self.columns
774767
if isinstance(newshape, int):
775768
if newshape == -1:

pyrtl/wire.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,6 @@ def __bool__(self):
394394
'something that calls "__eq__", such as when you test if a '
395395
'WireVector is "in" something')
396396

397-
__nonzero__ = __bool__ # for Python 2 and 3 compatibility
398-
399397
def __and__(self, other: WireVectorLike) -> WireVector:
400398
"""Returns the result of bitwise ANDing ``self`` and ``other``.
401399
@@ -1305,8 +1303,6 @@ def __bool__(self):
13051303
'something that calls "__eq__", such as when you test if a '
13061304
'Register.next is "in" something')
13071305

1308-
__nonzero__ = __bool__ # for Python 2 and 3 compatibility
1309-
13101306
def __init__(self, bitwidth: int, name: str = '', reset_value: int = None,
13111307
block: Block = None):
13121308
"""Construct a register.

0 commit comments

Comments
 (0)