Skip to content

Commit fa4e6b8

Browse files
committed
✨: add CanArrayRFloorDiv protocol
Support right floor division operator for array classes
1 parent 0a935a8 commit fa4e6b8

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
@@ -345,6 +345,25 @@ def __ifloordiv__(self, other: Self | int | float, /) -> Self:
345345
...
346346

347347

348+
class CanArrayRFloorDiv(Protocol):
349+
"""Protocol for array classes that support the right floor division operator."""
350+
351+
def __rfloordiv__(self, other: Self | int | float, /) -> Self:
352+
"""Calculates the floor division for each element of the array `other` with the respective element of an array instance.
353+
354+
Args:
355+
other: dividend array. Must be compatible with `self` (see Broadcasting). Should have a numeric data type.
356+
357+
Returns:
358+
Self: an array containing the element-wise floor division results. The returned array must have a data type determined by Type Promotion Rules.
359+
360+
See Also:
361+
array_api_typing.FloorDiv
362+
363+
""" # noqa: E501
364+
...
365+
366+
348367
class CanArrayMod(Protocol):
349368
"""Protocol for array classes that support the modulo operator."""
350369

@@ -435,6 +454,7 @@ class Array(
435454
CanArrayRTrueDiv,
436455
CanArrayFloorDiv,
437456
CanArrayIFloorDiv,
457+
CanArrayRFloorDiv,
438458
CanArrayMod,
439459
CanArrayIMod,
440460
CanArrayPow,

0 commit comments

Comments
 (0)