Skip to content

Commit d313c34

Browse files
committed
✨: add CanArrayIMod protocol
Support in-place modulo operator for array classes
1 parent 540c855 commit d313c34

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

273273

274+
class CanArrayIMod(Protocol):
275+
"""Protocol for array classes that support the in-place modulo operator."""
276+
277+
def __imod__(self, other: Self | int | float, /) -> Self:
278+
"""Evaluates `self_i % other_i` for each element of an array instance with the respective element of the array `other`.
279+
280+
Args:
281+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
282+
283+
Returns:
284+
self, after performing the in-place modulo operation.
285+
286+
""" # noqa: E501
287+
...
288+
289+
274290
class CanArrayPow(Protocol):
275291
"""Protocol for array classes that support the power operator."""
276292

@@ -317,6 +333,7 @@ class Array(
317333
CanArrayFloorDiv,
318334
CanArrayIFloorDiv,
319335
CanArrayMod,
336+
CanArrayIMod,
320337
CanArrayPow,
321338
CanArrayIPow,
322339
Protocol,

0 commit comments

Comments
 (0)