Skip to content

Commit de335e0

Browse files
committed
✨: add HasArrayRTruediv protocol to support right division operator for array classes
Signed-off-by: Nathaniel Starkman <[email protected]>
1 parent 70e790d commit de335e0

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
@@ -242,6 +242,22 @@ def __itruediv__(self, other: Self | int | float, /) -> Self:
242242
...
243243

244244

245+
class CanArrayRTrueDiv(Protocol):
246+
"""Protocol for array classes that support the right true division operator."""
247+
248+
def __rtruediv__(self, other: Self | int | float, /) -> Self:
249+
"""Calculates the quotient for each element of an array instance with the respective element of the array other.
250+
251+
Args:
252+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
253+
254+
Returns:
255+
an array containing the element-wise quotients. The returned array must have a data type determined by Type Promotion Rules.
256+
257+
""" # noqa: E501
258+
...
259+
260+
245261
class CanArrayFloorDiv(Protocol):
246262
"""Protocol for array classes that support the floor division operator."""
247263

@@ -352,6 +368,7 @@ class Array(
352368
CanArrayIMul,
353369
CanArrayRMul,
354370
CanArrayTrueDiv,
371+
CanArrayRTrueDiv,
355372
CanArrayFloorDiv,
356373
CanArrayIFloorDiv,
357374
CanArrayMod,

0 commit comments

Comments
 (0)