Skip to content

Commit aa3fbf2

Browse files
committed
Suppress divide warning
1 parent 83b9c7d commit aa3fbf2

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

tests/test_mathematical.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,7 @@ def test_float_remainder_magnitude(dtype):
13161316
assert_equal(result, expected)
13171317

13181318

1319+
@pytest.mark.usefixtures("suppress_divide_numpy_warnings")
13191320
@pytest.mark.usefixtures("suppress_invalid_numpy_warnings")
13201321
@pytest.mark.parametrize("func", ["remainder", "fmod"])
13211322
@pytest.mark.parametrize("dtype", get_float_dtypes(no_float16=False))

tests/third_party/cupy/math_tests/test_arithmetic.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,16 @@ def test_unary(self, xp):
127127
if self.name in ("reciprocal") and xp is numpy:
128128
# In NumPy, for integer arguments with absolute value larger than 1 the result is always zero.
129129
# We need to convert the input data type to float then compare the output with DPNP.
130-
if arg1.dtype.char in "bB": # int8
131-
arg1 = xp.asarray(arg1, dtype=numpy.float16)
132-
elif arg1.dtype.char in "hH": # int16
133-
arg1 = xp.asarray(arg1, dtype=numpy.float32)
134-
elif arg1.dtype.char in "iIlL": # int32, int64
135-
np_dtype = (
136-
numpy.float64 if has_support_aspect64() else numpy.float32
137-
)
130+
if numpy.issubdtype(arg1.dtype, numpy.integer):
131+
if arg1.dtype.char in "bB": # int8
132+
np_dtype = numpy.float16
133+
elif arg1.dtype.char in "hH": # int16
134+
np_dtype = numpy.float32
135+
else: # int32, int64
136+
if has_support_aspect64():
137+
np_dtype = numpy.float64
138+
else:
139+
np_dtype = numpy.float32
138140
arg1 = xp.asarray(arg1, dtype=np_dtype)
139141

140142
if self.name in {"angle"}:

0 commit comments

Comments
 (0)