Skip to content

Commit f7fb92c

Browse files
Fix test test_asfarray and add test test_asfarray2 (#923)
Co-authored-by: Alexander-Makaryev <[email protected]>
1 parent 5533133 commit f7fb92c

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

tests/test_arraymanipulation.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@
44
import numpy
55

66

7-
@pytest.mark.parametrize("type",
7+
@pytest.mark.parametrize("dtype",
88
[numpy.float64, numpy.float32, numpy.int64, numpy.int32],
9-
ids=['float64', 'float32', 'int64', 'int32'])
10-
@pytest.mark.parametrize("input",
11-
[[1, 2, 3], [1., 2., 3.], dpnp.array([1, 2, 3]), dpnp.array([1., 2., 3.])],
12-
ids=['intlist', 'floatlist', 'intarray', 'floatarray'])
13-
def test_asfarray(type, input):
14-
np_res = numpy.asfarray(input, type)
15-
dpnp_res = dpnp.asfarray(input, type)
16-
17-
numpy.testing.assert_array_equal(dpnp_res, np_res)
9+
ids=["float64", "float32", "int64", "int32"])
10+
@pytest.mark.parametrize("data",
11+
[[1, 2, 3], [1., 2., 3.]],
12+
ids=["[1, 2, 3]", "[1., 2., 3.]"])
13+
def test_asfarray(dtype, data):
14+
expected = numpy.asfarray(data, dtype)
15+
result = dpnp.asfarray(data, dtype)
16+
17+
numpy.testing.assert_array_equal(result, expected)
18+
19+
20+
@pytest.mark.parametrize("dtype",
21+
[numpy.float64, numpy.float32, numpy.int64, numpy.int32],
22+
ids=["float64", "float32", "int64", "int32"])
23+
@pytest.mark.parametrize("data",
24+
[[1, 2, 3], [1., 2., 3.]],
25+
ids=["[1, 2, 3]", "[1., 2., 3.]"])
26+
def test_asfarray2(dtype, data):
27+
expected = numpy.asfarray(numpy.array(data), dtype)
28+
result = dpnp.asfarray(dpnp.array(data), dtype)
29+
30+
numpy.testing.assert_array_equal(result, expected)
1831

1932

2033
class TestConcatenate:

0 commit comments

Comments
 (0)