Skip to content

Commit b17ac47

Browse files
committed
✨: add HasArrayRAnd protocol to support right bitwise AND operator for array classes
1 parent 5b17ca0 commit b17ac47

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
@@ -496,6 +496,22 @@ def __iand__(self, other: Self | int | float, /) -> Self:
496496
...
497497

498498

499+
class HasArrayRAnd(Protocol):
500+
"""Evaluates ``self_i & other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
501+
502+
def __rand__(self, other: Self | int | float, /) -> Self:
503+
"""Calculates the bitwise AND for each element of an array instance with the respective element of the array other.
504+
505+
Args:
506+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
507+
508+
Returns:
509+
an array containing the element-wise bitwise ANDs. The returned array must have a data type determined by Type Promotion Rules.
510+
511+
""" # noqa: E501
512+
...
513+
514+
499515
class HasArrayOr(Protocol):
500516
"""Evaluates ``self_i | other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
501517

@@ -751,6 +767,7 @@ class Array(
751767
HasArrayInvert,
752768
HasArrayAnd,
753769
HasArrayIAnd,
770+
HasArrayRAnd,
754771
HasArrayOr,
755772
HasArrayIOr,
756773
HasArrayXOr,

0 commit comments

Comments
 (0)