|
22 | 22 | zeros, |
23 | 23 | zeros_like, |
24 | 24 | ) |
25 | | -from .._dtypes import int16, float32, float64 |
| 25 | +from .._dtypes import float32, float64 |
26 | 26 | from .._array_object import Array, CPU_DEVICE, Device |
27 | 27 | from .._flags import set_array_api_strict_flags |
28 | 28 |
|
@@ -97,18 +97,20 @@ def test_asarray_copy(): |
97 | 97 | a[0] = 0 |
98 | 98 | assert all(b[0] == 0) |
99 | 99 |
|
| 100 | + |
100 | 101 | def test_asarray_list_of_lists(): |
101 | | - a = asarray(1, dtype=int16) |
102 | | - b = asarray([1], dtype=int16) |
103 | | - res = asarray([a, a]) |
104 | | - assert res.shape == (2,) |
105 | | - assert res.dtype == int16 |
106 | | - assert all(res == asarray([1, 1])) |
107 | | - |
108 | | - res = asarray([b, b]) |
109 | | - assert res.shape == (2, 1) |
110 | | - assert res.dtype == int16 |
111 | | - assert all(res == asarray([[1], [1]])) |
| 102 | + lst = [[1, 2, 3], [4, 5, 6]] |
| 103 | + res = asarray(lst) |
| 104 | + assert res.shape == (2, 3) |
| 105 | + |
| 106 | + |
| 107 | +def test_asarray_nested_arrays(): |
| 108 | + # do not allow arrays in nested sequences |
| 109 | + with pytest.raises(TypeError): |
| 110 | + asarray([[1, 2, 3], asarray([4, 5, 6])]) |
| 111 | + |
| 112 | + with pytest.raises(TypeError): |
| 113 | + asarray([1, asarray(1)]) |
112 | 114 |
|
113 | 115 |
|
114 | 116 | def test_asarray_device_inference(): |
|
0 commit comments