assassinlike commited on
Commit
b42e4d3
·
verified ·
1 Parent(s): 3867446

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/__init__.cpython-310.pyc +0 -0
  2. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_array_object.cpython-310.pyc +0 -0
  3. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_constants.cpython-310.pyc +0 -0
  4. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_creation_functions.cpython-310.pyc +0 -0
  5. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_data_type_functions.cpython-310.pyc +0 -0
  6. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_dtypes.cpython-310.pyc +0 -0
  7. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_elementwise_functions.cpython-310.pyc +0 -0
  8. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_indexing_functions.cpython-310.pyc +0 -0
  9. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_manipulation_functions.cpython-310.pyc +0 -0
  10. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_searching_functions.cpython-310.pyc +0 -0
  11. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_set_functions.cpython-310.pyc +0 -0
  12. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_sorting_functions.cpython-310.pyc +0 -0
  13. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_statistical_functions.cpython-310.pyc +0 -0
  14. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_typing.cpython-310.pyc +0 -0
  15. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_utility_functions.cpython-310.pyc +0 -0
  16. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/linalg.cpython-310.pyc +0 -0
  17. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/setup.cpython-310.pyc +0 -0
  18. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__init__.py +7 -0
  19. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  20. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_array_object.cpython-310.pyc +0 -0
  21. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_creation_functions.cpython-310.pyc +0 -0
  22. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_data_type_functions.cpython-310.pyc +0 -0
  23. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_elementwise_functions.cpython-310.pyc +0 -0
  24. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_indexing_functions.cpython-310.pyc +0 -0
  25. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_manipulation_functions.cpython-310.pyc +0 -0
  26. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_set_functions.cpython-310.pyc +0 -0
  27. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_sorting_functions.cpython-310.pyc +0 -0
  28. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_validation.cpython-310.pyc +0 -0
  29. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_array_object.py +395 -0
  30. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_creation_functions.py +142 -0
  31. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_data_type_functions.py +31 -0
  32. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_elementwise_functions.py +114 -0
  33. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_indexing_functions.py +24 -0
  34. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_manipulation_functions.py +37 -0
  35. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_set_functions.py +19 -0
  36. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_sorting_functions.py +23 -0
  37. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_validation.py +27 -0
  38. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/__init__.cpython-310.pyc +0 -0
  39. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_add_newdocs_scalars.cpython-310.pyc +0 -0
  40. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_asarray.cpython-310.pyc +0 -0
  41. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_dtype.cpython-310.pyc +0 -0
  42. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_dtype_ctypes.cpython-310.pyc +0 -0
  43. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_exceptions.cpython-310.pyc +0 -0
  44. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_internal.cpython-310.pyc +0 -0
  45. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_machar.cpython-310.pyc +0 -0
  46. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_methods.cpython-310.pyc +0 -0
  47. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_string_helpers.cpython-310.pyc +0 -0
  48. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_type_aliases.cpython-310.pyc +0 -0
  49. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/arrayprint.cpython-310.pyc +0 -0
  50. data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/cversions.cpython-310.pyc +0 -0
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (9.88 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_array_object.cpython-310.pyc ADDED
Binary file (28.4 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_constants.cpython-310.pyc ADDED
Binary file (278 Bytes). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_creation_functions.cpython-310.pyc ADDED
Binary file (8.49 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_data_type_functions.cpython-310.pyc ADDED
Binary file (5.83 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_dtypes.cpython-310.pyc ADDED
Binary file (2.52 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_elementwise_functions.cpython-310.pyc ADDED
Binary file (19.7 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_indexing_functions.cpython-310.pyc ADDED
Binary file (993 Bytes). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_manipulation_functions.cpython-310.pyc ADDED
Binary file (3.7 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_searching_functions.cpython-310.pyc ADDED
Binary file (2.16 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_set_functions.cpython-310.pyc ADDED
Binary file (2.27 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_sorting_functions.cpython-310.pyc ADDED
Binary file (1.57 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_statistical_functions.cpython-310.pyc ADDED
Binary file (2.77 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_typing.cpython-310.pyc ADDED
Binary file (2.07 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/_utility_functions.cpython-310.pyc ADDED
Binary file (1.08 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/linalg.cpython-310.pyc ADDED
Binary file (13.4 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/__pycache__/setup.cpython-310.pyc ADDED
Binary file (572 Bytes). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ """
2
+ Tests for the array API namespace.
3
+
4
+ Note, full compliance with the array API can be tested with the official array API test
5
+ suite https://github.com/data-apis/array-api-tests. This test suite primarily
6
+ focuses on those things that are not tested by the official test suite.
7
+ """
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (485 Bytes). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_array_object.cpython-310.pyc ADDED
Binary file (14.8 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_creation_functions.cpython-310.pyc ADDED
Binary file (8.13 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_data_type_functions.cpython-310.pyc ADDED
Binary file (1.36 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_elementwise_functions.cpython-310.pyc ADDED
Binary file (3.19 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_indexing_functions.cpython-310.pyc ADDED
Binary file (861 Bytes). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_manipulation_functions.cpython-310.pyc ADDED
Binary file (1.78 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_set_functions.cpython-310.pyc ADDED
Binary file (840 Bytes). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_sorting_functions.cpython-310.pyc ADDED
Binary file (857 Bytes). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/__pycache__/test_validation.cpython-310.pyc ADDED
Binary file (1.23 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_array_object.py ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import operator
2
+
3
+ from numpy.testing import assert_raises, suppress_warnings
4
+ import numpy as np
5
+ import pytest
6
+
7
+ from .. import ones, asarray, reshape, result_type, all, equal
8
+ from .._array_object import Array
9
+ from .._dtypes import (
10
+ _all_dtypes,
11
+ _boolean_dtypes,
12
+ _real_floating_dtypes,
13
+ _floating_dtypes,
14
+ _complex_floating_dtypes,
15
+ _integer_dtypes,
16
+ _integer_or_boolean_dtypes,
17
+ _real_numeric_dtypes,
18
+ _numeric_dtypes,
19
+ int8,
20
+ int16,
21
+ int32,
22
+ int64,
23
+ uint64,
24
+ bool as bool_,
25
+ )
26
+
27
+
28
+ def test_validate_index():
29
+ # The indexing tests in the official array API test suite test that the
30
+ # array object correctly handles the subset of indices that are required
31
+ # by the spec. But the NumPy array API implementation specifically
32
+ # disallows any index not required by the spec, via Array._validate_index.
33
+ # This test focuses on testing that non-valid indices are correctly
34
+ # rejected. See
35
+ # https://data-apis.org/array-api/latest/API_specification/indexing.html
36
+ # and the docstring of Array._validate_index for the exact indexing
37
+ # behavior that should be allowed. This does not test indices that are
38
+ # already invalid in NumPy itself because Array will generally just pass
39
+ # such indices directly to the underlying np.ndarray.
40
+
41
+ a = ones((3, 4))
42
+
43
+ # Out of bounds slices are not allowed
44
+ assert_raises(IndexError, lambda: a[:4])
45
+ assert_raises(IndexError, lambda: a[:-4])
46
+ assert_raises(IndexError, lambda: a[:3:-1])
47
+ assert_raises(IndexError, lambda: a[:-5:-1])
48
+ assert_raises(IndexError, lambda: a[4:])
49
+ assert_raises(IndexError, lambda: a[-4:])
50
+ assert_raises(IndexError, lambda: a[4::-1])
51
+ assert_raises(IndexError, lambda: a[-4::-1])
52
+
53
+ assert_raises(IndexError, lambda: a[...,:5])
54
+ assert_raises(IndexError, lambda: a[...,:-5])
55
+ assert_raises(IndexError, lambda: a[...,:5:-1])
56
+ assert_raises(IndexError, lambda: a[...,:-6:-1])
57
+ assert_raises(IndexError, lambda: a[...,5:])
58
+ assert_raises(IndexError, lambda: a[...,-5:])
59
+ assert_raises(IndexError, lambda: a[...,5::-1])
60
+ assert_raises(IndexError, lambda: a[...,-5::-1])
61
+
62
+ # Boolean indices cannot be part of a larger tuple index
63
+ assert_raises(IndexError, lambda: a[a[:,0]==1,0])
64
+ assert_raises(IndexError, lambda: a[a[:,0]==1,...])
65
+ assert_raises(IndexError, lambda: a[..., a[0]==1])
66
+ assert_raises(IndexError, lambda: a[[True, True, True]])
67
+ assert_raises(IndexError, lambda: a[(True, True, True),])
68
+
69
+ # Integer array indices are not allowed (except for 0-D)
70
+ idx = asarray([[0, 1]])
71
+ assert_raises(IndexError, lambda: a[idx])
72
+ assert_raises(IndexError, lambda: a[idx,])
73
+ assert_raises(IndexError, lambda: a[[0, 1]])
74
+ assert_raises(IndexError, lambda: a[(0, 1), (0, 1)])
75
+ assert_raises(IndexError, lambda: a[[0, 1]])
76
+ assert_raises(IndexError, lambda: a[np.array([[0, 1]])])
77
+
78
+ # Multiaxis indices must contain exactly as many indices as dimensions
79
+ assert_raises(IndexError, lambda: a[()])
80
+ assert_raises(IndexError, lambda: a[0,])
81
+ assert_raises(IndexError, lambda: a[0])
82
+ assert_raises(IndexError, lambda: a[:])
83
+
84
+ def test_operators():
85
+ # For every operator, we test that it works for the required type
86
+ # combinations and raises TypeError otherwise
87
+ binary_op_dtypes = {
88
+ "__add__": "numeric",
89
+ "__and__": "integer_or_boolean",
90
+ "__eq__": "all",
91
+ "__floordiv__": "real numeric",
92
+ "__ge__": "real numeric",
93
+ "__gt__": "real numeric",
94
+ "__le__": "real numeric",
95
+ "__lshift__": "integer",
96
+ "__lt__": "real numeric",
97
+ "__mod__": "real numeric",
98
+ "__mul__": "numeric",
99
+ "__ne__": "all",
100
+ "__or__": "integer_or_boolean",
101
+ "__pow__": "numeric",
102
+ "__rshift__": "integer",
103
+ "__sub__": "numeric",
104
+ "__truediv__": "floating",
105
+ "__xor__": "integer_or_boolean",
106
+ }
107
+ # Recompute each time because of in-place ops
108
+ def _array_vals():
109
+ for d in _integer_dtypes:
110
+ yield asarray(1, dtype=d)
111
+ for d in _boolean_dtypes:
112
+ yield asarray(False, dtype=d)
113
+ for d in _floating_dtypes:
114
+ yield asarray(1.0, dtype=d)
115
+
116
+
117
+ BIG_INT = int(1e30)
118
+ for op, dtypes in binary_op_dtypes.items():
119
+ ops = [op]
120
+ if op not in ["__eq__", "__ne__", "__le__", "__ge__", "__lt__", "__gt__"]:
121
+ rop = "__r" + op[2:]
122
+ iop = "__i" + op[2:]
123
+ ops += [rop, iop]
124
+ for s in [1, 1.0, 1j, BIG_INT, False]:
125
+ for _op in ops:
126
+ for a in _array_vals():
127
+ # Test array op scalar. From the spec, the following combinations
128
+ # are supported:
129
+
130
+ # - Python bool for a bool array dtype,
131
+ # - a Python int within the bounds of the given dtype for integer array dtypes,
132
+ # - a Python int or float for real floating-point array dtypes
133
+ # - a Python int, float, or complex for complex floating-point array dtypes
134
+
135
+ if ((dtypes == "all"
136
+ or dtypes == "numeric" and a.dtype in _numeric_dtypes
137
+ or dtypes == "real numeric" and a.dtype in _real_numeric_dtypes
138
+ or dtypes == "integer" and a.dtype in _integer_dtypes
139
+ or dtypes == "integer_or_boolean" and a.dtype in _integer_or_boolean_dtypes
140
+ or dtypes == "boolean" and a.dtype in _boolean_dtypes
141
+ or dtypes == "floating" and a.dtype in _floating_dtypes
142
+ )
143
+ # bool is a subtype of int, which is why we avoid
144
+ # isinstance here.
145
+ and (a.dtype in _boolean_dtypes and type(s) == bool
146
+ or a.dtype in _integer_dtypes and type(s) == int
147
+ or a.dtype in _real_floating_dtypes and type(s) in [float, int]
148
+ or a.dtype in _complex_floating_dtypes and type(s) in [complex, float, int]
149
+ )):
150
+ if a.dtype in _integer_dtypes and s == BIG_INT:
151
+ assert_raises(OverflowError, lambda: getattr(a, _op)(s))
152
+ else:
153
+ # Only test for no error
154
+ with suppress_warnings() as sup:
155
+ # ignore warnings from pow(BIG_INT)
156
+ sup.filter(RuntimeWarning,
157
+ "invalid value encountered in power")
158
+ getattr(a, _op)(s)
159
+ else:
160
+ assert_raises(TypeError, lambda: getattr(a, _op)(s))
161
+
162
+ # Test array op array.
163
+ for _op in ops:
164
+ for x in _array_vals():
165
+ for y in _array_vals():
166
+ # See the promotion table in NEP 47 or the array
167
+ # API spec page on type promotion. Mixed kind
168
+ # promotion is not defined.
169
+ if (x.dtype == uint64 and y.dtype in [int8, int16, int32, int64]
170
+ or y.dtype == uint64 and x.dtype in [int8, int16, int32, int64]
171
+ or x.dtype in _integer_dtypes and y.dtype not in _integer_dtypes
172
+ or y.dtype in _integer_dtypes and x.dtype not in _integer_dtypes
173
+ or x.dtype in _boolean_dtypes and y.dtype not in _boolean_dtypes
174
+ or y.dtype in _boolean_dtypes and x.dtype not in _boolean_dtypes
175
+ or x.dtype in _floating_dtypes and y.dtype not in _floating_dtypes
176
+ or y.dtype in _floating_dtypes and x.dtype not in _floating_dtypes
177
+ ):
178
+ assert_raises(TypeError, lambda: getattr(x, _op)(y))
179
+ # Ensure in-place operators only promote to the same dtype as the left operand.
180
+ elif (
181
+ _op.startswith("__i")
182
+ and result_type(x.dtype, y.dtype) != x.dtype
183
+ ):
184
+ assert_raises(TypeError, lambda: getattr(x, _op)(y))
185
+ # Ensure only those dtypes that are required for every operator are allowed.
186
+ elif (dtypes == "all" and (x.dtype in _boolean_dtypes and y.dtype in _boolean_dtypes
187
+ or x.dtype in _numeric_dtypes and y.dtype in _numeric_dtypes)
188
+ or (dtypes == "real numeric" and x.dtype in _real_numeric_dtypes and y.dtype in _real_numeric_dtypes)
189
+ or (dtypes == "numeric" and x.dtype in _numeric_dtypes and y.dtype in _numeric_dtypes)
190
+ or dtypes == "integer" and x.dtype in _integer_dtypes and y.dtype in _integer_dtypes
191
+ or dtypes == "integer_or_boolean" and (x.dtype in _integer_dtypes and y.dtype in _integer_dtypes
192
+ or x.dtype in _boolean_dtypes and y.dtype in _boolean_dtypes)
193
+ or dtypes == "boolean" and x.dtype in _boolean_dtypes and y.dtype in _boolean_dtypes
194
+ or dtypes == "floating" and x.dtype in _floating_dtypes and y.dtype in _floating_dtypes
195
+ ):
196
+ getattr(x, _op)(y)
197
+ else:
198
+ assert_raises(TypeError, lambda: getattr(x, _op)(y))
199
+
200
+ unary_op_dtypes = {
201
+ "__abs__": "numeric",
202
+ "__invert__": "integer_or_boolean",
203
+ "__neg__": "numeric",
204
+ "__pos__": "numeric",
205
+ }
206
+ for op, dtypes in unary_op_dtypes.items():
207
+ for a in _array_vals():
208
+ if (
209
+ dtypes == "numeric"
210
+ and a.dtype in _numeric_dtypes
211
+ or dtypes == "integer_or_boolean"
212
+ and a.dtype in _integer_or_boolean_dtypes
213
+ ):
214
+ # Only test for no error
215
+ getattr(a, op)()
216
+ else:
217
+ assert_raises(TypeError, lambda: getattr(a, op)())
218
+
219
+ # Finally, matmul() must be tested separately, because it works a bit
220
+ # different from the other operations.
221
+ def _matmul_array_vals():
222
+ for a in _array_vals():
223
+ yield a
224
+ for d in _all_dtypes:
225
+ yield ones((3, 4), dtype=d)
226
+ yield ones((4, 2), dtype=d)
227
+ yield ones((4, 4), dtype=d)
228
+
229
+ # Scalars always error
230
+ for _op in ["__matmul__", "__rmatmul__", "__imatmul__"]:
231
+ for s in [1, 1.0, False]:
232
+ for a in _matmul_array_vals():
233
+ if (type(s) in [float, int] and a.dtype in _floating_dtypes
234
+ or type(s) == int and a.dtype in _integer_dtypes):
235
+ # Type promotion is valid, but @ is not allowed on 0-D
236
+ # inputs, so the error is a ValueError
237
+ assert_raises(ValueError, lambda: getattr(a, _op)(s))
238
+ else:
239
+ assert_raises(TypeError, lambda: getattr(a, _op)(s))
240
+
241
+ for x in _matmul_array_vals():
242
+ for y in _matmul_array_vals():
243
+ if (x.dtype == uint64 and y.dtype in [int8, int16, int32, int64]
244
+ or y.dtype == uint64 and x.dtype in [int8, int16, int32, int64]
245
+ or x.dtype in _integer_dtypes and y.dtype not in _integer_dtypes
246
+ or y.dtype in _integer_dtypes and x.dtype not in _integer_dtypes
247
+ or x.dtype in _floating_dtypes and y.dtype not in _floating_dtypes
248
+ or y.dtype in _floating_dtypes and x.dtype not in _floating_dtypes
249
+ or x.dtype in _boolean_dtypes
250
+ or y.dtype in _boolean_dtypes
251
+ ):
252
+ assert_raises(TypeError, lambda: x.__matmul__(y))
253
+ assert_raises(TypeError, lambda: y.__rmatmul__(x))
254
+ assert_raises(TypeError, lambda: x.__imatmul__(y))
255
+ elif x.shape == () or y.shape == () or x.shape[1] != y.shape[0]:
256
+ assert_raises(ValueError, lambda: x.__matmul__(y))
257
+ assert_raises(ValueError, lambda: y.__rmatmul__(x))
258
+ if result_type(x.dtype, y.dtype) != x.dtype:
259
+ assert_raises(TypeError, lambda: x.__imatmul__(y))
260
+ else:
261
+ assert_raises(ValueError, lambda: x.__imatmul__(y))
262
+ else:
263
+ x.__matmul__(y)
264
+ y.__rmatmul__(x)
265
+ if result_type(x.dtype, y.dtype) != x.dtype:
266
+ assert_raises(TypeError, lambda: x.__imatmul__(y))
267
+ elif y.shape[0] != y.shape[1]:
268
+ # This one fails because x @ y has a different shape from x
269
+ assert_raises(ValueError, lambda: x.__imatmul__(y))
270
+ else:
271
+ x.__imatmul__(y)
272
+
273
+
274
+ def test_python_scalar_construtors():
275
+ b = asarray(False)
276
+ i = asarray(0)
277
+ f = asarray(0.0)
278
+ c = asarray(0j)
279
+
280
+ assert bool(b) == False
281
+ assert int(i) == 0
282
+ assert float(f) == 0.0
283
+ assert operator.index(i) == 0
284
+
285
+ # bool/int/float/complex should only be allowed on 0-D arrays.
286
+ assert_raises(TypeError, lambda: bool(asarray([False])))
287
+ assert_raises(TypeError, lambda: int(asarray([0])))
288
+ assert_raises(TypeError, lambda: float(asarray([0.0])))
289
+ assert_raises(TypeError, lambda: complex(asarray([0j])))
290
+ assert_raises(TypeError, lambda: operator.index(asarray([0])))
291
+
292
+ # bool should work on all types of arrays
293
+ assert bool(b) is bool(i) is bool(f) is bool(c) is False
294
+
295
+ # int should fail on complex arrays
296
+ assert int(b) == int(i) == int(f) == 0
297
+ assert_raises(TypeError, lambda: int(c))
298
+
299
+ # float should fail on complex arrays
300
+ assert float(b) == float(i) == float(f) == 0.0
301
+ assert_raises(TypeError, lambda: float(c))
302
+
303
+ # complex should work on all types of arrays
304
+ assert complex(b) == complex(i) == complex(f) == complex(c) == 0j
305
+
306
+ # index should only work on integer arrays
307
+ assert operator.index(i) == 0
308
+ assert_raises(TypeError, lambda: operator.index(b))
309
+ assert_raises(TypeError, lambda: operator.index(f))
310
+ assert_raises(TypeError, lambda: operator.index(c))
311
+
312
+
313
+ def test_device_property():
314
+ a = ones((3, 4))
315
+ assert a.device == 'cpu'
316
+
317
+ assert all(equal(a.to_device('cpu'), a))
318
+ assert_raises(ValueError, lambda: a.to_device('gpu'))
319
+
320
+ assert all(equal(asarray(a, device='cpu'), a))
321
+ assert_raises(ValueError, lambda: asarray(a, device='gpu'))
322
+
323
+ def test_array_properties():
324
+ a = ones((1, 2, 3))
325
+ b = ones((2, 3))
326
+ assert_raises(ValueError, lambda: a.T)
327
+
328
+ assert isinstance(b.T, Array)
329
+ assert b.T.shape == (3, 2)
330
+
331
+ assert isinstance(a.mT, Array)
332
+ assert a.mT.shape == (1, 3, 2)
333
+ assert isinstance(b.mT, Array)
334
+ assert b.mT.shape == (3, 2)
335
+
336
+ def test___array__():
337
+ a = ones((2, 3), dtype=int16)
338
+ assert np.asarray(a) is a._array
339
+ b = np.asarray(a, dtype=np.float64)
340
+ assert np.all(np.equal(b, np.ones((2, 3), dtype=np.float64)))
341
+ assert b.dtype == np.float64
342
+
343
+ def test_allow_newaxis():
344
+ a = ones(5)
345
+ indexed_a = a[None, :]
346
+ assert indexed_a.shape == (1, 5)
347
+
348
+ def test_disallow_flat_indexing_with_newaxis():
349
+ a = ones((3, 3, 3))
350
+ with pytest.raises(IndexError):
351
+ a[None, 0, 0]
352
+
353
+ def test_disallow_mask_with_newaxis():
354
+ a = ones((3, 3, 3))
355
+ with pytest.raises(IndexError):
356
+ a[None, asarray(True)]
357
+
358
+ @pytest.mark.parametrize("shape", [(), (5,), (3, 3, 3)])
359
+ @pytest.mark.parametrize("index", ["string", False, True])
360
+ def test_error_on_invalid_index(shape, index):
361
+ a = ones(shape)
362
+ with pytest.raises(IndexError):
363
+ a[index]
364
+
365
+ def test_mask_0d_array_without_errors():
366
+ a = ones(())
367
+ a[asarray(True)]
368
+
369
+ @pytest.mark.parametrize(
370
+ "i", [slice(5), slice(5, 0), asarray(True), asarray([0, 1])]
371
+ )
372
+ def test_error_on_invalid_index_with_ellipsis(i):
373
+ a = ones((3, 3, 3))
374
+ with pytest.raises(IndexError):
375
+ a[..., i]
376
+ with pytest.raises(IndexError):
377
+ a[i, ...]
378
+
379
+ def test_array_keys_use_private_array():
380
+ """
381
+ Indexing operations convert array keys before indexing the internal array
382
+
383
+ Fails when array_api array keys are not converted into NumPy-proper arrays
384
+ in __getitem__(). This is achieved by passing array_api arrays with 0-sized
385
+ dimensions, which NumPy-proper treats erroneously - not sure why!
386
+
387
+ TODO: Find and use appropriate __setitem__() case.
388
+ """
389
+ a = ones((0, 0), dtype=bool_)
390
+ assert a[a].shape == (0,)
391
+
392
+ a = ones((0,), dtype=bool_)
393
+ key = ones((0, 0), dtype=bool_)
394
+ with pytest.raises(IndexError):
395
+ a[key]
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_creation_functions.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numpy.testing import assert_raises
2
+ import numpy as np
3
+
4
+ from .. import all
5
+ from .._creation_functions import (
6
+ asarray,
7
+ arange,
8
+ empty,
9
+ empty_like,
10
+ eye,
11
+ full,
12
+ full_like,
13
+ linspace,
14
+ meshgrid,
15
+ ones,
16
+ ones_like,
17
+ zeros,
18
+ zeros_like,
19
+ )
20
+ from .._dtypes import float32, float64
21
+ from .._array_object import Array
22
+
23
+
24
+ def test_asarray_errors():
25
+ # Test various protections against incorrect usage
26
+ assert_raises(TypeError, lambda: Array([1]))
27
+ assert_raises(TypeError, lambda: asarray(["a"]))
28
+ assert_raises(ValueError, lambda: asarray([1.0], dtype=np.float16))
29
+ assert_raises(OverflowError, lambda: asarray(2**100))
30
+ # Preferably this would be OverflowError
31
+ # assert_raises(OverflowError, lambda: asarray([2**100]))
32
+ assert_raises(TypeError, lambda: asarray([2**100]))
33
+ asarray([1], device="cpu") # Doesn't error
34
+ assert_raises(ValueError, lambda: asarray([1], device="gpu"))
35
+
36
+ assert_raises(ValueError, lambda: asarray([1], dtype=int))
37
+ assert_raises(ValueError, lambda: asarray([1], dtype="i"))
38
+
39
+
40
+ def test_asarray_copy():
41
+ a = asarray([1])
42
+ b = asarray(a, copy=True)
43
+ a[0] = 0
44
+ assert all(b[0] == 1)
45
+ assert all(a[0] == 0)
46
+ a = asarray([1])
47
+ b = asarray(a, copy=np._CopyMode.ALWAYS)
48
+ a[0] = 0
49
+ assert all(b[0] == 1)
50
+ assert all(a[0] == 0)
51
+ a = asarray([1])
52
+ b = asarray(a, copy=np._CopyMode.NEVER)
53
+ a[0] = 0
54
+ assert all(b[0] == 0)
55
+ assert_raises(NotImplementedError, lambda: asarray(a, copy=False))
56
+ assert_raises(NotImplementedError,
57
+ lambda: asarray(a, copy=np._CopyMode.IF_NEEDED))
58
+
59
+
60
+ def test_arange_errors():
61
+ arange(1, device="cpu") # Doesn't error
62
+ assert_raises(ValueError, lambda: arange(1, device="gpu"))
63
+ assert_raises(ValueError, lambda: arange(1, dtype=int))
64
+ assert_raises(ValueError, lambda: arange(1, dtype="i"))
65
+
66
+
67
+ def test_empty_errors():
68
+ empty((1,), device="cpu") # Doesn't error
69
+ assert_raises(ValueError, lambda: empty((1,), device="gpu"))
70
+ assert_raises(ValueError, lambda: empty((1,), dtype=int))
71
+ assert_raises(ValueError, lambda: empty((1,), dtype="i"))
72
+
73
+
74
+ def test_empty_like_errors():
75
+ empty_like(asarray(1), device="cpu") # Doesn't error
76
+ assert_raises(ValueError, lambda: empty_like(asarray(1), device="gpu"))
77
+ assert_raises(ValueError, lambda: empty_like(asarray(1), dtype=int))
78
+ assert_raises(ValueError, lambda: empty_like(asarray(1), dtype="i"))
79
+
80
+
81
+ def test_eye_errors():
82
+ eye(1, device="cpu") # Doesn't error
83
+ assert_raises(ValueError, lambda: eye(1, device="gpu"))
84
+ assert_raises(ValueError, lambda: eye(1, dtype=int))
85
+ assert_raises(ValueError, lambda: eye(1, dtype="i"))
86
+
87
+
88
+ def test_full_errors():
89
+ full((1,), 0, device="cpu") # Doesn't error
90
+ assert_raises(ValueError, lambda: full((1,), 0, device="gpu"))
91
+ assert_raises(ValueError, lambda: full((1,), 0, dtype=int))
92
+ assert_raises(ValueError, lambda: full((1,), 0, dtype="i"))
93
+
94
+
95
+ def test_full_like_errors():
96
+ full_like(asarray(1), 0, device="cpu") # Doesn't error
97
+ assert_raises(ValueError, lambda: full_like(asarray(1), 0, device="gpu"))
98
+ assert_raises(ValueError, lambda: full_like(asarray(1), 0, dtype=int))
99
+ assert_raises(ValueError, lambda: full_like(asarray(1), 0, dtype="i"))
100
+
101
+
102
+ def test_linspace_errors():
103
+ linspace(0, 1, 10, device="cpu") # Doesn't error
104
+ assert_raises(ValueError, lambda: linspace(0, 1, 10, device="gpu"))
105
+ assert_raises(ValueError, lambda: linspace(0, 1, 10, dtype=float))
106
+ assert_raises(ValueError, lambda: linspace(0, 1, 10, dtype="f"))
107
+
108
+
109
+ def test_ones_errors():
110
+ ones((1,), device="cpu") # Doesn't error
111
+ assert_raises(ValueError, lambda: ones((1,), device="gpu"))
112
+ assert_raises(ValueError, lambda: ones((1,), dtype=int))
113
+ assert_raises(ValueError, lambda: ones((1,), dtype="i"))
114
+
115
+
116
+ def test_ones_like_errors():
117
+ ones_like(asarray(1), device="cpu") # Doesn't error
118
+ assert_raises(ValueError, lambda: ones_like(asarray(1), device="gpu"))
119
+ assert_raises(ValueError, lambda: ones_like(asarray(1), dtype=int))
120
+ assert_raises(ValueError, lambda: ones_like(asarray(1), dtype="i"))
121
+
122
+
123
+ def test_zeros_errors():
124
+ zeros((1,), device="cpu") # Doesn't error
125
+ assert_raises(ValueError, lambda: zeros((1,), device="gpu"))
126
+ assert_raises(ValueError, lambda: zeros((1,), dtype=int))
127
+ assert_raises(ValueError, lambda: zeros((1,), dtype="i"))
128
+
129
+
130
+ def test_zeros_like_errors():
131
+ zeros_like(asarray(1), device="cpu") # Doesn't error
132
+ assert_raises(ValueError, lambda: zeros_like(asarray(1), device="gpu"))
133
+ assert_raises(ValueError, lambda: zeros_like(asarray(1), dtype=int))
134
+ assert_raises(ValueError, lambda: zeros_like(asarray(1), dtype="i"))
135
+
136
+ def test_meshgrid_dtype_errors():
137
+ # Doesn't raise
138
+ meshgrid()
139
+ meshgrid(asarray([1.], dtype=float32))
140
+ meshgrid(asarray([1.], dtype=float32), asarray([1.], dtype=float32))
141
+
142
+ assert_raises(ValueError, lambda: meshgrid(asarray([1.], dtype=float32), asarray([1.], dtype=float64)))
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_data_type_functions.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from numpy.testing import assert_raises
4
+ from numpy import array_api as xp
5
+ import numpy as np
6
+
7
+ @pytest.mark.parametrize(
8
+ "from_, to, expected",
9
+ [
10
+ (xp.int8, xp.int16, True),
11
+ (xp.int16, xp.int8, False),
12
+ (xp.bool, xp.int8, False),
13
+ (xp.asarray(0, dtype=xp.uint8), xp.int8, False),
14
+ ],
15
+ )
16
+ def test_can_cast(from_, to, expected):
17
+ """
18
+ can_cast() returns correct result
19
+ """
20
+ assert xp.can_cast(from_, to) == expected
21
+
22
+ def test_isdtype_strictness():
23
+ assert_raises(TypeError, lambda: xp.isdtype(xp.float64, 64))
24
+ assert_raises(ValueError, lambda: xp.isdtype(xp.float64, 'f8'))
25
+
26
+ assert_raises(TypeError, lambda: xp.isdtype(xp.float64, (('integral',),)))
27
+ assert_raises(TypeError, lambda: xp.isdtype(xp.float64, np.object_))
28
+
29
+ # TODO: These will require https://github.com/numpy/numpy/issues/23883
30
+ # assert_raises(TypeError, lambda: xp.isdtype(xp.float64, None))
31
+ # assert_raises(TypeError, lambda: xp.isdtype(xp.float64, np.float64))
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_elementwise_functions.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from inspect import getfullargspec
2
+
3
+ from numpy.testing import assert_raises
4
+
5
+ from .. import asarray, _elementwise_functions
6
+ from .._elementwise_functions import bitwise_left_shift, bitwise_right_shift
7
+ from .._dtypes import (
8
+ _dtype_categories,
9
+ _boolean_dtypes,
10
+ _floating_dtypes,
11
+ _integer_dtypes,
12
+ )
13
+
14
+
15
+ def nargs(func):
16
+ return len(getfullargspec(func).args)
17
+
18
+
19
+ def test_function_types():
20
+ # Test that every function accepts only the required input types. We only
21
+ # test the negative cases here (error). The positive cases are tested in
22
+ # the array API test suite.
23
+
24
+ elementwise_function_input_types = {
25
+ "abs": "numeric",
26
+ "acos": "floating-point",
27
+ "acosh": "floating-point",
28
+ "add": "numeric",
29
+ "asin": "floating-point",
30
+ "asinh": "floating-point",
31
+ "atan": "floating-point",
32
+ "atan2": "real floating-point",
33
+ "atanh": "floating-point",
34
+ "bitwise_and": "integer or boolean",
35
+ "bitwise_invert": "integer or boolean",
36
+ "bitwise_left_shift": "integer",
37
+ "bitwise_or": "integer or boolean",
38
+ "bitwise_right_shift": "integer",
39
+ "bitwise_xor": "integer or boolean",
40
+ "ceil": "real numeric",
41
+ "conj": "complex floating-point",
42
+ "cos": "floating-point",
43
+ "cosh": "floating-point",
44
+ "divide": "floating-point",
45
+ "equal": "all",
46
+ "exp": "floating-point",
47
+ "expm1": "floating-point",
48
+ "floor": "real numeric",
49
+ "floor_divide": "real numeric",
50
+ "greater": "real numeric",
51
+ "greater_equal": "real numeric",
52
+ "imag": "complex floating-point",
53
+ "isfinite": "numeric",
54
+ "isinf": "numeric",
55
+ "isnan": "numeric",
56
+ "less": "real numeric",
57
+ "less_equal": "real numeric",
58
+ "log": "floating-point",
59
+ "logaddexp": "real floating-point",
60
+ "log10": "floating-point",
61
+ "log1p": "floating-point",
62
+ "log2": "floating-point",
63
+ "logical_and": "boolean",
64
+ "logical_not": "boolean",
65
+ "logical_or": "boolean",
66
+ "logical_xor": "boolean",
67
+ "multiply": "numeric",
68
+ "negative": "numeric",
69
+ "not_equal": "all",
70
+ "positive": "numeric",
71
+ "pow": "numeric",
72
+ "real": "complex floating-point",
73
+ "remainder": "real numeric",
74
+ "round": "numeric",
75
+ "sign": "numeric",
76
+ "sin": "floating-point",
77
+ "sinh": "floating-point",
78
+ "sqrt": "floating-point",
79
+ "square": "numeric",
80
+ "subtract": "numeric",
81
+ "tan": "floating-point",
82
+ "tanh": "floating-point",
83
+ "trunc": "real numeric",
84
+ }
85
+
86
+ def _array_vals():
87
+ for d in _integer_dtypes:
88
+ yield asarray(1, dtype=d)
89
+ for d in _boolean_dtypes:
90
+ yield asarray(False, dtype=d)
91
+ for d in _floating_dtypes:
92
+ yield asarray(1.0, dtype=d)
93
+
94
+ for x in _array_vals():
95
+ for func_name, types in elementwise_function_input_types.items():
96
+ dtypes = _dtype_categories[types]
97
+ func = getattr(_elementwise_functions, func_name)
98
+ if nargs(func) == 2:
99
+ for y in _array_vals():
100
+ if x.dtype not in dtypes or y.dtype not in dtypes:
101
+ assert_raises(TypeError, lambda: func(x, y))
102
+ else:
103
+ if x.dtype not in dtypes:
104
+ assert_raises(TypeError, lambda: func(x))
105
+
106
+
107
+ def test_bitwise_shift_error():
108
+ # bitwise shift functions should raise when the second argument is negative
109
+ assert_raises(
110
+ ValueError, lambda: bitwise_left_shift(asarray([1, 1]), asarray([1, -1]))
111
+ )
112
+ assert_raises(
113
+ ValueError, lambda: bitwise_right_shift(asarray([1, 1]), asarray([1, -1]))
114
+ )
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_indexing_functions.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from numpy import array_api as xp
4
+
5
+
6
+ @pytest.mark.parametrize(
7
+ "x, indices, axis, expected",
8
+ [
9
+ ([2, 3], [1, 1, 0], 0, [3, 3, 2]),
10
+ ([2, 3], [1, 1, 0], -1, [3, 3, 2]),
11
+ ([[2, 3]], [1], -1, [[3]]),
12
+ ([[2, 3]], [0, 0], 0, [[2, 3], [2, 3]]),
13
+ ],
14
+ )
15
+ def test_take_function(x, indices, axis, expected):
16
+ """
17
+ Indices respect relative order of a descending stable-sort
18
+
19
+ See https://github.com/numpy/numpy/issues/20778
20
+ """
21
+ x = xp.asarray(x)
22
+ indices = xp.asarray(indices)
23
+ out = xp.take(x, indices, axis=axis)
24
+ assert xp.all(out == xp.asarray(expected))
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_manipulation_functions.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from numpy.testing import assert_raises
2
+ import numpy as np
3
+
4
+ from .. import all
5
+ from .._creation_functions import asarray
6
+ from .._dtypes import float64, int8
7
+ from .._manipulation_functions import (
8
+ concat,
9
+ reshape,
10
+ stack
11
+ )
12
+
13
+
14
+ def test_concat_errors():
15
+ assert_raises(TypeError, lambda: concat((1, 1), axis=None))
16
+ assert_raises(TypeError, lambda: concat([asarray([1], dtype=int8),
17
+ asarray([1], dtype=float64)]))
18
+
19
+
20
+ def test_stack_errors():
21
+ assert_raises(TypeError, lambda: stack([asarray([1, 1], dtype=int8),
22
+ asarray([2, 2], dtype=float64)]))
23
+
24
+
25
+ def test_reshape_copy():
26
+ a = asarray(np.ones((2, 3)))
27
+ b = reshape(a, (3, 2), copy=True)
28
+ assert not np.shares_memory(a._array, b._array)
29
+
30
+ a = asarray(np.ones((2, 3)))
31
+ b = reshape(a, (3, 2), copy=False)
32
+ assert np.shares_memory(a._array, b._array)
33
+
34
+ a = asarray(np.ones((2, 3)).T)
35
+ b = reshape(a, (3, 2), copy=True)
36
+ assert_raises(AttributeError, lambda: reshape(a, (2, 3), copy=False))
37
+
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_set_functions.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ from hypothesis import given
3
+ from hypothesis.extra.array_api import make_strategies_namespace
4
+
5
+ from numpy import array_api as xp
6
+
7
+ xps = make_strategies_namespace(xp)
8
+
9
+
10
+ @pytest.mark.parametrize("func", [xp.unique_all, xp.unique_inverse])
11
+ @given(xps.arrays(dtype=xps.scalar_dtypes(), shape=xps.array_shapes()))
12
+ def test_inverse_indices_shape(func, x):
13
+ """
14
+ Inverse indices share shape of input array
15
+
16
+ See https://github.com/numpy/numpy/issues/20638
17
+ """
18
+ out = func(x)
19
+ assert out.inverse_indices.shape == x.shape
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_sorting_functions.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from numpy import array_api as xp
4
+
5
+
6
+ @pytest.mark.parametrize(
7
+ "obj, axis, expected",
8
+ [
9
+ ([0, 0], -1, [0, 1]),
10
+ ([0, 1, 0], -1, [1, 0, 2]),
11
+ ([[0, 1], [1, 1]], 0, [[1, 0], [0, 1]]),
12
+ ([[0, 1], [1, 1]], 1, [[1, 0], [0, 1]]),
13
+ ],
14
+ )
15
+ def test_stable_desc_argsort(obj, axis, expected):
16
+ """
17
+ Indices respect relative order of a descending stable-sort
18
+
19
+ See https://github.com/numpy/numpy/issues/20778
20
+ """
21
+ x = xp.asarray(obj)
22
+ out = xp.argsort(x, axis=axis, stable=True, descending=True)
23
+ assert xp.all(out == xp.asarray(expected))
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/array_api/tests/test_validation.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Callable
2
+
3
+ import pytest
4
+
5
+ from numpy import array_api as xp
6
+
7
+
8
+ def p(func: Callable, *args, **kwargs):
9
+ f_sig = ", ".join(
10
+ [str(a) for a in args] + [f"{k}={v}" for k, v in kwargs.items()]
11
+ )
12
+ id_ = f"{func.__name__}({f_sig})"
13
+ return pytest.param(func, args, kwargs, id=id_)
14
+
15
+
16
+ @pytest.mark.parametrize(
17
+ "func, args, kwargs",
18
+ [
19
+ p(xp.can_cast, 42, xp.int8),
20
+ p(xp.can_cast, xp.int8, 42),
21
+ p(xp.result_type, 42),
22
+ ],
23
+ )
24
+ def test_raises_on_invalid_types(func, args, kwargs):
25
+ """Function raises TypeError when passed invalidly-typed inputs"""
26
+ with pytest.raises(TypeError):
27
+ func(*args, **kwargs)
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (4.02 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_add_newdocs_scalars.cpython-310.pyc ADDED
Binary file (11 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_asarray.cpython-310.pyc ADDED
Binary file (3.77 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_dtype.cpython-310.pyc ADDED
Binary file (8.21 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_dtype_ctypes.cpython-310.pyc ADDED
Binary file (3.07 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_exceptions.cpython-310.pyc ADDED
Binary file (5.83 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_internal.cpython-310.pyc ADDED
Binary file (23.2 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_machar.cpython-310.pyc ADDED
Binary file (8.33 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_methods.cpython-310.pyc ADDED
Binary file (5.74 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_string_helpers.cpython-310.pyc ADDED
Binary file (3.04 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/_type_aliases.cpython-310.pyc ADDED
Binary file (5.37 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/arrayprint.cpython-310.pyc ADDED
Binary file (52.4 kB). View file
 
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/numpy/core/__pycache__/cversions.cpython-310.pyc ADDED
Binary file (566 Bytes). View file