Skip to content

Commit 6e2be2c

Browse files
committed
✨: add CanArrayIMod protocol
Support in-place modulo operator for array classes
1 parent 19cd5f9 commit 6e2be2c

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

288288

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

@@ -335,6 +354,7 @@ class Array(
335354
CanArrayFloorDiv,
336355
CanArrayIFloorDiv,
337356
CanArrayMod,
357+
CanArrayIMod,
338358
CanArrayPow,
339359
CanArrayIPow,
340360
Protocol,

0 commit comments

Comments
 (0)