Skip to content

Commit

Permalink
Update recently updated tests to run properly when no fp64 (#2273)
Browse files Browse the repository at this point in the history
Some of the tests which were updated by latest PRs don't work properly
when running on a device without fp64 support.
The PR is intended to resolve that and to implement proper check of the
resulting arrays for impacted tests.
  • Loading branch information
antonwolfy authored Jan 22, 2025
1 parent 094ab7c commit 451c2b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dpnp/tests/test_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,9 @@ def test_logspace_axis(axis):


def test_logspace_list_input():
res_np = numpy.logspace([0], [2], base=[5])
res_dp = dpnp.logspace([0], [2], base=[5])
assert_allclose(res_dp, res_np)
expected = numpy.logspace([0], [2], base=[5])
result = dpnp.logspace([0], [2], base=[5])
assert_dtype_allclose(result, expected)


@pytest.mark.parametrize(
Expand Down
16 changes: 8 additions & 8 deletions dpnp/tests/test_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ def test_basic(self, kind, dtype):

@pytest.mark.parametrize("axis", [None, -2, -1, 0, 1, 2])
def test_axis(self, axis):
a = generate_random_numpy_array((3, 4, 3))
a = generate_random_numpy_array((3, 4, 3), dtype="i8")
ia = dpnp.array(a)

result = dpnp.argsort(ia, axis=axis)
expected = numpy.argsort(a, axis=axis)
expected = numpy.argsort(a, axis=axis, kind="stable")
assert_array_equal(result, expected)

@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True))
@pytest.mark.parametrize("axis", [None, -2, -1, 0, 1])
def test_ndarray(self, dtype, axis):
def test_ndarray_method(self, dtype, axis):
a = generate_random_numpy_array((6, 2), dtype)
ia = dpnp.array(a)

result = ia.argsort(axis=axis)
expected = a.argsort(axis=axis, kind="stable")
assert_array_equal(result, expected)
assert_dtype_allclose(result, expected)

# this test validates that all different options of kind in dpnp are stable
@pytest.mark.parametrize("kind", [None, "stable", "mergesort", "radixsort"])
Expand Down Expand Up @@ -291,16 +291,16 @@ def test_basic(self, kind, dtype):

@pytest.mark.parametrize("axis", [None, -2, -1, 0, 1, 2])
def test_axis(self, axis):
a = generate_random_numpy_array((3, 4, 3))
a = generate_random_numpy_array((3, 4, 3), dtype="i8")
ia = dpnp.array(a)

result = dpnp.sort(ia, axis=axis)
expected = numpy.sort(a, axis=axis)
expected = numpy.sort(a, axis=axis, kind="stable")
assert_array_equal(result, expected)

@pytest.mark.parametrize("dtype", get_all_dtypes())
@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True))
@pytest.mark.parametrize("axis", [-2, -1, 0, 1])
def test_ndarray(self, dtype, axis):
def test_ndarray_method(self, dtype, axis):
a = generate_random_numpy_array((6, 2), dtype)
ia = dpnp.array(a)

Expand Down

0 comments on commit 451c2b3

Please sign in to comment.