Skip to content

Commit 08eb4e1

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

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

320320

321+
class CanArrayRFloorDiv(Protocol):
322+
"""Protocol for array classes that support the right floor division operator."""
323+
324+
def __rfloordiv__(self, other: Self | int | float, /) -> Self:
325+
"""Calculates the quotient for each element of an array instance with the respective element of the array other.
326+
327+
Args:
328+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
329+
330+
Returns:
331+
an array containing the element-wise quotients. The returned array must have a data type determined by Type Promotion Rules.
332+
333+
""" # noqa: E501
334+
...
335+
336+
321337
class CanArrayMod(Protocol):
322338
"""Protocol for array classes that support the modulo operator."""
323339

@@ -402,6 +418,7 @@ class Array(
402418
CanArrayRTrueDiv,
403419
CanArrayFloorDiv,
404420
CanArrayIFloorDiv,
421+
CanArrayRFloorDiv,
405422
CanArrayMod,
406423
CanArrayIMod,
407424
CanArrayPow,

0 commit comments

Comments
 (0)