Skip to content

Commit 19cd5f9

Browse files
committed
✨: add CanArrayIPow protocol
Support in-place power operator for array classes
1 parent c26f488 commit 19cd5f9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/array_api_typing/_array.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,25 @@ def __pow__(self, other: Self | int | float, /) -> Self:
302302
...
303303

304304

305+
class CanArrayIPow(Protocol):
306+
"""Protocol for array classes that support the in-place power operator."""
307+
308+
def __ipow__(self, other: Self | int | float, /) -> Self:
309+
"""Calculates the in-place power for each element of an array instance with the respective element of the array `other`.
310+
311+
Args:
312+
other: exponent array. Must be compatible with `self` (see Broadcasting). Should have a numeric data type.
313+
314+
Returns:
315+
Self: `self`, after performing the in-place power operation. The returned array must have a data type determined by Type Promotion Rules.
316+
317+
See Also:
318+
array_api_typing.Power
319+
320+
""" # noqa: E501
321+
...
322+
323+
305324
class Array(
306325
HasArrayNamespace[NS_co],
307326
CanArrayPos,
@@ -317,6 +336,7 @@ class Array(
317336
CanArrayIFloorDiv,
318337
CanArrayMod,
319338
CanArrayPow,
339+
CanArrayIPow,
320340
Protocol,
321341
):
322342
"""Array API specification for array object attributes and methods."""

0 commit comments

Comments
 (0)