Skip to content

Commit 1cbc3c8

Browse files
committed
✨: add HasArrayIRShift protocol to support in-place right shift operator for array classes
1 parent 390d73a commit 1cbc3c8

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
@@ -478,6 +478,22 @@ def __rshift__(self, other: Self | int, /) -> Self:
478478
...
479479

480480

481+
class HasArrayIRShift(Protocol):
482+
"""Protocol for array classes that support the in-place right shift operator."""
483+
484+
def __irshift__(self, other: Self | int, /) -> Self:
485+
"""Calculates the in-place right shift for each element of an array instance with the respective element of the array other.
486+
487+
Args:
488+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
489+
490+
Returns:
491+
self, after performing the in-place right shift.
492+
493+
""" # noqa: E501
494+
...
495+
496+
481497
class HasArrayLT(Protocol):
482498
"""Protocol for array classes that support the less-than operator."""
483499

@@ -604,6 +620,7 @@ class Array(
604620
HasArrayLShift,
605621
HasArrayILShift,
606622
HasArrayRShift,
623+
HasArrayIRShift,
607624
HasArrayLT,
608625
HasArrayLE,
609626
HasArrayGT,

0 commit comments

Comments
 (0)