From 451c2b3e25d3b313693ed7e5181aaf75a5b98700 Mon Sep 17 00:00:00 2001 From: Anton <100830759+antonwolfy@users.noreply.github.com> Date: Wed, 22 Jan 2025 18:27:31 +0100 Subject: [PATCH] Update recently updated tests to run properly when no fp64 (#2273) 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. --- dpnp/tests/test_arraycreation.py | 6 +++--- dpnp/tests/test_sort.py | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dpnp/tests/test_arraycreation.py b/dpnp/tests/test_arraycreation.py index 46424634d29..2cc38c4a844 100644 --- a/dpnp/tests/test_arraycreation.py +++ b/dpnp/tests/test_arraycreation.py @@ -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( diff --git a/dpnp/tests/test_sort.py b/dpnp/tests/test_sort.py index 5bb51311b9e..170583ac31c 100644 --- a/dpnp/tests/test_sort.py +++ b/dpnp/tests/test_sort.py @@ -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"]) @@ -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)