Skip to content

Commit 717b9c3

Browse files
committed
✨: add HasArrayIXor protocol to support in-place bitwise XOR operator for array classes
1 parent 49a5509 commit 717b9c3

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
@@ -414,6 +414,22 @@ def __xor__(self, other: Self | int | float, /) -> Self:
414414
...
415415

416416

417+
class HasArrayIXor(Protocol):
418+
"""Evaluates ``self_i ^= other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
419+
420+
def __ixor__(self, other: Self | int | float, /) -> Self:
421+
"""Calculates the in-place bitwise XOR for each element of an array instance with the respective element of the array other.
422+
423+
Args:
424+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
425+
426+
Returns:
427+
self, after performing the in-place bitwise XOR.
428+
429+
""" # noqa: E501
430+
...
431+
432+
417433
class HasArrayLShift(Protocol):
418434
"""Protocol for array classes that support the left shift operator."""
419435

@@ -568,6 +584,7 @@ class Array(
568584
HasArrayOr,
569585
HasArrayIOr,
570586
HasArrayXOr,
587+
HasArrayIXor,
571588
HasArrayLShift,
572589
HasArrayRShift,
573590
HasArrayLT,

0 commit comments

Comments
 (0)