Skip to content

Commit bb7773e

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

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
@@ -208,6 +208,25 @@ def __truediv__(self, other: Self | int | float, /) -> Self:
208208
...
209209

210210

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

0 commit comments

Comments
 (0)