array-api-strict 2.2__py3-none-any.whl → 2.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- array_api_strict/__init__.py +10 -7
- array_api_strict/_array_object.py +31 -19
- array_api_strict/_creation_functions.py +2 -0
- array_api_strict/_data_type_functions.py +34 -3
- array_api_strict/_dtypes.py +1 -0
- array_api_strict/_elementwise_functions.py +140 -471
- array_api_strict/_fft.py +31 -5
- array_api_strict/_flags.py +10 -8
- array_api_strict/_helpers.py +37 -0
- array_api_strict/_linear_algebra_functions.py +1 -1
- array_api_strict/_manipulation_functions.py +5 -0
- array_api_strict/_searching_functions.py +34 -5
- array_api_strict/_statistical_functions.py +42 -5
- array_api_strict/_version.py +16 -16
- array_api_strict/tests/test_array_object.py +146 -74
- array_api_strict/tests/test_creation_functions.py +7 -0
- array_api_strict/tests/test_data_type_functions.py +24 -4
- array_api_strict/tests/test_elementwise_functions.py +66 -8
- array_api_strict/tests/test_flags.py +29 -18
- array_api_strict/tests/test_manipulation_functions.py +1 -1
- array_api_strict/tests/test_searching_functions.py +44 -0
- array_api_strict/tests/test_statistical_functions.py +19 -1
- array_api_strict/tests/test_validation.py +1 -1
- array_api_strict-2.3.1.dist-info/METADATA +68 -0
- array_api_strict-2.3.1.dist-info/RECORD +43 -0
- {array_api_strict-2.2.dist-info → array_api_strict-2.3.1.dist-info}/WHEEL +1 -1
- array_api_strict-2.2.dist-info/METADATA +0 -37
- array_api_strict-2.2.dist-info/RECORD +0 -41
- {array_api_strict-2.2.dist-info → array_api_strict-2.3.1.dist-info}/LICENSE +0 -0
- {array_api_strict-2.2.dist-info → array_api_strict-2.3.1.dist-info}/top_level.txt +0 -0
|
@@ -236,3 +236,10 @@ def from_dlpack_2023_12(api_version):
|
|
|
236
236
|
pytest.raises(exception, lambda: from_dlpack(capsule, copy=False))
|
|
237
237
|
pytest.raises(exception, lambda: from_dlpack(capsule, copy=True))
|
|
238
238
|
pytest.raises(exception, lambda: from_dlpack(capsule, copy=None))
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def test_from_dlpack_default_device():
|
|
242
|
+
x = asarray([1, 2, 3])
|
|
243
|
+
y = from_dlpack(x)
|
|
244
|
+
z = from_dlpack(np.asarray([1, 2, 3]))
|
|
245
|
+
assert x.device == y.device == z.device == CPU_DEVICE
|
|
@@ -6,9 +6,9 @@ from numpy.testing import assert_raises
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
|
|
8
8
|
from .._creation_functions import asarray
|
|
9
|
-
from .._data_type_functions import astype, can_cast, isdtype
|
|
9
|
+
from .._data_type_functions import astype, can_cast, isdtype, result_type
|
|
10
10
|
from .._dtypes import (
|
|
11
|
-
bool, int8, int16, uint8, float64,
|
|
11
|
+
bool, int8, int16, uint8, float64, int64
|
|
12
12
|
)
|
|
13
13
|
from .._flags import set_array_api_strict_flags
|
|
14
14
|
|
|
@@ -31,15 +31,17 @@ def test_can_cast(from_, to, expected):
|
|
|
31
31
|
def test_isdtype_strictness():
|
|
32
32
|
assert_raises(TypeError, lambda: isdtype(float64, 64))
|
|
33
33
|
assert_raises(ValueError, lambda: isdtype(float64, 'f8'))
|
|
34
|
-
|
|
35
34
|
assert_raises(TypeError, lambda: isdtype(float64, (('integral',),)))
|
|
35
|
+
assert_raises(TypeError, lambda: isdtype(float64, None))
|
|
36
|
+
assert_raises(TypeError, lambda: isdtype(np.float64, float64))
|
|
37
|
+
assert_raises(TypeError, lambda: isdtype(asarray(1.0), float64))
|
|
38
|
+
|
|
36
39
|
with assert_raises(TypeError), warnings.catch_warnings(record=True) as w:
|
|
37
40
|
warnings.simplefilter("always")
|
|
38
41
|
isdtype(float64, np.object_)
|
|
39
42
|
assert len(w) == 1
|
|
40
43
|
assert issubclass(w[-1].category, UserWarning)
|
|
41
44
|
|
|
42
|
-
assert_raises(TypeError, lambda: isdtype(float64, None))
|
|
43
45
|
with assert_raises(TypeError), warnings.catch_warnings(record=True) as w:
|
|
44
46
|
warnings.simplefilter("always")
|
|
45
47
|
isdtype(float64, np.float64)
|
|
@@ -68,3 +70,21 @@ def astype_device(api_version):
|
|
|
68
70
|
else:
|
|
69
71
|
pytest.raises(TypeError, lambda: astype(a, int8, device=None))
|
|
70
72
|
pytest.raises(TypeError, lambda: astype(a, int8, device=a.device))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@pytest.mark.parametrize("api_version", ['2023.12', '2024.12'])
|
|
76
|
+
def test_result_type_py_scalars(api_version):
|
|
77
|
+
if api_version <= '2023.12':
|
|
78
|
+
set_array_api_strict_flags(api_version=api_version)
|
|
79
|
+
|
|
80
|
+
with pytest.raises(TypeError):
|
|
81
|
+
result_type(int16, 3)
|
|
82
|
+
else:
|
|
83
|
+
set_array_api_strict_flags(api_version=api_version)
|
|
84
|
+
|
|
85
|
+
assert result_type(int8, 3) == int8
|
|
86
|
+
assert result_type(uint8, 3) == uint8
|
|
87
|
+
assert result_type(float64, 3) == float64
|
|
88
|
+
|
|
89
|
+
with pytest.raises(TypeError):
|
|
90
|
+
result_type(int64, True)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from inspect import signature, getmodule
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from pytest import raises as assert_raises
|
|
4
|
+
from numpy.testing import suppress_warnings
|
|
4
5
|
|
|
5
|
-
import pytest
|
|
6
6
|
|
|
7
7
|
from .. import asarray, _elementwise_functions
|
|
8
8
|
from .._elementwise_functions import bitwise_left_shift, bitwise_right_shift
|
|
@@ -19,6 +19,8 @@ from .._dtypes import (
|
|
|
19
19
|
)
|
|
20
20
|
from .._flags import set_array_api_strict_flags
|
|
21
21
|
|
|
22
|
+
from .test_array_object import _check_op_array_scalar, BIG_INT
|
|
23
|
+
|
|
22
24
|
import array_api_strict
|
|
23
25
|
|
|
24
26
|
|
|
@@ -49,7 +51,7 @@ elementwise_function_input_types = {
|
|
|
49
51
|
"bitwise_xor": "integer or boolean",
|
|
50
52
|
"ceil": "real numeric",
|
|
51
53
|
"clip": "real numeric",
|
|
52
|
-
"conj": "
|
|
54
|
+
"conj": "numeric",
|
|
53
55
|
"copysign": "real floating-point",
|
|
54
56
|
"cos": "floating-point",
|
|
55
57
|
"cosh": "floating-point",
|
|
@@ -85,7 +87,7 @@ elementwise_function_input_types = {
|
|
|
85
87
|
"not_equal": "all",
|
|
86
88
|
"positive": "numeric",
|
|
87
89
|
"pow": "numeric",
|
|
88
|
-
"real": "
|
|
90
|
+
"real": "numeric",
|
|
89
91
|
"reciprocal": "floating-point",
|
|
90
92
|
"remainder": "real numeric",
|
|
91
93
|
"round": "numeric",
|
|
@@ -120,6 +122,7 @@ def test_missing_functions():
|
|
|
120
122
|
# Ensure the above dictionary is complete.
|
|
121
123
|
import array_api_strict._elementwise_functions as mod
|
|
122
124
|
mod_funcs = [n for n in dir(mod) if getmodule(getattr(mod, n)) is mod]
|
|
125
|
+
mod_funcs = [n for n in mod_funcs if not n.startswith("_")]
|
|
123
126
|
assert set(mod_funcs) == set(elementwise_function_input_types)
|
|
124
127
|
|
|
125
128
|
|
|
@@ -130,8 +133,7 @@ def test_function_device_persists():
|
|
|
130
133
|
yield asarray(1., dtype=d)
|
|
131
134
|
|
|
132
135
|
# Use the latest version of the standard so all functions are included
|
|
133
|
-
|
|
134
|
-
set_array_api_strict_flags(api_version="2024.12")
|
|
136
|
+
set_array_api_strict_flags(api_version="2024.12")
|
|
135
137
|
|
|
136
138
|
for func_name, types in elementwise_function_input_types.items():
|
|
137
139
|
dtypes = _dtype_categories[types]
|
|
@@ -167,8 +169,7 @@ def test_function_types():
|
|
|
167
169
|
yield asarray(1.0, dtype=d)
|
|
168
170
|
|
|
169
171
|
# Use the latest version of the standard so all functions are included
|
|
170
|
-
|
|
171
|
-
set_array_api_strict_flags(api_version="2024.12")
|
|
172
|
+
set_array_api_strict_flags(api_version="2024.12")
|
|
172
173
|
|
|
173
174
|
for x in _array_vals():
|
|
174
175
|
for func_name, types in elementwise_function_input_types.items():
|
|
@@ -202,3 +203,60 @@ def test_bitwise_shift_error():
|
|
|
202
203
|
assert_raises(
|
|
203
204
|
ValueError, lambda: bitwise_right_shift(asarray([1, 1]), asarray([1, -1]))
|
|
204
205
|
)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def test_scalars():
|
|
210
|
+
# mirror test_array_object.py::test_operators()
|
|
211
|
+
#
|
|
212
|
+
# Also check that binary functions accept (array, scalar) and (scalar, array)
|
|
213
|
+
# arguments, and reject (scalar, scalar) arguments.
|
|
214
|
+
|
|
215
|
+
# Use the latest version of the standard so that scalars are actually allowed
|
|
216
|
+
set_array_api_strict_flags(api_version="2024.12")
|
|
217
|
+
|
|
218
|
+
def _array_vals():
|
|
219
|
+
for d in _integer_dtypes:
|
|
220
|
+
yield asarray(1, dtype=d)
|
|
221
|
+
for d in _boolean_dtypes:
|
|
222
|
+
yield asarray(False, dtype=d)
|
|
223
|
+
for d in _floating_dtypes:
|
|
224
|
+
yield asarray(1.0, dtype=d)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
for func_name, dtypes in elementwise_function_input_types.items():
|
|
228
|
+
func = getattr(_elementwise_functions, func_name)
|
|
229
|
+
if nargs(func) != 2:
|
|
230
|
+
continue
|
|
231
|
+
|
|
232
|
+
nocomplex = [
|
|
233
|
+
'atan2', 'copysign', 'floor_divide', 'hypot', 'logaddexp', 'nextafter',
|
|
234
|
+
'remainder',
|
|
235
|
+
'greater', 'less', 'greater_equal', 'less_equal', 'maximum', 'minimum',
|
|
236
|
+
]
|
|
237
|
+
|
|
238
|
+
for s in [1, 1.0, 1j, BIG_INT, False]:
|
|
239
|
+
for a in _array_vals():
|
|
240
|
+
for func1 in [lambda s: func(a, s), lambda s: func(s, a)]:
|
|
241
|
+
|
|
242
|
+
if func_name in nocomplex and type(s) == complex:
|
|
243
|
+
allowed = False
|
|
244
|
+
else:
|
|
245
|
+
allowed = _check_op_array_scalar(dtypes, a, s, func1, func_name)
|
|
246
|
+
|
|
247
|
+
# only check `func(array, scalar) == `func(array, array)` if
|
|
248
|
+
# the former is legal under the promotion rules
|
|
249
|
+
if allowed:
|
|
250
|
+
conv_scalar = a._promote_scalar(s)
|
|
251
|
+
|
|
252
|
+
with suppress_warnings() as sup:
|
|
253
|
+
# ignore warnings from pow(BIG_INT)
|
|
254
|
+
sup.filter(RuntimeWarning,
|
|
255
|
+
"invalid value encountered in power")
|
|
256
|
+
assert func(s, a) == func(conv_scalar, a)
|
|
257
|
+
assert func(a, s) == func(a, conv_scalar)
|
|
258
|
+
|
|
259
|
+
with assert_raises(TypeError):
|
|
260
|
+
func(s, s)
|
|
261
|
+
|
|
262
|
+
|
|
@@ -19,7 +19,7 @@ import pytest
|
|
|
19
19
|
def test_flag_defaults():
|
|
20
20
|
flags = get_array_api_strict_flags()
|
|
21
21
|
assert flags == {
|
|
22
|
-
'api_version': '
|
|
22
|
+
'api_version': '2024.12',
|
|
23
23
|
'boolean_indexing': True,
|
|
24
24
|
'data_dependent_shapes': True,
|
|
25
25
|
'enabled_extensions': ('linalg', 'fft'),
|
|
@@ -36,7 +36,7 @@ def test_reset_flags():
|
|
|
36
36
|
reset_array_api_strict_flags()
|
|
37
37
|
flags = get_array_api_strict_flags()
|
|
38
38
|
assert flags == {
|
|
39
|
-
'api_version': '
|
|
39
|
+
'api_version': '2024.12',
|
|
40
40
|
'boolean_indexing': True,
|
|
41
41
|
'data_dependent_shapes': True,
|
|
42
42
|
'enabled_extensions': ('linalg', 'fft'),
|
|
@@ -47,7 +47,7 @@ def test_setting_flags():
|
|
|
47
47
|
set_array_api_strict_flags(data_dependent_shapes=False)
|
|
48
48
|
flags = get_array_api_strict_flags()
|
|
49
49
|
assert flags == {
|
|
50
|
-
'api_version': '
|
|
50
|
+
'api_version': '2024.12',
|
|
51
51
|
'boolean_indexing': True,
|
|
52
52
|
'data_dependent_shapes': False,
|
|
53
53
|
'enabled_extensions': ('linalg', 'fft'),
|
|
@@ -55,7 +55,7 @@ def test_setting_flags():
|
|
|
55
55
|
set_array_api_strict_flags(enabled_extensions=('fft',))
|
|
56
56
|
flags = get_array_api_strict_flags()
|
|
57
57
|
assert flags == {
|
|
58
|
-
'api_version': '
|
|
58
|
+
'api_version': '2024.12',
|
|
59
59
|
'boolean_indexing': True,
|
|
60
60
|
'data_dependent_shapes': False,
|
|
61
61
|
'enabled_extensions': ('fft',),
|
|
@@ -98,15 +98,26 @@ def test_flags_api_version_2023_12():
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
def test_flags_api_version_2024_12():
|
|
101
|
-
|
|
101
|
+
set_array_api_strict_flags(api_version='2024.12')
|
|
102
|
+
flags = get_array_api_strict_flags()
|
|
103
|
+
assert flags == {
|
|
104
|
+
'api_version': '2024.12',
|
|
105
|
+
'boolean_indexing': True,
|
|
106
|
+
'data_dependent_shapes': True,
|
|
107
|
+
'enabled_extensions': ('linalg', 'fft'),
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def test_flags_api_version_2025_12():
|
|
112
|
+
# Make sure setting the version to 2025.12 issues a warning.
|
|
102
113
|
with pytest.warns(UserWarning) as record:
|
|
103
|
-
set_array_api_strict_flags(api_version='
|
|
114
|
+
set_array_api_strict_flags(api_version='2025.12')
|
|
104
115
|
assert len(record) == 1
|
|
105
|
-
assert '
|
|
116
|
+
assert '2025.12' in str(record[0].message)
|
|
106
117
|
assert 'draft' in str(record[0].message)
|
|
107
118
|
flags = get_array_api_strict_flags()
|
|
108
119
|
assert flags == {
|
|
109
|
-
'api_version': '
|
|
120
|
+
'api_version': '2025.12',
|
|
110
121
|
'boolean_indexing': True,
|
|
111
122
|
'data_dependent_shapes': True,
|
|
112
123
|
'enabled_extensions': ('linalg', 'fft'),
|
|
@@ -125,9 +136,12 @@ def test_setting_flags_invalid():
|
|
|
125
136
|
|
|
126
137
|
def test_api_version():
|
|
127
138
|
# Test defaults
|
|
128
|
-
assert xp.__array_api_version__ == '
|
|
139
|
+
assert xp.__array_api_version__ == '2024.12'
|
|
129
140
|
|
|
130
141
|
# Test setting the version
|
|
142
|
+
set_array_api_strict_flags(api_version='2023.12')
|
|
143
|
+
assert xp.__array_api_version__ == '2023.12'
|
|
144
|
+
|
|
131
145
|
set_array_api_strict_flags(api_version='2022.12')
|
|
132
146
|
assert xp.__array_api_version__ == '2022.12'
|
|
133
147
|
|
|
@@ -307,14 +321,16 @@ api_version_2024_12_examples = {
|
|
|
307
321
|
'reciprocal': lambda: xp.reciprocal(xp.asarray([2.])),
|
|
308
322
|
'take_along_axis': lambda: xp.take_along_axis(xp.zeros((2, 3)),
|
|
309
323
|
xp.zeros((1, 4), dtype=xp.int64)),
|
|
324
|
+
'count_nonzero': lambda: xp.count_nonzero(xp.arange(3)),
|
|
325
|
+
'cumulative_prod': lambda: xp.cumulative_prod(xp.arange(1, 5)),
|
|
310
326
|
}
|
|
311
327
|
|
|
312
328
|
@pytest.mark.parametrize('func_name', api_version_2024_12_examples.keys())
|
|
313
329
|
def test_api_version_2024_12(func_name):
|
|
314
330
|
func = api_version_2024_12_examples[func_name]
|
|
315
331
|
|
|
316
|
-
# By default, these functions should error
|
|
317
|
-
|
|
332
|
+
# By default, these functions should not error
|
|
333
|
+
func()
|
|
318
334
|
|
|
319
335
|
# In 2022.12 and 2023.12, these functions should error
|
|
320
336
|
set_array_api_strict_flags(api_version='2022.12')
|
|
@@ -322,11 +338,6 @@ def test_api_version_2024_12(func_name):
|
|
|
322
338
|
set_array_api_strict_flags(api_version='2023.12')
|
|
323
339
|
pytest.raises(RuntimeError, func)
|
|
324
340
|
|
|
325
|
-
# They should not error in 2024.12
|
|
326
|
-
with pytest.warns(UserWarning):
|
|
327
|
-
set_array_api_strict_flags(api_version='2024.12')
|
|
328
|
-
func()
|
|
329
|
-
|
|
330
341
|
# Test the behavior gets updated properly
|
|
331
342
|
set_array_api_strict_flags(api_version='2023.12')
|
|
332
343
|
pytest.raises(RuntimeError, func)
|
|
@@ -433,9 +444,9 @@ def test_environment_variables():
|
|
|
433
444
|
# ARRAY_API_STRICT_API_VERSION
|
|
434
445
|
('''\
|
|
435
446
|
import array_api_strict as xp
|
|
436
|
-
assert xp.__array_api_version__ == '
|
|
447
|
+
assert xp.__array_api_version__ == '2024.12'
|
|
437
448
|
|
|
438
|
-
assert xp.get_array_api_strict_flags()['api_version'] == '
|
|
449
|
+
assert xp.get_array_api_strict_flags()['api_version'] == '2024.12'
|
|
439
450
|
|
|
440
451
|
''', {}),
|
|
441
452
|
*[
|
|
@@ -11,7 +11,7 @@ from .._manipulation_functions import (
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def test_concat_errors():
|
|
14
|
-
assert_raises(TypeError, lambda: concat((1, 1), axis=None))
|
|
14
|
+
assert_raises((TypeError, ValueError), lambda: concat((1, 1), axis=None))
|
|
15
15
|
assert_raises(TypeError, lambda: concat([asarray([1], dtype=int8),
|
|
16
16
|
asarray([1], dtype=float64)]))
|
|
17
17
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
import array_api_strict as xp
|
|
4
|
+
|
|
5
|
+
from array_api_strict import ArrayAPIStrictFlags
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_where_with_scalars():
|
|
9
|
+
x = xp.asarray([1, 2, 3, 1])
|
|
10
|
+
|
|
11
|
+
# Versions up to and including 2023.12 don't support scalar arguments
|
|
12
|
+
with ArrayAPIStrictFlags(api_version='2023.12'):
|
|
13
|
+
with pytest.raises(AttributeError, match="object has no attribute 'dtype'"):
|
|
14
|
+
xp.where(x == 1, 42, 44)
|
|
15
|
+
|
|
16
|
+
# Versions after 2023.12 support scalar arguments
|
|
17
|
+
x_where = xp.where(x == 1, xp.asarray(42), 44)
|
|
18
|
+
|
|
19
|
+
expected = xp.asarray([42, 44, 44, 42])
|
|
20
|
+
assert xp.all(x_where == expected)
|
|
21
|
+
|
|
22
|
+
# The spec does not allow both x1 and x2 to be scalars
|
|
23
|
+
with pytest.raises(TypeError, match="Two scalars"):
|
|
24
|
+
xp.where(x == 1, 42, 44)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_where_mixed_dtypes():
|
|
28
|
+
# https://github.com/data-apis/array-api-strict/issues/131
|
|
29
|
+
x = xp.asarray([1., 2.])
|
|
30
|
+
res = xp.where(x > 1.5, x, 0)
|
|
31
|
+
assert res.dtype == x.dtype
|
|
32
|
+
assert all(res == xp.asarray([0., 2.]))
|
|
33
|
+
|
|
34
|
+
# retry with boolean x1, x2
|
|
35
|
+
c = x > 1.5
|
|
36
|
+
res = xp.where(c, False, c)
|
|
37
|
+
assert all(res == xp.asarray([False, False]))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_where_f32():
|
|
41
|
+
# https://github.com/data-apis/array-api-strict/issues/131#issuecomment-2723016294
|
|
42
|
+
res = xp.where(xp.asarray([True, False]), 1., xp.asarray([2, 2], dtype=xp.float32))
|
|
43
|
+
assert res.dtype == xp.float32
|
|
44
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import cmath
|
|
1
2
|
import pytest
|
|
2
3
|
|
|
3
|
-
from .._flags import set_array_api_strict_flags
|
|
4
|
+
from .._flags import set_array_api_strict_flags, ArrayAPIStrictFlags
|
|
4
5
|
|
|
5
6
|
import array_api_strict as xp
|
|
6
7
|
|
|
@@ -37,3 +38,20 @@ def test_sum_prod_trace_2023_12(func_name):
|
|
|
37
38
|
assert func(a_real).dtype == xp.float32
|
|
38
39
|
assert func(a_complex).dtype == xp.complex64
|
|
39
40
|
assert func(a_int).dtype == xp.int64
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# mean(complex-valued array) is allowed from 2024.12 onwards
|
|
44
|
+
def test_mean_complex():
|
|
45
|
+
a = xp.asarray([1j, 2j, 3j])
|
|
46
|
+
|
|
47
|
+
with ArrayAPIStrictFlags(api_version='2023.12'):
|
|
48
|
+
with pytest.raises(TypeError):
|
|
49
|
+
xp.mean(a)
|
|
50
|
+
|
|
51
|
+
m = xp.mean(a)
|
|
52
|
+
assert cmath.isclose(complex(m), 2j)
|
|
53
|
+
|
|
54
|
+
# mean of integer arrays is still not allowed
|
|
55
|
+
with pytest.raises(TypeError):
|
|
56
|
+
xp.mean(xp.arange(3))
|
|
57
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: array_api_strict
|
|
3
|
+
Version: 2.3.1
|
|
4
|
+
Summary: A strict, minimal implementation of the Python array API standard.
|
|
5
|
+
Author: Consortium for Python Data API Standards
|
|
6
|
+
License: Copyright (c) 2021-2024, NumPy Developers, Consortium for Python Data API Standards
|
|
7
|
+
|
|
8
|
+
All rights reserved.
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without
|
|
11
|
+
modification, are permitted provided that the following conditions are
|
|
12
|
+
met:
|
|
13
|
+
|
|
14
|
+
* Redistributions of source code must retain the above copyright
|
|
15
|
+
notice, this list of conditions and the following disclaimer.
|
|
16
|
+
|
|
17
|
+
* Redistributions in binary form must reproduce the above
|
|
18
|
+
copyright notice, this list of conditions and the following
|
|
19
|
+
disclaimer in the documentation and/or other materials provided
|
|
20
|
+
with the distribution.
|
|
21
|
+
|
|
22
|
+
* Neither the name of the NumPy Developers nor the names of any
|
|
23
|
+
contributors may be used to endorse or promote products derived
|
|
24
|
+
from this software without specific prior written permission.
|
|
25
|
+
|
|
26
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
27
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
28
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
29
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
30
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
31
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
32
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
33
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
34
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
36
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37
|
+
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
44
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
45
|
+
Classifier: Operating System :: OS Independent
|
|
46
|
+
Requires-Python: >=3.9
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
License-File: LICENSE
|
|
49
|
+
Requires-Dist: numpy
|
|
50
|
+
|
|
51
|
+
# array-api-strict
|
|
52
|
+
|
|
53
|
+
`array_api_strict` is a strict, minimal implementation of the [Python array
|
|
54
|
+
API](https://data-apis.org/array-api/latest/).
|
|
55
|
+
|
|
56
|
+
The purpose of array-api-strict is to provide an implementation of the array
|
|
57
|
+
API for consuming libraries to test against so they can be completely sure
|
|
58
|
+
their usage of the array API is portable.
|
|
59
|
+
|
|
60
|
+
It is *not* intended to be used by end-users. End-users of the array API
|
|
61
|
+
should just use their favorite array library (NumPy, CuPy, PyTorch, etc.) as
|
|
62
|
+
usual. It is also not intended to be used as a dependency by consuming
|
|
63
|
+
libraries. Consuming library code should use the
|
|
64
|
+
[array-api-compat](https://data-apis.org/array-api-compat/) package to
|
|
65
|
+
support the array API. Rather, it is intended to be used in the test suites of
|
|
66
|
+
consuming libraries to test their array API usage.
|
|
67
|
+
|
|
68
|
+
See the documentation for more details https://data-apis.org/array-api-strict/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
array_api_strict/__init__.py,sha256=GDez0wXMz0GD2RvY9QF60kiueaYYOAcUTOjUhtT2xSI,7023
|
|
2
|
+
array_api_strict/_array_object.py,sha256=Ig6WJNPjYvTnf1Ry4JsSt09OfkEjcG6TYXtG_TaZ6d8,53111
|
|
3
|
+
array_api_strict/_constants.py,sha256=AYayN2jf1Dp5rXZ7WPBdUhtPBo_JMCi-pD9oW5zmFkI,87
|
|
4
|
+
array_api_strict/_creation_functions.py,sha256=sjkIVxh0gbiIgpRGwjo5_R2i4Purb2MJfAljl1v6ogY,13017
|
|
5
|
+
array_api_strict/_data_type_functions.py,sha256=FvIlbcHo0QdOHirF4Kumkm_GJ6EVSbap9uBK2fBSDRQ,8135
|
|
6
|
+
array_api_strict/_dtypes.py,sha256=UxX6e2pEBeRrd_V21bdg85Wxr94d1YUq4USrT1I8Ioo,6278
|
|
7
|
+
array_api_strict/_elementwise_functions.py,sha256=ClJ2aDwPazGW_wvYnGjzBXL-YdgY6ejkU8s_Ev8wif4,23510
|
|
8
|
+
array_api_strict/_fft.py,sha256=qm9xcjKQAxjmNuq6fgkf-49E6OHhLodyHpfPIpoHmxc,10302
|
|
9
|
+
array_api_strict/_flags.py,sha256=m3Q117wbnOmgg4fr4cBuDw5x4VAOUn05pnPrTFAZ5vk,13647
|
|
10
|
+
array_api_strict/_helpers.py,sha256=MUUbpaahyweRK-TbSp-mHUn05y-x6hSWg0N4JqBpVqs,1336
|
|
11
|
+
array_api_strict/_indexing_functions.py,sha256=3AqC8Mgi9BakrStlZoIV34d0Au5dMk6qT07TxpvvCGk,1520
|
|
12
|
+
array_api_strict/_info.py,sha256=QvW1PV7dO2oGPWAerG3wJn61QAqjqxx4iHkWPUturI4,4455
|
|
13
|
+
array_api_strict/_linalg.py,sha256=sfmd5fuq2nHy_9kD2QQ23_JbbVZo7LHFgb10qjrr7nw,19846
|
|
14
|
+
array_api_strict/_linear_algebra_functions.py,sha256=FNvaEbiOL4HkHpTtav9OvEFsSrv-6ezaqeajRPALn1Y,3881
|
|
15
|
+
array_api_strict/_manipulation_functions.py,sha256=njyE4GiGsjLL-wNC8Uw4hk9H6bLaEUneyn2DAYB6TDM,6878
|
|
16
|
+
array_api_strict/_searching_functions.py,sha256=7dxQPuKq8-TV260mxLCBjTMvzF03h0TDvEMdkMcVP-I,4106
|
|
17
|
+
array_api_strict/_set_functions.py,sha256=PZVsxkRQi5Zi104dI2fHZBFqpluOAW0IJzzdJSyajiI,3295
|
|
18
|
+
array_api_strict/_sorting_functions.py,sha256=GG7g2NYCFn2G2fFS6ZdfYOWpuuSIrdZdJWEuL72_-LI,2065
|
|
19
|
+
array_api_strict/_statistical_functions.py,sha256=I_nNZyv4aKRmrJjdsw0PJZCtQ-TgKuMyaBMWbSioTlI,6237
|
|
20
|
+
array_api_strict/_typing.py,sha256=oaHM01VhgC5JIHxXMouEEajNs0OXtwOasnIznK7z9fk,1889
|
|
21
|
+
array_api_strict/_utility_functions.py,sha256=Mu07FogReaAFToPMHE_j90YBEDEvxD5jPcMK3zeUiG0,2007
|
|
22
|
+
array_api_strict/_version.py,sha256=4lLWfgycoQE7rafXKcKQeSzbG6DAo6_kH0qn9J_0diQ,511
|
|
23
|
+
array_api_strict/tests/__init__.py,sha256=t_2GZ3lKcsu4ec4GMKPUDYaeMUJyDquBlQAcPgj7kFE,282
|
|
24
|
+
array_api_strict/tests/conftest.py,sha256=-wIDryl2MdRLdSonU1G1xWssNq2TFKiWuHquNasXYA8,468
|
|
25
|
+
array_api_strict/tests/test_array_object.py,sha256=N84q_642ypibxihmRssWth4eHPs8AbpQrktCbZDipIc,23567
|
|
26
|
+
array_api_strict/tests/test_creation_functions.py,sha256=qPflQZN4Bc1aGwTPqodSNcEdvXjvOeNp59cvxUGq0lg,8515
|
|
27
|
+
array_api_strict/tests/test_data_type_functions.py,sha256=1zQ4qkA6x9GWB-OQuAr9ndpUcocfNY95W8Zt4iC4Kgs,2860
|
|
28
|
+
array_api_strict/tests/test_device_support.py,sha256=zpfhHxeRREoXfp0qZTlilm2ZceBc71uCKea1GMVe-ZU,855
|
|
29
|
+
array_api_strict/tests/test_elementwise_functions.py,sha256=K2bUKe-YZOR-T0G-Kz2xtgNr06xKi_ks0uk8v_rJziQ,9293
|
|
30
|
+
array_api_strict/tests/test_flags.py,sha256=kcBbFB4aq3XY_9HM1j3wKmq8MVNfU4YxwK21mARM0iw,18982
|
|
31
|
+
array_api_strict/tests/test_indexing_functions.py,sha256=C23FnuowVDC1OBuDH06pvsd61qM2dTpTwzw6UgC4BoY,1281
|
|
32
|
+
array_api_strict/tests/test_linalg.py,sha256=CJ4JnCkWyysMUAih3PI-ZZeOH-X39H0p-RKBoEwk6Jw,5675
|
|
33
|
+
array_api_strict/tests/test_manipulation_functions.py,sha256=Yc92IvA3FaTZueqAUOFMkx3MH4PXCHDof7ckrJxudQs,1078
|
|
34
|
+
array_api_strict/tests/test_searching_functions.py,sha256=ivDcpggiQkSdGVqboJmwczj3Zfmgojp86tNWJphxB0k,1352
|
|
35
|
+
array_api_strict/tests/test_set_functions.py,sha256=ikzab1j3SXxGf0OqwHrOAM13HwQetdhtB60Zc_gc1DE,542
|
|
36
|
+
array_api_strict/tests/test_sorting_functions.py,sha256=1xvQBKts5KTKYc-puMITX9iR_KTbzzVB8fY-SObad_Y,899
|
|
37
|
+
array_api_strict/tests/test_statistical_functions.py,sha256=0ihnw4W9vOqU6RMBOUw29Fg-xumXpfz0h05v0E0RsMQ,1814
|
|
38
|
+
array_api_strict/tests/test_validation.py,sha256=Dtl-kGRtdslaPVWWtr3rBrIsJPuj7LZz6_pw2yjwkWE,674
|
|
39
|
+
array_api_strict-2.3.1.dist-info/LICENSE,sha256=djDm4UfHAJmycwFUNyUmrTdRkrFF9Ac8uqIlbxH7j5Y,1585
|
|
40
|
+
array_api_strict-2.3.1.dist-info/METADATA,sha256=VURFsgnmY7crtgcQGW8mXfQzlD_YMZoFXP2WmYokTdI,3425
|
|
41
|
+
array_api_strict-2.3.1.dist-info/WHEEL,sha256=5Mi1sN9lKoFv_gxcPtisEVrJZihrm_beibeg5R6xb4I,91
|
|
42
|
+
array_api_strict-2.3.1.dist-info/top_level.txt,sha256=M4cE8VLgRHp_d9TPkbk7_I4JriELFdEJz-NKJJqAkAE,17
|
|
43
|
+
array_api_strict-2.3.1.dist-info/RECORD,,
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: array_api_strict
|
|
3
|
-
Version: 2.2
|
|
4
|
-
Summary: A strict, minimal implementation of the Python array API standard.
|
|
5
|
-
Home-page: https://data-apis.org/array-api-strict/
|
|
6
|
-
Author: Consortium for Python Data API Standards
|
|
7
|
-
License: MIT
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
14
|
-
Classifier: Operating System :: OS Independent
|
|
15
|
-
Requires-Python: >=3.9
|
|
16
|
-
Description-Content-Type: text/markdown
|
|
17
|
-
License-File: LICENSE
|
|
18
|
-
Requires-Dist: numpy
|
|
19
|
-
|
|
20
|
-
# array-api-strict
|
|
21
|
-
|
|
22
|
-
`array_api_strict` is a strict, minimal implementation of the [Python array
|
|
23
|
-
API](https://data-apis.org/array-api/latest/).
|
|
24
|
-
|
|
25
|
-
The purpose of array-api-strict is to provide an implementation of the array
|
|
26
|
-
API for consuming libraries to test against so they can be completely sure
|
|
27
|
-
their usage of the array API is portable.
|
|
28
|
-
|
|
29
|
-
It is *not* intended to be used by end-users. End-users of the array API
|
|
30
|
-
should just use their favorite array library (NumPy, CuPy, PyTorch, etc.) as
|
|
31
|
-
usual. It is also not intended to be used as a dependency by consuming
|
|
32
|
-
libraries. Consuming library code should use the
|
|
33
|
-
[array-api-compat](https://data-apis.org/array-api-compat/) package to
|
|
34
|
-
support the array API. Rather, it is intended to be used in the test suites of
|
|
35
|
-
consuming libraries to test their array API usage.
|
|
36
|
-
|
|
37
|
-
See the documentation for more details https://data-apis.org/array-api-strict/
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
array_api_strict/__init__.py,sha256=Nm_8GFfA0bpkVMw3urULYSadngGPaW6C2VuEpM-ziyI,6904
|
|
2
|
-
array_api_strict/_array_object.py,sha256=Q69HJ8qdQqqugWIRf4RsifZUEypbhNV_y5EVSygmbrQ,52571
|
|
3
|
-
array_api_strict/_constants.py,sha256=AYayN2jf1Dp5rXZ7WPBdUhtPBo_JMCi-pD9oW5zmFkI,87
|
|
4
|
-
array_api_strict/_creation_functions.py,sha256=A9TTvPSznF9NsxT0Pd_G9yU6IZAfW1tpBkFMYoJyguw,12985
|
|
5
|
-
array_api_strict/_data_type_functions.py,sha256=sKxKRQiwoXPwQJPbiN5BhF9rbc3ZtXfjRuglB7VsIgo,7016
|
|
6
|
-
array_api_strict/_dtypes.py,sha256=QDGo9rqiS_o3quv7QRFM0j6DkvOjRauQ1Ymikwlu8Ns,6213
|
|
7
|
-
array_api_strict/_elementwise_functions.py,sha256=epo92ppRP4XDcDhS431J599NA1pT4DK08wIdV9vVO8s,39713
|
|
8
|
-
array_api_strict/_fft.py,sha256=xH1o4j_amq3e1yGVChV6vms7oAfCzpzB18I-IzjNSXw,9702
|
|
9
|
-
array_api_strict/_flags.py,sha256=lUb-SowhHvA9MLBm0ICO5L7M7FgclWPF8v8z5N--Q_o,13558
|
|
10
|
-
array_api_strict/_indexing_functions.py,sha256=3AqC8Mgi9BakrStlZoIV34d0Au5dMk6qT07TxpvvCGk,1520
|
|
11
|
-
array_api_strict/_info.py,sha256=QvW1PV7dO2oGPWAerG3wJn61QAqjqxx4iHkWPUturI4,4455
|
|
12
|
-
array_api_strict/_linalg.py,sha256=sfmd5fuq2nHy_9kD2QQ23_JbbVZo7LHFgb10qjrr7nw,19846
|
|
13
|
-
array_api_strict/_linear_algebra_functions.py,sha256=12XPBU27X3WZdaq9Ob2eUmL_PxMzDNF76pY4iESlPyo,3872
|
|
14
|
-
array_api_strict/_manipulation_functions.py,sha256=Pa1gVRlaSC39-Zd6n4Q8c9P0anZYdyCh95Wyx3az3lc,6681
|
|
15
|
-
array_api_strict/_searching_functions.py,sha256=32IiLLpa91N-jtzaxj4Nw9nQgF2ROkcNZ-XH6WQQUHY,3233
|
|
16
|
-
array_api_strict/_set_functions.py,sha256=PZVsxkRQi5Zi104dI2fHZBFqpluOAW0IJzzdJSyajiI,3295
|
|
17
|
-
array_api_strict/_sorting_functions.py,sha256=GG7g2NYCFn2G2fFS6ZdfYOWpuuSIrdZdJWEuL72_-LI,2065
|
|
18
|
-
array_api_strict/_statistical_functions.py,sha256=dMJ-x8TQW5MD2rFYCmRH6QthA2KDKXjhkj4hcbd3LSU,5148
|
|
19
|
-
array_api_strict/_typing.py,sha256=oaHM01VhgC5JIHxXMouEEajNs0OXtwOasnIznK7z9fk,1889
|
|
20
|
-
array_api_strict/_utility_functions.py,sha256=Mu07FogReaAFToPMHE_j90YBEDEvxD5jPcMK3zeUiG0,2007
|
|
21
|
-
array_api_strict/_version.py,sha256=20M94v12DlLnRLp4vkFO-TkQKxHY21bls4ZgOvbf7jE,495
|
|
22
|
-
array_api_strict/tests/__init__.py,sha256=t_2GZ3lKcsu4ec4GMKPUDYaeMUJyDquBlQAcPgj7kFE,282
|
|
23
|
-
array_api_strict/tests/conftest.py,sha256=-wIDryl2MdRLdSonU1G1xWssNq2TFKiWuHquNasXYA8,468
|
|
24
|
-
array_api_strict/tests/test_array_object.py,sha256=IzfVo63eiPoFFwb4woNT15e4gJFfYVyD7zK-wddRMBY,21865
|
|
25
|
-
array_api_strict/tests/test_creation_functions.py,sha256=ve0MeqZPrG2dmCG3hTVhap1YgIW-lAaSZIJ_ZoOV9cQ,8323
|
|
26
|
-
array_api_strict/tests/test_data_type_functions.py,sha256=pLAtm96gpAduNVqq-914JvjAollzhBp4YojVfNScBzs,2138
|
|
27
|
-
array_api_strict/tests/test_device_support.py,sha256=zpfhHxeRREoXfp0qZTlilm2ZceBc71uCKea1GMVe-ZU,855
|
|
28
|
-
array_api_strict/tests/test_elementwise_functions.py,sha256=ManUmYZF3oT-UXH4lqWJna3zDHdxVBeuvIdFlFPABQ4,7114
|
|
29
|
-
array_api_strict/tests/test_flags.py,sha256=YadbyJEu7DmMo3TKl3nROf7R4xDIrQfm8acifHA3CYc,18598
|
|
30
|
-
array_api_strict/tests/test_indexing_functions.py,sha256=C23FnuowVDC1OBuDH06pvsd61qM2dTpTwzw6UgC4BoY,1281
|
|
31
|
-
array_api_strict/tests/test_linalg.py,sha256=CJ4JnCkWyysMUAih3PI-ZZeOH-X39H0p-RKBoEwk6Jw,5675
|
|
32
|
-
array_api_strict/tests/test_manipulation_functions.py,sha256=CzcudVxUKhQ4Ec94Vda4C6HaAqrOQPQfQxT4uTM2fsM,1064
|
|
33
|
-
array_api_strict/tests/test_set_functions.py,sha256=ikzab1j3SXxGf0OqwHrOAM13HwQetdhtB60Zc_gc1DE,542
|
|
34
|
-
array_api_strict/tests/test_sorting_functions.py,sha256=1xvQBKts5KTKYc-puMITX9iR_KTbzzVB8fY-SObad_Y,899
|
|
35
|
-
array_api_strict/tests/test_statistical_functions.py,sha256=JwS4DhASt5T0YUNtbFK2nSXgDrVVZx1tVpe7LU2aPK4,1365
|
|
36
|
-
array_api_strict/tests/test_validation.py,sha256=JdsK4z1M0U5YoJrfWSzOpEhmlehvZHF5SG0I0k6oDy8,672
|
|
37
|
-
array_api_strict-2.2.dist-info/LICENSE,sha256=djDm4UfHAJmycwFUNyUmrTdRkrFF9Ac8uqIlbxH7j5Y,1585
|
|
38
|
-
array_api_strict-2.2.dist-info/METADATA,sha256=uCWtV4ZiiCzUkNRWapj10LpJxUCPHy8fzddfOiFt2cM,1593
|
|
39
|
-
array_api_strict-2.2.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
|
|
40
|
-
array_api_strict-2.2.dist-info/top_level.txt,sha256=M4cE8VLgRHp_d9TPkbk7_I4JriELFdEJz-NKJJqAkAE,17
|
|
41
|
-
array_api_strict-2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|