Skip to content

Commit cca6714

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

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

288288

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

@@ -411,6 +430,7 @@ class Array(
411430
CanArrayIMul,
412431
CanArrayRMul,
413432
CanArrayTrueDiv,
433+
CanArrayRTrueDiv,
414434
CanArrayFloorDiv,
415435
CanArrayIFloorDiv,
416436
CanArrayMod,

0 commit comments

Comments
 (0)