Skip to content

Commit b4acd32

Browse files
committed
✨: add CanArrayFloorDiv protocol
Support floor division operator for array classes
1 parent e2e3333 commit b4acd32

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
@@ -151,6 +151,25 @@ def __truediv__(self, other: Self | int | float, /) -> Self:
151151
...
152152

153153

154+
class CanArrayFloorDiv(Protocol):
155+
"""Protocol for array classes that support the floor division operator."""
156+
157+
def __floordiv__(self, other: Self | int | float, /) -> Self:
158+
"""Evaluates `self_i // other_i` for each element of an array instance with the respective element of the array `other`.
159+
160+
Args:
161+
other: Must be compatible with `self` (see Broadcasting). Should have a numeric data type.
162+
163+
Returns:
164+
Self: an array containing the element-wise results. The returned array must have a data type determined by Type Promotion Rules.
165+
166+
See Also:
167+
array_api_typing.FloorDiv
168+
169+
""" # noqa: E501
170+
...
171+
172+
154173
class Array(
155174
HasArrayNamespace[NS_co],
156175
CanArrayPos,
@@ -159,6 +178,7 @@ class Array(
159178
CanArraySub,
160179
CanArrayMul,
161180
CanArrayTrueDiv,
181+
CanArrayFloorDiv,
162182
Protocol,
163183
):
164184
"""Array API specification for array object attributes and methods."""

0 commit comments

Comments
 (0)