Skip to content

Commit 4645337

Browse files
committed
✨: add HasArrayIMod protocol to support in-place modulo operator for array classes
1 parent ddd8b65 commit 4645337

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
@@ -240,6 +240,22 @@ def __mod__(self, other: Self | int | float, /) -> Self:
240240
...
241241

242242

243+
class HasArrayIMod(Protocol):
244+
"""Protocol for array classes that support the in-place modulo operator."""
245+
246+
def __imod__(self, other: Self | int | float, /) -> Self:
247+
"""Calculates the in-place remainder for each element of an array instance with the respective element of the array other.
248+
249+
Args:
250+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
251+
252+
Returns:
253+
self, after performing the in-place modulo operation.
254+
255+
""" # noqa: E501
256+
...
257+
258+
243259
class HasArrayPow(Protocol):
244260
"""Protocol for array classes that support the power operator."""
245261

@@ -493,6 +509,7 @@ class Array(
493509
HasArrayFloorDiv,
494510
HasArrayIFloorDiv,
495511
HasArrayMod,
512+
HasArrayIMod,
496513
HasArrayPow,
497514
HasArrayIPow,
498515
HasArrayMatmul,

0 commit comments

Comments
 (0)