Skip to content

Commit 216a12d

Browse files
committed
✨: add HasArrayLE protocol to support less-equal operator for array classes
1 parent 445e057 commit 216a12d

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
@@ -300,6 +300,22 @@ def __lt__(self, other: Self | int | float) -> Self:
300300
...
301301

302302

303+
class HasArrayLE(Protocol):
304+
"""Protocol for array classes that support the less-equal operator."""
305+
306+
def __lt__(self, other: Self | int | float) -> Self:
307+
"""Computes the truth value of ``self_i <= other_i`` for each element of an array instance with the respective element of the array other.
308+
309+
Args:
310+
other: other array. Must be compatible with ``self`` (see Broadcasting). Should have a numeric data type.
311+
312+
Returns:
313+
an array containing the element-wise results. The returned array must have a data type of bool.
314+
315+
""" # noqa: E501
316+
...
317+
318+
303319
class Array(
304320
HasArrayNamespace[NS_co],
305321
HasArrayPos,
@@ -319,6 +335,7 @@ class Array(
319335
HasArrayLShift,
320336
HasArrayRShift,
321337
HasArrayLT,
338+
HasArrayLE,
322339
Protocol,
323340
):
324341
"""Array API specification for array object attributes and methods."""

0 commit comments

Comments
 (0)