Skip to content

Commit c432bab

Browse files
committed
Add a proper handling of corner cases
1 parent 3317209 commit c432bab

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

tests/test_mathematical.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,37 +1915,27 @@ def test_bool(self):
19151915

19161916
result = dpnp.sinc(ia)
19171917
expected = numpy.sinc(a)
1918-
# numpy 1.26 promotes result to float64 dtype, but expected float16
1919-
assert_dtype_allclose(
1920-
result,
1921-
expected,
1922-
check_only_type_kind=(
1923-
numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
1924-
),
1925-
)
1918+
# numpy promotes result to float64 dtype, but expected float16
1919+
assert_dtype_allclose(result, expected, check_only_type_kind=True)
19261920

19271921
@pytest.mark.parametrize("dt", get_all_dtypes(no_none=True, no_bool=True))
19281922
def test_zero(self, dt):
1929-
if (
1930-
dt == numpy.float16
1931-
and numpy.lib.NumpyVersion(numpy.__version__) < "2.0.0"
1932-
):
1933-
pytest.skip("numpy.sinc return NaN")
1934-
19351923
a = numpy.array([0.0], dtype=dt)
19361924
ia = dpnp.array(a)
19371925

19381926
result = dpnp.sinc(ia)
19391927
expected = numpy.sinc(a)
19401928
assert_dtype_allclose(result, expected)
19411929

1930+
# TODO: add a proper NumPY version once resolved
19421931
@testing.with_requires("numpy>=2.0.0")
19431932
def test_zero_fp16(self):
19441933
a = numpy.array([0.0], dtype=numpy.float16)
19451934
ia = dpnp.array(a)
19461935

19471936
result = dpnp.sinc(ia)
1948-
expected = numpy.sinc(a)
1937+
# expected = numpy.sinc(a) # numpy returns NaN, but expected 1.0
1938+
expected = numpy.ones_like(a)
19491939
assert_dtype_allclose(result, expected)
19501940

19511941
@pytest.mark.usefixtures("suppress_invalid_numpy_warnings")

0 commit comments

Comments
 (0)