Skip to content

Commit dce36c4

Browse files
committed
✨: add CanArrayITruediv protocol
Support in-place true division operator for array classes
1 parent bba937a commit dce36c4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/array_api_typing/_array.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,25 @@ def __truediv__(self, other: Self | int | float, /) -> Self:
210210
...
211211

212212

213+
class CanArrayITruediv(Protocol):
214+
"""Protocol for array classes that support the in-place true division operator."""
215+
216+
def __itruediv__(self, other: Self | int | float, /) -> Self:
217+
"""Calculates the in-place quotient for each element of an array instance with the respective element of the array `other`.
218+
219+
Args:
220+
other: divisor array. Must be compatible with `self` (see Broadcasting). Should have a numeric data type.
221+
222+
Returns:
223+
Self: `self`, after performing the in-place true division. The returned array must have a data type determined by Type Promotion Rules.
224+
225+
See Also:
226+
array_api_typing.TrueDiv
227+
228+
""" # noqa: E501
229+
...
230+
231+
213232
class CanArrayFloorDiv(Protocol):
214233
"""Protocol for array classes that support the floor division operator."""
215234

0 commit comments

Comments
 (0)