Skip to content

Commit 76b0245

Browse files
committed
✨: add HasArrayNeg protocol to support unary minus operator
1 parent 637b592 commit 76b0245

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/array_api_typing/_array.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,25 @@ def __pos__(self) -> Self:
4545
...
4646

4747

48+
class HasArrayNeg(Protocol):
49+
"""Protocol for array classes that support the unary minus operator."""
50+
51+
def __neg__(self) -> Self:
52+
"""Evaluates -self_i for each element of an array instance.
53+
54+
Returns:
55+
an array containing the evaluated result for each element in self.
56+
The returned array must have a data type determined by Type
57+
Promotion Rules.
58+
59+
"""
60+
...
61+
62+
4863
class Array(
4964
HasArrayNamespace[NS_co],
5065
HasArrayPos,
66+
HasArrayNeg,
5167
Protocol,
5268
):
5369
"""Array API specification for array object attributes and methods."""

0 commit comments

Comments
 (0)