Skip to content

Commit f98896e

Browse files
committed
✨: add HasArrayFloorDiv protocol to support floor division operator for array classes
1 parent 439c70a commit f98896e

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
@@ -126,6 +126,22 @@ def __truediv__(self, other: Self | int | float, /) -> Self:
126126
...
127127

128128

129+
class HasArrayFloorDiv(Protocol):
130+
"""Protocol for array classes that support the floor division operator."""
131+
132+
def __floordiv__(self, other: Self | int | float, /) -> Self:
133+
"""Calculates the quotient for each element of an array instance with the respective element of the array other.
134+
135+
Args:
136+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
137+
138+
Returns:
139+
an array containing the element-wise quotients. The returned array must have a data type determined by Type Promotion Rules.
140+
141+
""" # noqa: E501
142+
...
143+
144+
129145
class Array(
130146
HasArrayNamespace[NS_co],
131147
HasArrayPos,
@@ -134,6 +150,7 @@ class Array(
134150
HasArraySub,
135151
HasArrayMul,
136152
HasArrayTrueDiv,
153+
HasArrayFloorDiv,
137154
Protocol,
138155
):
139156
"""Array API specification for array object attributes and methods."""

0 commit comments

Comments
 (0)