|
1 | 1 | import pytest
|
| 2 | +from .helper import get_all_dtypes |
2 | 3 |
|
3 | 4 | import dpnp
|
4 | 5 | import numpy
|
5 | 6 |
|
6 | 7 |
|
7 | 8 | @pytest.mark.usefixtures("allow_fall_back_on_numpy")
|
8 |
| -@pytest.mark.parametrize("dtype", |
9 |
| - [numpy.float64, numpy.float32, numpy.int64, numpy.int32], |
10 |
| - ids=["float64", "float32", "int64", "int32"]) |
11 |
| -@pytest.mark.parametrize("data", |
12 |
| - [[1, 2, 3], [1., 2., 3.]], |
13 |
| - ids=["[1, 2, 3]", "[1., 2., 3.]"]) |
| 9 | +@pytest.mark.parametrize("dtype", get_all_dtypes()) |
| 10 | +@pytest.mark.parametrize( |
| 11 | + "data", [[1, 2, 3], [1.0, 2.0, 3.0]], ids=["[1, 2, 3]", "[1., 2., 3.]"] |
| 12 | +) |
14 | 13 | def test_asfarray(dtype, data):
|
15 | 14 | expected = numpy.asfarray(data, dtype)
|
16 | 15 | result = dpnp.asfarray(data, dtype)
|
17 | 16 |
|
18 | 17 | numpy.testing.assert_array_equal(result, expected)
|
19 | 18 |
|
20 | 19 |
|
21 |
| -@pytest.mark.parametrize("dtype", |
22 |
| - [numpy.float64, numpy.float32, numpy.int64, numpy.int32], |
23 |
| - ids=["float64", "float32", "int64", "int32"]) |
24 |
| -@pytest.mark.parametrize("data", |
25 |
| - [[1, 2, 3], [1., 2., 3.]], |
26 |
| - ids=["[1, 2, 3]", "[1., 2., 3.]"]) |
27 |
| -def test_asfarray2(dtype, data): |
28 |
| - expected = numpy.asfarray(numpy.array(data), dtype) |
29 |
| - result = dpnp.asfarray(dpnp.array(data), dtype) |
| 20 | +@pytest.mark.parametrize("dtype", get_all_dtypes()) |
| 21 | +@pytest.mark.parametrize("data", [[1.0, 2.0, 3.0]], ids=["[1., 2., 3.]"]) |
| 22 | +@pytest.mark.parametrize("data_dtype", get_all_dtypes(no_none=True)) |
| 23 | +def test_asfarray2(dtype, data, data_dtype): |
| 24 | + expected = numpy.asfarray(numpy.array(data, dtype=data_dtype), dtype) |
| 25 | + result = dpnp.asfarray(dpnp.array(data, dtype=data_dtype), dtype) |
30 | 26 |
|
31 | 27 | numpy.testing.assert_array_equal(result, expected)
|
32 | 28 |
|
@@ -59,7 +55,9 @@ def test_concatenate(self):
|
59 | 55 | numpy.testing.assert_array_equal(dpnp.concatenate((r4, r3)), r4 + r3)
|
60 | 56 | # Mixed sequence types
|
61 | 57 | numpy.testing.assert_array_equal(dpnp.concatenate((tuple(r4), r3)), r4 + r3)
|
62 |
| - numpy.testing.assert_array_equal(dpnp.concatenate((dpnp.array(r4), r3)), r4 + r3) |
| 58 | + numpy.testing.assert_array_equal( |
| 59 | + dpnp.concatenate((dpnp.array(r4), r3)), r4 + r3 |
| 60 | + ) |
63 | 61 | # Explicit axis specification
|
64 | 62 | numpy.testing.assert_array_equal(dpnp.concatenate((r4, r3), 0), r4 + r3)
|
65 | 63 | # Including negative
|
|
0 commit comments