Skip to content

Commit 7f9cf89

Browse files
committed
✨: add HasArrayRFloorDiv protocol
Support right floor division operator for array classes
1 parent de335e0 commit 7f9cf89

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
@@ -290,6 +290,22 @@ def __ifloordiv__(self, other: Self | int | float, /) -> Self:
290290
...
291291

292292

293+
class CanArrayRFloorDiv(Protocol):
294+
"""Protocol for array classes that support the right floor division operator."""
295+
296+
def __rfloordiv__(self, other: Self | int | float, /) -> Self:
297+
"""Calculates the quotient for each element of an array instance with the respective element of the array other.
298+
299+
Args:
300+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
301+
302+
Returns:
303+
an array containing the element-wise quotients. The returned array must have a data type determined by Type Promotion Rules.
304+
305+
""" # noqa: E501
306+
...
307+
308+
293309
class CanArrayMod(Protocol):
294310
"""Protocol for array classes that support the modulo operator."""
295311

@@ -371,6 +387,7 @@ class Array(
371387
CanArrayRTrueDiv,
372388
CanArrayFloorDiv,
373389
CanArrayIFloorDiv,
390+
CanArrayRFloorDiv,
374391
CanArrayMod,
375392
CanArrayIMod,
376393
CanArrayPow,

0 commit comments

Comments
 (0)