Skip to content

Commit b47800d

Browse files
committed
✨: add HasArrayRMod protocol
Support right modulo operator for array classes Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
1 parent 65c9191 commit b47800d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/array_api_typing/_array.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,22 @@ def __imod__(self, other: Self | int | float, /) -> Self:
369369
...
370370

371371

372+
class CanArrayRMod(Protocol):
373+
"""Protocol for array classes that support the right modulo operator."""
374+
375+
def __rmod__(self, other: Self | int | float, /) -> Self:
376+
"""Calculates the remainder for each element of an array instance with the respective element of the array other.
377+
378+
Args:
379+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
380+
381+
Returns:
382+
an array containing the element-wise remainders. The returned array must have a data type determined by Type Promotion Rules.
383+
384+
""" # noqa: E501
385+
...
386+
387+
372388
class CanArrayPow(Protocol):
373389
"""Protocol for array classes that support the power operator."""
374390

@@ -437,6 +453,7 @@ class Array(
437453
CanArrayRFloorDiv,
438454
CanArrayMod,
439455
CanArrayIMod,
456+
CanArrayRMod,
440457
CanArrayPow,
441458
CanArrayIPow,
442459
CanArrayRPow,

0 commit comments

Comments
 (0)