Skip to content

Commit 78194dc

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

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

248248

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

@@ -293,6 +312,7 @@ class Array(
293312
CanArrayIMul,
294313
CanArrayTrueDiv,
295314
CanArrayFloorDiv,
315+
CanArrayIFloorDiv,
296316
CanArrayMod,
297317
CanArrayPow,
298318
Protocol,

0 commit comments

Comments
 (0)