Skip to content

Commit da84fd1

Browse files
committed
✨: add HasArrayROr protocol to support right bitwise OR operator for array classes
1 parent b17ac47 commit da84fd1

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
@@ -544,6 +544,22 @@ def __ior__(self, other: Self | int | float, /) -> Self:
544544
...
545545

546546

547+
class HasArrayROr(Protocol):
548+
"""Evaluates ``self_i | other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
549+
550+
def __ror__(self, other: Self | int | float, /) -> Self:
551+
"""Calculates the bitwise OR for each element of an array instance with the respective element of the array other.
552+
553+
Args:
554+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
555+
556+
Returns:
557+
an array containing the element-wise bitwise ORs. The returned array must have a data type determined by Type Promotion Rules.
558+
559+
""" # noqa: E501
560+
...
561+
562+
547563
class HasArrayXOr(Protocol):
548564
"""Evaluates ``self_i ^ other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
549565

@@ -770,6 +786,7 @@ class Array(
770786
HasArrayRAnd,
771787
HasArrayOr,
772788
HasArrayIOr,
789+
HasArrayROr,
773790
HasArrayXOr,
774791
HasArrayIXor,
775792
HasArrayLShift,

0 commit comments

Comments
 (0)