Skip to content

Commit 9024fe5

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

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
@@ -640,6 +640,22 @@ def __ilshift__(self, other: Self | int, /) -> Self:
640640
...
641641

642642

643+
class HasArrayRLShift(Protocol):
644+
"""Protocol for array classes that support the right left shift operator."""
645+
646+
def __rlshift__(self, other: Self | int, /) -> Self:
647+
"""Calculates the left shift for each element of an array instance with the respective element of the array other.
648+
649+
Args:
650+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
651+
652+
Returns:
653+
an array containing the element-wise left shifts. The returned array must have a data type determined by Type Promotion Rules.
654+
655+
""" # noqa: E501
656+
...
657+
658+
643659
class HasArrayRShift(Protocol):
644660
"""Protocol for array classes that support the right shift operator."""
645661

@@ -808,6 +824,7 @@ class Array(
808824
HasArrayRXor,
809825
HasArrayLShift,
810826
HasArrayILShift,
827+
HasArrayRLShift,
811828
HasArrayRShift,
812829
HasArrayIRShift,
813830
HasArrayLT,

0 commit comments

Comments
 (0)