Skip to content

Commit d7c59d3

Browse files
committed
✨: add HasArrayRXor protocol to support right bitwise XOR operator for array classes
1 parent da84fd1 commit d7c59d3

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
@@ -592,6 +592,22 @@ def __ixor__(self, other: Self | int | float, /) -> Self:
592592
...
593593

594594

595+
class HasArrayRXor(Protocol):
596+
"""Evaluates ``self_i ^ other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
597+
598+
def __rxor__(self, other: Self | int | float, /) -> Self:
599+
"""Calculates the bitwise XOR for each element of an array instance with the respective element of the array other.
600+
601+
Args:
602+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
603+
604+
Returns:
605+
an array containing the element-wise bitwise XORs. The returned array must have a data type determined by Type Promotion Rules.
606+
607+
""" # noqa: E501
608+
...
609+
610+
595611
class HasArrayLShift(Protocol):
596612
"""Protocol for array classes that support the left shift operator."""
597613

@@ -789,6 +805,7 @@ class Array(
789805
HasArrayROr,
790806
HasArrayXOr,
791807
HasArrayIXor,
808+
HasArrayRXor,
792809
HasArrayLShift,
793810
HasArrayILShift,
794811
HasArrayRShift,

0 commit comments

Comments
 (0)