Skip to content

Commit 5a121cf

Browse files
committed
convert arange to a protocol
Signed-off-by: nstarman <[email protected]>
1 parent 50bad52 commit 5a121cf

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

Diff for: src/array_api_stubs/_draft/_namespace.py

+3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
from typing import Protocol
44

5+
from .creation_functions import arange as ArangeCallable
6+
57

68
class ArrayAPINamespace(Protocol):
79
"""Protocol for the array API namespace itself."""
810

11+
arange: ArangeCallable

Diff for: src/array_api_stubs/_draft/creation_functions.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Protocol
12
from ._types import (
23
List,
34
NestedSequence,
@@ -11,15 +12,7 @@
1112
)
1213

1314

14-
def arange(
15-
start: Union[int, float],
16-
/,
17-
stop: Optional[Union[int, float]] = None,
18-
step: Union[int, float] = 1,
19-
*,
20-
dtype: Optional[dtype] = None,
21-
device: Optional[device] = None,
22-
) -> array:
15+
class arange(Protocol):
2316
"""
2417
Returns evenly spaced values within the half-open interval ``[start, stop)`` as a one-dimensional array.
2518
@@ -46,6 +39,17 @@ def arange(
4639
a one-dimensional array containing evenly spaced values. The length of the output array must be ``ceil((stop-start)/step)`` if ``stop - start`` and ``step`` have the same sign, and length ``0`` otherwise.
4740
"""
4841

42+
def __call__(
43+
start: Union[int, float],
44+
/,
45+
stop: Optional[Union[int, float]] = None,
46+
step: Union[int, float] = 1,
47+
*,
48+
dtype: Optional[dtype] = None,
49+
device: Optional[device] = None,
50+
) -> array:
51+
...
52+
4953

5054
def asarray(
5155
obj: Union[

0 commit comments

Comments
 (0)