Skip to content

Commit 540c855

Browse files
committed
✨: add CanArrayIPow protocol
Support in-place power operator for array classes
1 parent a7ac25e commit 540c855

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
@@ -287,6 +287,22 @@ def __pow__(self, other: Self | int | float, /) -> Self:
287287
...
288288

289289

290+
class CanArrayIPow(Protocol):
291+
"""Protocol for array classes that support the in-place power operator."""
292+
293+
def __ipow__(self, other: Self | int | float, /) -> Self:
294+
"""Calculates the in-place power for each element of an array instance with the respective element of the array other.
295+
296+
Args:
297+
other: exponent array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
298+
299+
Returns:
300+
self, after performing the in-place power operation.
301+
302+
""" # noqa: E501
303+
...
304+
305+
290306
class Array(
291307
HasArrayNamespace[NS_co],
292308
CanArrayPos,
@@ -302,6 +318,7 @@ class Array(
302318
CanArrayIFloorDiv,
303319
CanArrayMod,
304320
CanArrayPow,
321+
CanArrayIPow,
305322
Protocol,
306323
):
307324
"""Array API specification for array object attributes and methods."""

0 commit comments

Comments
 (0)