Skip to content

Commit a7ac25e

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

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
@@ -236,6 +236,22 @@ def __floordiv__(self, other: Self | int | float, /) -> Self:
236236
...
237237

238238

239+
class CanArrayIFloorDiv(Protocol):
240+
"""Protocol for array classes that support the in-place floor division operator."""
241+
242+
def __ifloordiv__(self, other: Self | int | float, /) -> Self:
243+
"""Calculates the in-place quotient for each element of an array instance with the respective element of the array other.
244+
245+
Args:
246+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
247+
248+
Returns:
249+
self, after performing the in-place floor division.
250+
251+
""" # noqa: E501
252+
...
253+
254+
239255
class CanArrayMod(Protocol):
240256
"""Protocol for array classes that support the modulo operator."""
241257

@@ -283,6 +299,7 @@ class Array(
283299
CanArrayIMul,
284300
CanArrayTrueDiv,
285301
CanArrayFloorDiv,
302+
CanArrayIFloorDiv,
286303
CanArrayMod,
287304
CanArrayPow,
288305
Protocol,

0 commit comments

Comments
 (0)