From 8b4793994102002764c73dc5816e430eeb96df62 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 22 Jan 2025 15:20:07 +0100 Subject: [PATCH 1/3] Use assert_dtype_allclose in test_logspace_list_input --- dpnp/tests/test_arraycreation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 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( From 0941ebb8e3a4ab4b509b69694895b6c4ffb26130 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 22 Jan 2025 15:26:18 +0100 Subject: [PATCH 2/3] Use assert_dtype_allclose for input arrays which are generated for floating dtypes in sort and argsort tests --- dpnp/tests/test_sort.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dpnp/tests/test_sort.py b/dpnp/tests/test_sort.py index 5bb51311b9e..5b84947db49 100644 --- a/dpnp/tests/test_sort.py +++ b/dpnp/tests/test_sort.py @@ -31,7 +31,7 @@ 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) @@ -40,13 +40,13 @@ def test_axis(self, axis): @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) 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) From 8f915fba8841399e6ba75534f6040360760134dc Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 22 Jan 2025 16:07:11 +0100 Subject: [PATCH 3/3] Test against stable numpy sort --- dpnp/tests/test_sort.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dpnp/tests/test_sort.py b/dpnp/tests/test_sort.py index 5b84947db49..170583ac31c 100644 --- a/dpnp/tests/test_sort.py +++ b/dpnp/tests/test_sort.py @@ -35,7 +35,7 @@ def test_axis(self, axis): 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)) @@ -295,7 +295,7 @@ def test_axis(self, axis): 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(no_none=True))