Skip to content

Commit 19f6f8b

Browse files
authored
rename ArrayApi into BaseArrayApi (#16)
1 parent 32ad385 commit 19f6f8b

File tree

5 files changed

+55
-55
lines changed

5 files changed

+55
-55
lines changed

onnx_array_api/npx/npx_array_api.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ArrayApiError(RuntimeError):
1313
pass
1414

1515

16-
class ArrayApi:
16+
class BaseArrayApi:
1717
"""
1818
List of supported method by a tensor.
1919
"""
@@ -36,145 +36,145 @@ def generic_method(self, method_name, *args: Any, **kwargs: Any) -> Any:
3636
f"for class {self.__class__.__name__!r}. "
3737
f"Method 'generic_method' can be overwritten "
3838
f"as well to change the behaviour "
39-
f"for all methods supported by class ArrayApi."
39+
f"for all methods supported by class BaseArrayApi."
4040
)
4141

4242
def numpy(self) -> np.ndarray:
4343
return self.generic_method("numpy")
4444

45-
def __neg__(self) -> "ArrayApi":
45+
def __neg__(self) -> "BaseArrayApi":
4646
return self.generic_method("__neg__")
4747

48-
def __invert__(self) -> "ArrayApi":
48+
def __invert__(self) -> "BaseArrayApi":
4949
return self.generic_method("__invert__")
5050

51-
def __add__(self, ov: "ArrayApi") -> "ArrayApi":
51+
def __add__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
5252
return self.generic_method("__add__", ov)
5353

54-
def __radd__(self, ov: "ArrayApi") -> "ArrayApi":
54+
def __radd__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
5555
return self.generic_method("__radd__", ov)
5656

57-
def __sub__(self, ov: "ArrayApi") -> "ArrayApi":
57+
def __sub__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
5858
return self.generic_method("__sub__", ov)
5959

60-
def __rsub__(self, ov: "ArrayApi") -> "ArrayApi":
60+
def __rsub__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
6161
return self.generic_method("__rsub__", ov)
6262

63-
def __mul__(self, ov: "ArrayApi") -> "ArrayApi":
63+
def __mul__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
6464
return self.generic_method("__mul__", ov)
6565

66-
def __rmul__(self, ov: "ArrayApi") -> "ArrayApi":
66+
def __rmul__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
6767
return self.generic_method("__rmul__", ov)
6868

69-
def __matmul__(self, ov: "ArrayApi") -> "ArrayApi":
69+
def __matmul__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
7070
return self.generic_method("__matmul__", ov)
7171

72-
def __truediv__(self, ov: "ArrayApi") -> "ArrayApi":
72+
def __truediv__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
7373
return self.generic_method("__truediv__", ov)
7474

75-
def __rtruediv__(self, ov: "ArrayApi") -> "ArrayApi":
75+
def __rtruediv__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
7676
return self.generic_method("__rtruediv__", ov)
7777

78-
def __mod__(self, ov: "ArrayApi") -> "ArrayApi":
78+
def __mod__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
7979
return self.generic_method("__mod__", ov)
8080

81-
def __rmod__(self, ov: "ArrayApi") -> "ArrayApi":
81+
def __rmod__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
8282
return self.generic_method("__rmod__", ov)
8383

84-
def __pow__(self, ov: "ArrayApi") -> "ArrayApi":
84+
def __pow__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
8585
return self.generic_method("__pow__", ov)
8686

87-
def __rpow__(self, ov: "ArrayApi") -> "ArrayApi":
87+
def __rpow__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
8888
return self.generic_method("__rpow__", ov)
8989

90-
def __lt__(self, ov: "ArrayApi") -> "ArrayApi":
90+
def __lt__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
9191
return self.generic_method("__lt__", ov)
9292

93-
def __le__(self, ov: "ArrayApi") -> "ArrayApi":
93+
def __le__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
9494
return self.generic_method("__le__", ov)
9595

96-
def __gt__(self, ov: "ArrayApi") -> "ArrayApi":
96+
def __gt__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
9797
return self.generic_method("__gt__", ov)
9898

99-
def __ge__(self, ov: "ArrayApi") -> "ArrayApi":
99+
def __ge__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
100100
return self.generic_method("__ge__", ov)
101101

102-
def __eq__(self, ov: "ArrayApi") -> "ArrayApi":
102+
def __eq__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
103103
return self.generic_method("__eq__", ov)
104104

105-
def __ne__(self, ov: "ArrayApi") -> "ArrayApi":
105+
def __ne__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
106106
return self.generic_method("__ne__", ov)
107107

108-
def __lshift__(self, ov: "ArrayApi") -> "ArrayApi":
108+
def __lshift__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
109109
return self.generic_method("__lshift__", ov)
110110

111-
def __rshift__(self, ov: "ArrayApi") -> "ArrayApi":
111+
def __rshift__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
112112
return self.generic_method("__rshift__", ov)
113113

114-
def __and__(self, ov: "ArrayApi") -> "ArrayApi":
114+
def __and__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
115115
return self.generic_method("__and__", ov)
116116

117-
def __rand__(self, ov: "ArrayApi") -> "ArrayApi":
117+
def __rand__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
118118
return self.generic_method("__rand__", ov)
119119

120-
def __or__(self, ov: "ArrayApi") -> "ArrayApi":
120+
def __or__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
121121
return self.generic_method("__or__", ov)
122122

123-
def __ror__(self, ov: "ArrayApi") -> "ArrayApi":
123+
def __ror__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
124124
return self.generic_method("__ror__", ov)
125125

126-
def __xor__(self, ov: "ArrayApi") -> "ArrayApi":
126+
def __xor__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
127127
return self.generic_method("__xor__", ov)
128128

129-
def __rxor__(self, ov: "ArrayApi") -> "ArrayApi":
129+
def __rxor__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
130130
return self.generic_method("__rxor__", ov)
131131

132132
@property
133-
def T(self) -> "ArrayApi":
133+
def T(self) -> "BaseArrayApi":
134134
return self.generic_method("T")
135135

136-
def astype(self, dtype: Any) -> "ArrayApi":
136+
def astype(self, dtype: Any) -> "BaseArrayApi":
137137
return self.generic_method("astype", dtype)
138138

139139
@property
140-
def shape(self) -> "ArrayApi":
140+
def shape(self) -> "BaseArrayApi":
141141
return self.generic_method("shape")
142142

143-
def reshape(self, shape: "ArrayApi") -> "ArrayApi":
143+
def reshape(self, shape: "BaseArrayApi") -> "BaseArrayApi":
144144
return self.generic_method("reshape", shape)
145145

146146
def sum(
147147
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
148-
) -> "ArrayApi":
148+
) -> "BaseArrayApi":
149149
return self.generic_method("sum", axis=axis, keepdims=keepdims)
150150

151151
def mean(
152152
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
153-
) -> "ArrayApi":
153+
) -> "BaseArrayApi":
154154
return self.generic_method("mean", axis=axis, keepdims=keepdims)
155155

156156
def min(
157157
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
158-
) -> "ArrayApi":
158+
) -> "BaseArrayApi":
159159
return self.generic_method("min", axis=axis, keepdims=keepdims)
160160

161161
def max(
162162
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
163-
) -> "ArrayApi":
163+
) -> "BaseArrayApi":
164164
return self.generic_method("max", axis=axis, keepdims=keepdims)
165165

166166
def prod(
167167
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
168-
) -> "ArrayApi":
168+
) -> "BaseArrayApi":
169169
return self.generic_method("prod", axis=axis, keepdims=keepdims)
170170

171-
def copy(self) -> "ArrayApi":
171+
def copy(self) -> "BaseArrayApi":
172172
return self.generic_method("copy")
173173

174-
def flatten(self) -> "ArrayApi":
174+
def flatten(self) -> "BaseArrayApi":
175175
return self.generic_method("flatten")
176176

177-
def __getitem__(self, index: Any) -> "ArrayApi":
177+
def __getitem__(self, index: Any) -> "BaseArrayApi":
178178
return self.generic_method("__getitem__", index)
179179

180180
def __setitem__(self, index: Any, values: Any):

onnx_array_api/npx/npx_functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from .npx_constants import FUNCTION_DOMAIN
1010
from .npx_core_api import cst, make_tuple, npxapi_inline, npxapi_no_inline, var
11-
from .npx_tensors import ArrayApi
11+
from .npx_tensors import BaseArrayApi
1212
from .npx_types import (
1313
DType,
1414
ElemType,
@@ -173,7 +173,7 @@ def asarray(
173173
raise RuntimeError("Method 'astype' should be used to change the type.")
174174
if order is not None:
175175
raise NotImplementedError(f"order={order!r} not implemented.")
176-
if isinstance(a, ArrayApi):
176+
if isinstance(a, BaseArrayApi):
177177
if copy:
178178
return a.__class__(a, copy=copy)
179179
return a
@@ -404,7 +404,7 @@ def isdtype(
404404
dtype: DType, kind: Union[DType, str, Tuple[Union[DType, str], ...]]
405405
) -> bool:
406406
"""
407-
See :epkg:`ArrayAPI:isdtype`.
407+
See :epkg:`BaseArrayAPI:isdtype`.
408408
This function is not converted into an onnx graph.
409409
"""
410410
return np_array_api.isdtype(dtype, kind)

onnx_array_api/npx/npx_tensors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
from onnx.helper import np_dtype_to_tensor_dtype
55

6-
from .npx_array_api import ArrayApi, ArrayApiError
6+
from .npx_array_api import BaseArrayApi, ArrayApiError
77

88

99
class JitTensor:
@@ -14,11 +14,11 @@ class JitTensor:
1414
pass
1515

1616

17-
class EagerTensor(ArrayApi):
17+
class EagerTensor(BaseArrayApi):
1818
"""
1919
Defines a value for a specific eager mode.
2020
An eager tensor must overwrite every call to a method listed in class
21-
:class:`ArrayApi`.
21+
:class:`BaseArrayApi`.
2222
"""
2323

2424
def __iter__(self):
@@ -215,7 +215,7 @@ def generic_method(self, method_name, *args: Any, **kwargs: Any) -> Any:
215215
return self._generic_method_getitem(method_name, *args, **kwargs)
216216

217217
if method_name == "__setitem__":
218-
return ArrayApi.generic_method(self, method_name, *args, **kwargs)
218+
return BaseArrayApi.generic_method(self, method_name, *args, **kwargs)
219219

220220
if method_name in {"mean", "sum", "min", "max", "prod"}:
221221
return self._generic_method_reduce(method_name, *args, **kwargs)
@@ -226,4 +226,4 @@ def generic_method(self, method_name, *args: Any, **kwargs: Any) -> Any:
226226
if method_name.startswith("__") and method_name.endswith("__"):
227227
return self._generic_method_operator(method_name, *args, **kwargs)
228228

229-
return ArrayApi.generic_method(self, method_name, *args, **kwargs)
229+
return BaseArrayApi.generic_method(self, method_name, *args, **kwargs)

onnx_array_api/npx/npx_var.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from onnx import FunctionProto, ModelProto, NodeProto, TensorProto
55
from onnx.helper import np_dtype_to_tensor_dtype
66

7-
from .npx_array_api import ArrayApi, ArrayApiError
7+
from .npx_array_api import BaseArrayApi, ArrayApiError
88
from .npx_constants import DEFAULT_OPSETS, ONNX_DOMAIN
99
from .npx_types import ElemType, OptParType, ParType, TensorType, TupleType
1010

@@ -181,7 +181,7 @@ def to_onnx(
181181
return onx
182182

183183

184-
class Var(ArrayApi):
184+
class Var(BaseArrayApi):
185185
"""
186186
Defines a variable, a result...
187187

onnx_array_api/ort/ort_tensors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,15 @@ def get_ir_version(cls, ir_version):
231231

232232
class EagerOrtTensor(OrtTensor, OrtCommon, EagerTensor):
233233
"""
234-
Defines a value for a specific backend.
234+
Defines a value for :epkg:`onnxruntime` as a backend.
235235
"""
236236

237237
pass
238238

239239

240240
class JitOrtTensor(OrtTensor, OrtCommon, JitTensor):
241241
"""
242-
Defines a value for a specific backend.
242+
Defines a value for :epkg:`onnxruntime` as a backend.
243243
"""
244244

245245
pass

0 commit comments

Comments
 (0)