Skip to content

Commit 49a5509

Browse files
committed
✨: add HasArrayIOr protocol to support in-place bitwise OR operator for array classes
1 parent 2b15398 commit 49a5509

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
@@ -382,6 +382,22 @@ def __or__(self, other: Self | int | float, /) -> Self:
382382
...
383383

384384

385+
class HasArrayIOr(Protocol):
386+
"""Evaluates ``self_i |= other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
387+
388+
def __ior__(self, other: Self | int | float, /) -> Self:
389+
"""Calculates the in-place bitwise OR for each element of an array instance with the respective element of the array other.
390+
391+
Args:
392+
other: operand array. Must be compatible with self (see Broadcasting). Should have an integer data type.
393+
394+
Returns:
395+
self, after performing the in-place bitwise OR.
396+
397+
""" # noqa: E501
398+
...
399+
400+
385401
class HasArrayXOr(Protocol):
386402
"""Evaluates ``self_i ^ other_i`` for each element of an array instance with the respective element of the array other.""" # noqa: E501
387403

@@ -550,6 +566,7 @@ class Array(
550566
HasArrayAnd,
551567
HasArrayIAnd,
552568
HasArrayOr,
569+
HasArrayIOr,
553570
HasArrayXOr,
554571
HasArrayLShift,
555572
HasArrayRShift,

0 commit comments

Comments
 (0)