Skip to content

Commit b1bfa16

Browse files
committed
✨: add CanArrayIMod protocol
Support in-place modulo operator for array classes
1 parent 111e3b5 commit b1bfa16

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
@@ -284,6 +284,25 @@ def __mod__(self, other: Self | int | float, /) -> Self:
284284
...
285285

286286

287+
class CanArrayIMod(Protocol):
288+
"""Protocol for array classes that support the in-place modulo operator."""
289+
290+
def __imod__(self, other: Self | int | float, /) -> Self:
291+
"""Calculates the in-place remainder for each element of an array instance with the respective element of the array `other`.
292+
293+
Args:
294+
other: divisor array. Must be compatible with `self` (see Broadcasting). Should have a numeric data type.
295+
296+
Returns:
297+
Self: `self`, after performing the in-place modulo operation. The returned array must have a data type determined by Type Promotion Rules.
298+
299+
See Also:
300+
array_api_typing.Remainder
301+
302+
""" # noqa: E501
303+
...
304+
305+
287306
class CanArrayPow(Protocol):
288307
"""Protocol for array classes that support the power operator."""
289308

@@ -333,6 +352,7 @@ class Array(
333352
CanArrayFloorDiv,
334353
CanArrayIFloorDiv,
335354
CanArrayMod,
355+
CanArrayIMod,
336356
CanArrayPow,
337357
CanArrayIPow,
338358
Protocol,

0 commit comments

Comments
 (0)