Skip to content

Commit 3cf49ad

Browse files
committed
✨: add HasArrayRMod protocol
Support right modulo operator for array classes Signed-off-by: Nathaniel Starkman <[email protected]>
1 parent b6ea877 commit 3cf49ad

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
@@ -338,6 +338,22 @@ def __imod__(self, other: Self | int | float, /) -> Self:
338338
...
339339

340340

341+
class CanArrayRMod(Protocol):
342+
"""Protocol for array classes that support the right modulo operator."""
343+
344+
def __rmod__(self, other: Self | int | float, /) -> Self:
345+
"""Calculates the remainder for each element of an array instance with the respective element of the array other.
346+
347+
Args:
348+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
349+
350+
Returns:
351+
an array containing the element-wise remainders. The returned array must have a data type determined by Type Promotion Rules.
352+
353+
""" # noqa: E501
354+
...
355+
356+
341357
class CanArrayPow(Protocol):
342358
"""Protocol for array classes that support the power operator."""
343359

@@ -406,6 +422,7 @@ class Array(
406422
CanArrayRFloorDiv,
407423
CanArrayMod,
408424
CanArrayIMod,
425+
CanArrayRMod,
409426
CanArrayPow,
410427
CanArrayIPow,
411428
CanArrayRPow,

0 commit comments

Comments
 (0)