Skip to content

Commit 94b8d8a

Browse files
committed
✨: add CanArrayRFloorDiv protocol
Support right floor division operator for array classes
1 parent cca6714 commit 94b8d8a

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

345345

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

@@ -433,6 +452,7 @@ class Array(
433452
CanArrayRTrueDiv,
434453
CanArrayFloorDiv,
435454
CanArrayIFloorDiv,
455+
CanArrayRFloorDiv,
436456
CanArrayMod,
437457
CanArrayIMod,
438458
CanArrayPow,

0 commit comments

Comments
 (0)