Skip to content

Commit 0a935a8

Browse files
committed
✨: add CanArrayRTruediv protocol
Support right division operator for array classes Signed-off-by: Nathaniel Starkman <[email protected]>
1 parent 5165e18 commit 0a935a8

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
@@ -288,6 +288,25 @@ def __itruediv__(self, other: Self | int | float, /) -> Self:
288288
...
289289

290290

291+
class CanArrayRTrueDiv(Protocol):
292+
"""Protocol for array classes that support the right true division operator."""
293+
294+
def __rtruediv__(self, other: Self | int | float, /) -> Self:
295+
"""Calculates the quotient for each element of the array `other` with the respective element of an array instance.
296+
297+
Args:
298+
other: dividend array. Must be compatible with `self` (see Broadcasting). Should have a numeric data type.
299+
300+
Returns:
301+
Self: an array containing the element-wise quotients. The returned array must have a data type determined by Type Promotion Rules.
302+
303+
See Also:
304+
array_api_typing.TrueDiv
305+
306+
""" # noqa: E501
307+
...
308+
309+
291310
class CanArrayFloorDiv(Protocol):
292311
"""Protocol for array classes that support the floor division operator."""
293312

@@ -413,6 +432,7 @@ class Array(
413432
CanArrayIMul,
414433
CanArrayRMul,
415434
CanArrayTrueDiv,
435+
CanArrayRTrueDiv,
416436
CanArrayFloorDiv,
417437
CanArrayIFloorDiv,
418438
CanArrayMod,

0 commit comments

Comments
 (0)