Skip to content

Commit 390d73a

Browse files
committed
✨: add HasArrayILShift protocol to support in-place left shift operator for array classes
1 parent 717b9c3 commit 390d73a

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
@@ -446,6 +446,22 @@ def __lshift__(self, other: Self | int, /) -> Self:
446446
...
447447

448448

449+
class HasArrayILShift(Protocol):
450+
"""Protocol for array classes that support the in-place left shift operator."""
451+
452+
def __ilshift__(self, other: Self | int, /) -> Self:
453+
"""Calculates the in-place left shift for each element of an array instance with the respective element of the array other.
454+
455+
Args:
456+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
457+
458+
Returns:
459+
self, after performing the in-place left shift.
460+
461+
""" # noqa: E501
462+
...
463+
464+
449465
class HasArrayRShift(Protocol):
450466
"""Protocol for array classes that support the right shift operator."""
451467

@@ -586,6 +602,7 @@ class Array(
586602
HasArrayXOr,
587603
HasArrayIXor,
588604
HasArrayLShift,
605+
HasArrayILShift,
589606
HasArrayRShift,
590607
HasArrayLT,
591608
HasArrayLE,

0 commit comments

Comments
 (0)