Skip to content

Commit 9e274fd

Browse files
Update cupy tests for nan_to_num()
1 parent eea6d1e commit 9e274fd

File tree

3 files changed

+8
-37
lines changed

3 files changed

+8
-37
lines changed

tests/skipped_tests.tbl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,6 @@ tests/third_party/cupy/manipulation_tests/test_dims.py::TestInvalidBroadcast_par
207207
tests/third_party/cupy/manipulation_tests/test_dims.py::TestInvalidBroadcast_param_2_{shapes=[(3, 2), (3, 4)]}::test_invalid_broadcast
208208
tests/third_party/cupy/manipulation_tests/test_dims.py::TestInvalidBroadcast_param_3_{shapes=[(0,), (2,)]}::test_invalid_broadcast
209209

210-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num
211-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_negative
212-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_for_old_numpy
213-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_negative_for_old_numpy
214-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_inf
215-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_nan
216-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_inf_nan
217-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_nan_arg
218-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_inf_arg
219-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_broadcast[nan]
220-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_broadcast[posinf]
221-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_broadcast[neginf]
222-
223-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_scalar_nan
224-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_copy
225-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_inplace
226210
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_real_if_close_real_dtypes
227211
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_real_if_close_with_tol_real_dtypes
228212
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_real_if_close_true

tests/skipped_tests_gpu.tbl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,22 +261,6 @@ tests/third_party/cupy/manipulation_tests/test_dims.py::TestInvalidBroadcast_par
261261
tests/third_party/cupy/manipulation_tests/test_dims.py::TestInvalidBroadcast_param_2_{shapes=[(3, 2), (3, 4)]}::test_invalid_broadcast
262262
tests/third_party/cupy/manipulation_tests/test_dims.py::TestInvalidBroadcast_param_3_{shapes=[(0,), (2,)]}::test_invalid_broadcast
263263

264-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num
265-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_negative
266-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_for_old_numpy
267-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_negative_for_old_numpy
268-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_inf
269-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_nan
270-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_inf_nan
271-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_nan_arg
272-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_inf_arg
273-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_broadcast[nan]
274-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_broadcast[posinf]
275-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_broadcast[neginf]
276-
277-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_scalar_nan
278-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_copy
279-
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_nan_to_num_inplace
280264
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_real_if_close_real_dtypes
281265
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_real_if_close_with_tol_real_dtypes
282266
tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_real_if_close_true

tests/third_party/cupy/math_tests/test_misc.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,27 +260,30 @@ def test_nan_to_num_inf_arg(self):
260260

261261
@testing.numpy_cupy_array_equal()
262262
def test_nan_to_num_copy(self, xp):
263-
x = xp.asarray([0, 1, xp.nan, 4], dtype=xp.float64)
263+
x = xp.asarray([0, 1, xp.nan, 4], dtype=cupy.default_float_type())
264264
y = xp.nan_to_num(x, copy=True)
265265
assert x is not y
266266
return y
267267

268268
@testing.numpy_cupy_array_equal()
269269
def test_nan_to_num_inplace(self, xp):
270-
x = xp.asarray([0, 1, xp.nan, 4], dtype=xp.float64)
270+
x = xp.asarray([0, 1, xp.nan, 4], dtype=cupy.default_float_type())
271271
y = xp.nan_to_num(x, copy=False)
272272
assert x is y
273273
return y
274274

275275
@pytest.mark.parametrize("kwarg", ["nan", "posinf", "neginf"])
276276
def test_nan_to_num_broadcast(self, kwarg):
277277
for xp in (numpy, cupy):
278-
x = xp.asarray([0, 1, xp.nan, 4], dtype=xp.float64)
279-
y = xp.zeros((2, 4), dtype=xp.float64)
278+
x = xp.asarray([0, 1, xp.nan, 4], dtype=cupy.default_float_type())
279+
y = xp.zeros((2, 4), dtype=cupy.default_float_type())
280280
with pytest.raises(ValueError):
281281
xp.nan_to_num(x, **{kwarg: y})
282+
# dpnp.nan_to_num() doesn`t support a scalar as an input
283+
# convert 0.0 to 0-ndim array
282284
with pytest.raises(ValueError):
283-
xp.nan_to_num(0.0, **{kwarg: y})
285+
x_ndim_0 = xp.array(0.0)
286+
xp.nan_to_num(x_ndim_0, **{kwarg: y})
284287

285288
@testing.for_all_dtypes(no_bool=True, no_complex=True)
286289
@testing.numpy_cupy_array_equal()

0 commit comments

Comments
 (0)