Skip to content

Commit 2b15398

Browse files
committed
✨: add HasArrayIAnd protocol to support in-place bitwise AND operator for array classes
1 parent 2598ed9 commit 2b15398

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
@@ -350,6 +350,22 @@ def __and__(self, other: Self | int | float, /) -> Self:
350350
...
351351

352352

353+
class HasArrayIAnd(Protocol):
354+
"""Evaluates ``self_i &= other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
355+
356+
def __iand__(self, other: Self | int | float, /) -> Self:
357+
"""Calculates the in-place bitwise AND for each element of an array instance with the respective element of the array other.
358+
359+
Args:
360+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
361+
362+
Returns:
363+
self, after performing the in-place bitwise AND.
364+
365+
""" # noqa: E501
366+
...
367+
368+
353369
class HasArrayOr(Protocol):
354370
"""Evaluates ``self_i | other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
355371

@@ -532,6 +548,7 @@ class Array(
532548
HasArrayIMatmul,
533549
HasArrayInvert,
534550
HasArrayAnd,
551+
HasArrayIAnd,
535552
HasArrayOr,
536553
HasArrayXOr,
537554
HasArrayLShift,

0 commit comments

Comments
 (0)