Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmute tests for dpnp.sum #1552

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions tests/test_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,9 +1203,6 @@ def test_sum_empty_out(dtype):
@pytest.mark.parametrize("transpose", [True, False])
@pytest.mark.parametrize("keepdims", [True, False])
def test_sum(shape, dtype_in, dtype_out, transpose, keepdims):
if transpose and shape in [(1, 2, 3), (3, 3, 3)]:
pytest.skip("muted due to issue dpctl-1391")

size = numpy.prod(shape)
a_np = numpy.arange(size).astype(dtype_in).reshape(shape)
a = dpnp.asarray(a_np)
Expand Down
24 changes: 14 additions & 10 deletions tests/test_sum.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import numpy
import pytest
from numpy.testing import (
assert_array_equal,
)

import dpnp
from tests.helper import get_float_dtypes, has_support_aspect64
from tests.helper import (
assert_dtype_allclose,
get_float_dtypes,
has_support_aspect64,
)


# Note: numpy.sum() always upcast integers to (u)int64 and float32 to
# float64 for dtype=None. `np.sum` does that too for integers, but not for
# Note: dpnp.sum() always upcast integers to (u)int64 and float32 to
# float64 for dtype=None. `numpy.sum()` does that too for integers, but not for
# float32, so we need to special-case it for these tests
@pytest.mark.parametrize("dtype", get_float_dtypes())
def test_sum_float(dtype):
Expand All @@ -22,11 +29,8 @@ def test_sum_float(dtype):

for axis in range(len(a)):
result = dpnp.sum(ia, axis=axis)
if dtype == dpnp.float32 and has_support_aspect64():
expected = numpy.sum(a, axis=axis, dtype=numpy.float64)
else:
expected = numpy.sum(a, axis=axis)
numpy.testing.assert_array_equal(expected, result)
expected = numpy.sum(a, axis=axis)
assert_dtype_allclose(result, expected)


def test_sum_int():
Expand All @@ -35,7 +39,7 @@ def test_sum_int():

result = dpnp.sum(ia)
expected = numpy.sum(a)
numpy.testing.assert_array_equal(expected, result)
assert_array_equal(expected, result)


def test_sum_axis():
Expand All @@ -54,4 +58,4 @@ def test_sum_axis():
expected = numpy.sum(a, axis=1, dtype=numpy.float64)
else:
expected = numpy.sum(a, axis=1)
numpy.testing.assert_array_equal(expected, result)
assert_array_equal(expected, result)
2 changes: 0 additions & 2 deletions tests/third_party/cupy/math_tests/test_sumprod.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def test_sum_axis2(self, xp, dtype):
else:
return a.sum(axis=1)

@pytest.mark.skip("muted due to issue dpctl-1391")
@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(contiguous_check=False)
def test_sum_axis_transposed(self, xp, dtype):
Expand All @@ -128,7 +127,6 @@ def test_sum_axis_transposed(self, xp, dtype):
else:
return a.sum(axis=1)

@pytest.mark.skip("muted due to issue dpctl-1391")
@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(contiguous_check=False)
def test_sum_axis_transposed2(self, xp, dtype):
Expand Down