Skip to content

Commit 0539997

Browse files
committed
✨: add HasArrayRRShift protocol to support right right shift operator for array classes
1 parent 9024fe5 commit 0539997

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
@@ -688,6 +688,22 @@ def __irshift__(self, other: Self | int, /) -> Self:
688688
...
689689

690690

691+
class HasArrayRRShift(Protocol):
692+
"""Protocol for array classes that support the right right shift operator."""
693+
694+
def __rrshift__(self, other: Self | int, /) -> Self:
695+
"""Calculates the right shift for each element of an array instance with the respective element of the array other.
696+
697+
Args:
698+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
699+
700+
Returns:
701+
an array containing the element-wise right shifts. The returned array must have a data type determined by Type Promotion Rules.
702+
703+
""" # noqa: E501
704+
...
705+
706+
691707
class HasArrayLT(Protocol):
692708
"""Protocol for array classes that support the less-than operator."""
693709

@@ -827,6 +843,7 @@ class Array(
827843
HasArrayRLShift,
828844
HasArrayRShift,
829845
HasArrayIRShift,
846+
HasArrayRRShift,
830847
HasArrayLT,
831848
HasArrayLE,
832849
HasArrayGT,

0 commit comments

Comments
 (0)