Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a1be18e

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

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
@@ -400,6 +400,25 @@ def __imod__(self, other: Self | int | float, /) -> Self:
400400
...
401401

402402

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

@@ -474,6 +493,7 @@ class Array(
474493
CanArrayRFloorDiv,
475494
CanArrayMod,
476495
CanArrayIMod,
496+
CanArrayRMod,
477497
CanArrayPow,
478498
CanArrayIPow,
479499
CanArrayRPow,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /