Skip to content

Commit

Permalink
Appease type checking for arithmetic using Python operators
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Sep 30, 2023
1 parent 3ab6268 commit 700da77
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions src/galois/_domains/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,99 @@ def astype(self, dtype, order="K", casting="unsafe", subok=True, copy=True):
f"{type(self)._name} arrays can only be cast as integer dtypes in {type(self)._dtypes}, not {dtype}."
)
return super().astype(dtype, order=order, casting=casting, subok=subok, copy=copy)

###############################################################################
# Override arithmetic operators so type checking is appeased
###############################################################################

# pylint: disable=useless-super-delegation,no-member

def __add__(self, other) -> Self:
return super().__add__(other)

def __iadd__(self, other) -> Self:
return super().__iadd__(other)

def __radd__(self, other) -> Self:
return super().__radd__(other)

def __sub__(self, other) -> Self:
return super().__sub__(other)

def __isub__(self, other) -> Self:
return super().__isub__(other)

def __rsub__(self, other) -> Self:
return super().__rsub__(other)

def __mul__(self, other) -> Self:
return super().__mul__(other)

def __imul__(self, other) -> Self:
return super().__imul__(other)

def __rmul__(self, other) -> Self:
return super().__rmul__(other)

def __truediv__(self, other) -> Self:
return super().__truediv__(other)

def __itruediv__(self, other) -> Self:
return super().__itruediv__(other)

def __rtruediv__(self, other) -> Self:
return super().__rtruediv__(other)

def __floordiv__(self, other) -> Self:
return super().__floordiv__(other) # pylint: disable=too-many-function-args

def __ifloordiv__(self, other) -> Self:
return super().__ifloordiv__(other)

def __rfloordiv__(self, other) -> Self:
return super().__rfloordiv__(other)

def __neg__(self) -> Self:
return super().__neg__()

def __mod__(self, other) -> Self:
return super().__mod__(other)

def __imod__(self, other) -> Self:
return super().__imod__(other)

Check warning on line 508 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L508

Added line #L508 was not covered by tests

def __rmod__(self, other) -> Self:
return super().__rmod__(other)

Check warning on line 511 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L511

Added line #L511 was not covered by tests

def __pow__(self, other) -> Self:
return super().__pow__(other) # pylint: disable=too-many-function-args

def __ipow__(self, other) -> Self:
return super().__ipow__(other)

Check warning on line 517 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L517

Added line #L517 was not covered by tests

def __rpow__(self, other) -> Self:
return super().__rpow__(other)

Check warning on line 520 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L520

Added line #L520 was not covered by tests

def __matmul__(self, other) -> Self:
return super().__matmul__(other)

def __rmatmul__(self, other) -> Self:
return super().__rmatmul__(other)

Check warning on line 526 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L526

Added line #L526 was not covered by tests

def __lshift__(self, other) -> Self:
return super().__lshift__(other)

Check warning on line 529 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L529

Added line #L529 was not covered by tests

def __ilshift__(self, other) -> Self:
return super().__ilshift__(other)

Check warning on line 532 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L532

Added line #L532 was not covered by tests

def __rlshift__(self, other) -> Self:
return super().__rlshift__(other)

Check warning on line 535 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L535

Added line #L535 was not covered by tests

def __rshift__(self, other) -> Self:
return super().__rshift__(other) # pylint: disable=too-many-function-args

Check warning on line 538 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L538

Added line #L538 was not covered by tests

def __irshift__(self, other) -> Self:
return super().__irshift__(other)

Check warning on line 541 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L541

Added line #L541 was not covered by tests

def __rrshift__(self, other) -> Self:
return super().__rrshift__(other)

Check warning on line 544 in src/galois/_domains/_array.py

View check run for this annotation

Codecov / codecov/patch

src/galois/_domains/_array.py#L544

Added line #L544 was not covered by tests

0 comments on commit 700da77

Please sign in to comment.