Skip to content

Commit ddd8b65

Browse files
committed
✨: add HasArrayIPow protocol to support in-place power operator for array classes
1 parent 8612110 commit ddd8b65

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

258258

259+
class HasArrayIPow(Protocol):
260+
"""Protocol for array classes that support the in-place power operator."""
261+
262+
def __ipow__(self, other: Self | int | float, /) -> Self:
263+
"""Calculates the in-place power for each element of an array instance with the respective element of the array other.
264+
265+
Args:
266+
other: exponent array. Must be compatible with self (see Broadcasting). Should have a numeric data type.
267+
268+
Returns:
269+
self, after performing the in-place power operation.
270+
271+
""" # noqa: E501
272+
...
273+
274+
259275
class HasArrayMatmul(Protocol):
260276
"""Protocol for array classes that support the matrix multiplication operator."""
261277

@@ -478,6 +494,7 @@ class Array(
478494
HasArrayIFloorDiv,
479495
HasArrayMod,
480496
HasArrayPow,
497+
HasArrayIPow,
481498
HasArrayMatmul,
482499
HasArrayInvert,
483500
HasArrayAnd,

0 commit comments

Comments
 (0)