Skip to content

Commit c26f488

Browse files
committed
✨: add CanArrayIFloorDiv protocol
Support in-place floor division operator for array classes
1 parent dce36c4 commit c26f488

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
@@ -248,6 +248,25 @@ def __floordiv__(self, other: Self | int | float, /) -> Self:
248248
...
249249

250250

251+
class CanArrayIFloorDiv(Protocol):
252+
"""Protocol for array classes that support the in-place floor division operator."""
253+
254+
def __ifloordiv__(self, other: Self | int | float, /) -> Self:
255+
"""Calculates the in-place floor division for each element of an array instance with the respective element of the array `other`.
256+
257+
Args:
258+
other: divisor array. Must be compatible with `self` (see Broadcasting). Should have a numeric data type.
259+
260+
Returns:
261+
Self: `self`, after performing the in-place floor division. The returned array must have a data type determined by Type Promotion Rules.
262+
263+
See Also:
264+
array_api_typing.FloorDiv
265+
266+
""" # noqa: E501
267+
...
268+
269+
251270
class CanArrayMod(Protocol):
252271
"""Protocol for array classes that support the modulo operator."""
253272

@@ -295,6 +314,7 @@ class Array(
295314
CanArrayIMul,
296315
CanArrayTrueDiv,
297316
CanArrayFloorDiv,
317+
CanArrayIFloorDiv,
298318
CanArrayMod,
299319
CanArrayPow,
300320
Protocol,

0 commit comments

Comments
 (0)