Skip to content

Commit 2ba52db

Browse files
committed
✨: add CanArrayRMod protocol
Support right modulo operator for array classes Signed-off-by: Nathaniel Starkman <[email protected]>
1 parent 6bb01a8 commit 2ba52db

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/array_api_typing/_array.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,25 @@ def __imod__(self, other: Self | int | float, /) -> Self:
402402
...
403403

404404

405+
class CanArrayRMod(Protocol):
406+
"""Protocol for array classes that support the right modulo operator."""
407+
408+
def __rmod__(self, other: Self | int | float, /) -> Self:
409+
"""Calculates the remainder for each element of the array `other` with the respective element of an array instance.
410+
411+
Args:
412+
other: dividend array. Must be compatible with `self` (see Broadcasting). Should have a numeric data type.
413+
414+
Returns:
415+
Self: an array containing the element-wise remainders. The returned array must have a data type determined by Type Promotion Rules.
416+
417+
See Also:
418+
array_api_typing.Remainder
419+
420+
""" # noqa: E501
421+
...
422+
423+
405424
class CanArrayPow(Protocol):
406425
"""Protocol for array classes that support the power operator."""
407426

@@ -476,6 +495,7 @@ class Array(
476495
CanArrayRFloorDiv,
477496
CanArrayMod,
478497
CanArrayIMod,
498+
CanArrayRMod,
479499
CanArrayPow,
480500
CanArrayIPow,
481501
CanArrayRPow,

0 commit comments

Comments
 (0)