Skip to content

Commit 7bd9f00

Browse files
committed
✨: add HasArrayRTruediv protocol to support right division operator for array classes
Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
1 parent 068d25e commit 7bd9f00

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

269269

270+
class CanArrayRTrueDiv(Protocol):
271+
"""Protocol for array classes that support the right true division operator."""
272+
273+
def __rtruediv__(self, other: Self | int | float, /) -> Self:
274+
"""Calculates the quotient for each element of an array instance with the respective element of the array other.
275+
276+
Args:
277+
other: divisor array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
278+
279+
Returns:
280+
an array containing the element-wise quotients. The returned array must have a data type determined by Type Promotion Rules.
281+
282+
""" # noqa: E501
283+
...
284+
285+
270286
class CanArrayFloorDiv(Protocol):
271287
"""Protocol for array classes that support the floor division operator."""
272288

@@ -383,6 +399,7 @@ class Array(
383399
CanArrayIMul,
384400
CanArrayRMul,
385401
CanArrayTrueDiv,
402+
CanArrayRTrueDiv,
386403
CanArrayFloorDiv,
387404
CanArrayIFloorDiv,
388405
CanArrayMod,

0 commit comments

Comments
 (0)