4
4
from typing import TYPE_CHECKING
5
5
if TYPE_CHECKING :
6
6
from ._types import (List , Optional , SupportsDLPack ,
7
- SupportsBufferProtocol , Tuple , Union , array , device ,
8
- dtype )
7
+ SupportsBufferProtocol , Tuple , Union , Array , Device ,
8
+ Dtype )
9
9
from collections .abc import Sequence
10
10
from ._dtypes import _all_dtypes
11
11
12
12
import numpy as np
13
13
14
- def asarray (obj : Union [float , NestedSequence [bool | int | float ], SupportsDLPack , SupportsBufferProtocol ], / , * , dtype : Optional [dtype ] = None , device : Optional [device ] = None , copy : Optional [bool ] = None ) -> array :
14
+ def asarray (obj : Union [float , NestedSequence [bool | int | float ], SupportsDLPack , SupportsBufferProtocol ], / , * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None , copy : Optional [bool ] = None ) -> Array :
15
15
"""
16
16
Array API compatible wrapper for :py:func:`np.asarray <numpy.asarray>`.
17
17
@@ -37,7 +37,7 @@ def asarray(obj: Union[float, NestedSequence[bool|int|float], SupportsDLPack, Su
37
37
raise TypeError (f"The array_api namespace does not support the dtype '{ res .dtype } '" )
38
38
return ndarray ._new (res )
39
39
40
- def arange (start : Union [int , float ], / , stop : Optional [Union [int , float ]] = None , step : Union [int , float ] = 1 , * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
40
+ def arange (start : Union [int , float ], / , stop : Optional [Union [int , float ]] = None , step : Union [int , float ] = 1 , * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
41
41
"""
42
42
Array API compatible wrapper for :py:func:`np.arange <numpy.arange>`.
43
43
@@ -49,7 +49,7 @@ def arange(start: Union[int, float], /, stop: Optional[Union[int, float]] = None
49
49
raise NotImplementedError ("Device support is not yet implemented" )
50
50
return ndarray ._new (np .arange (start , stop = stop , step = step , dtype = dtype ))
51
51
52
- def empty (shape : Union [int , Tuple [int , ...]], * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
52
+ def empty (shape : Union [int , Tuple [int , ...]], * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
53
53
"""
54
54
Array API compatible wrapper for :py:func:`np.empty <numpy.empty>`.
55
55
@@ -61,7 +61,7 @@ def empty(shape: Union[int, Tuple[int, ...]], *, dtype: Optional[dtype] = None,
61
61
raise NotImplementedError ("Device support is not yet implemented" )
62
62
return ndarray ._new (np .empty (shape , dtype = dtype ))
63
63
64
- def empty_like (x : array , / , * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
64
+ def empty_like (x : Array , / , * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
65
65
"""
66
66
Array API compatible wrapper for :py:func:`np.empty_like <numpy.empty_like>`.
67
67
@@ -73,7 +73,7 @@ def empty_like(x: array, /, *, dtype: Optional[dtype] = None, device: Optional[d
73
73
raise NotImplementedError ("Device support is not yet implemented" )
74
74
return ndarray ._new (np .empty_like (x ._array , dtype = dtype ))
75
75
76
- def eye (n_rows : int , n_cols : Optional [int ] = None , / , * , k : Optional [int ] = 0 , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
76
+ def eye (n_rows : int , n_cols : Optional [int ] = None , / , * , k : Optional [int ] = 0 , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
77
77
"""
78
78
Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.
79
79
@@ -85,11 +85,11 @@ def eye(n_rows: int, n_cols: Optional[int] = None, /, *, k: Optional[int] = 0, d
85
85
raise NotImplementedError ("Device support is not yet implemented" )
86
86
return ndarray ._new (np .eye (n_rows , M = n_cols , k = k , dtype = dtype ))
87
87
88
- def from_dlpack (x : object , / ) -> array :
88
+ def from_dlpack (x : object , / ) -> Array :
89
89
# Note: dlpack support is not yet implemented on ndarray
90
90
raise NotImplementedError ("DLPack support is not yet implemented" )
91
91
92
- def full (shape : Union [int , Tuple [int , ...]], fill_value : Union [int , float ], * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
92
+ def full (shape : Union [int , Tuple [int , ...]], fill_value : Union [int , float ], * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
93
93
"""
94
94
Array API compatible wrapper for :py:func:`np.full <numpy.full>`.
95
95
@@ -108,7 +108,7 @@ def full(shape: Union[int, Tuple[int, ...]], fill_value: Union[int, float], *, d
108
108
raise TypeError ("Invalid input to full" )
109
109
return ndarray ._new (res )
110
110
111
- def full_like (x : array , / , fill_value : Union [int , float ], * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
111
+ def full_like (x : Array , / , fill_value : Union [int , float ], * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
112
112
"""
113
113
Array API compatible wrapper for :py:func:`np.full_like <numpy.full_like>`.
114
114
@@ -125,7 +125,7 @@ def full_like(x: array, /, fill_value: Union[int, float], *, dtype: Optional[dty
125
125
raise TypeError ("Invalid input to full_like" )
126
126
return ndarray ._new (res )
127
127
128
- def linspace (start : Union [int , float ], stop : Union [int , float ], / , num : int , * , dtype : Optional [dtype ] = None , device : Optional [device ] = None , endpoint : bool = True ) -> array :
128
+ def linspace (start : Union [int , float ], stop : Union [int , float ], / , num : int , * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None , endpoint : bool = True ) -> Array :
129
129
"""
130
130
Array API compatible wrapper for :py:func:`np.linspace <numpy.linspace>`.
131
131
@@ -137,7 +137,7 @@ def linspace(start: Union[int, float], stop: Union[int, float], /, num: int, *,
137
137
raise NotImplementedError ("Device support is not yet implemented" )
138
138
return ndarray ._new (np .linspace (start , stop , num , dtype = dtype , endpoint = endpoint ))
139
139
140
- def meshgrid (* arrays : Sequence [array ], indexing : str = 'xy' ) -> List [array , ...]:
140
+ def meshgrid (* arrays : Sequence [Array ], indexing : str = 'xy' ) -> List [Array , ...]:
141
141
"""
142
142
Array API compatible wrapper for :py:func:`np.meshgrid <numpy.meshgrid>`.
143
143
@@ -146,7 +146,7 @@ def meshgrid(*arrays: Sequence[array], indexing: str = 'xy') -> List[array, ...]
146
146
from ._array_object import ndarray
147
147
return [ndarray ._new (array ) for array in np .meshgrid (* [a ._array for a in arrays ], indexing = indexing )]
148
148
149
- def ones (shape : Union [int , Tuple [int , ...]], * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
149
+ def ones (shape : Union [int , Tuple [int , ...]], * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
150
150
"""
151
151
Array API compatible wrapper for :py:func:`np.ones <numpy.ones>`.
152
152
@@ -158,7 +158,7 @@ def ones(shape: Union[int, Tuple[int, ...]], *, dtype: Optional[dtype] = None, d
158
158
raise NotImplementedError ("Device support is not yet implemented" )
159
159
return ndarray ._new (np .ones (shape , dtype = dtype ))
160
160
161
- def ones_like (x : array , / , * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
161
+ def ones_like (x : Array , / , * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
162
162
"""
163
163
Array API compatible wrapper for :py:func:`np.ones_like <numpy.ones_like>`.
164
164
@@ -170,7 +170,7 @@ def ones_like(x: array, /, *, dtype: Optional[dtype] = None, device: Optional[de
170
170
raise NotImplementedError ("Device support is not yet implemented" )
171
171
return ndarray ._new (np .ones_like (x ._array , dtype = dtype ))
172
172
173
- def zeros (shape : Union [int , Tuple [int , ...]], * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
173
+ def zeros (shape : Union [int , Tuple [int , ...]], * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
174
174
"""
175
175
Array API compatible wrapper for :py:func:`np.zeros <numpy.zeros>`.
176
176
@@ -182,7 +182,7 @@ def zeros(shape: Union[int, Tuple[int, ...]], *, dtype: Optional[dtype] = None,
182
182
raise NotImplementedError ("Device support is not yet implemented" )
183
183
return ndarray ._new (np .zeros (shape , dtype = dtype ))
184
184
185
- def zeros_like (x : array , / , * , dtype : Optional [dtype ] = None , device : Optional [device ] = None ) -> array :
185
+ def zeros_like (x : Array , / , * , dtype : Optional [Dtype ] = None , device : Optional [Device ] = None ) -> Array :
186
186
"""
187
187
Array API compatible wrapper for :py:func:`np.zeros_like <numpy.zeros_like>`.
188
188
0 commit comments