add tests for complex64/complex128
@@ -255,33 +255,48 @@ class TestMisc:
with pytest.raises(ValueError):
xp.nan_to_num(0.0, **{kwarg: y})
- @testing.for_all_dtypes(no_bool=True)
+ @testing.for_all_dtypes(no_bool=True, no_complex=True)
@testing.numpy_cupy_array_equal()
def test_real_if_close(self, xp, dtype):
x = testing.shaped_random((10,), xp, dtype)
return xp.real_if_close(x)
@testing.numpy_cupy_array_equal()
- def test_real_if_close_complex(self, xp):
- x = testing.shaped_random((10,), xp) + 1e-15j
+ def test_real_if_close_complex64(self, xp):
+ x = testing.shaped_random((10,), xp, dtype='F') + 1e-15j
return xp.real_if_close(x)
- @testing.for_all_dtypes(no_bool=True)
+ @testing.numpy_cupy_array_equal()
+ def test_real_if_close_complex128(self, xp):
+ x = testing.shaped_random((10,), xp, dtype='D') + 1e-50j
+ return xp.real_if_close(x)
+
+ @testing.for_all_dtypes(no_bool=True, no_complex=True)
@testing.numpy_cupy_array_equal()
def test_real_if_close_with_tol(self, xp, dtype):
x = testing.shaped_random((10,), xp, dtype)
return xp.real_if_close(x, tol=1e-6)
@testing.numpy_cupy_array_equal()
- def test_real_if_close_with_tol_complex(self, xp):
- x = testing.shaped_random((10,), xp) + 1e-3j
+ def test_real_if_close_with_tol_complex64(self, xp):
+ x = testing.shaped_random((10,), xp, dtype='F') + 1e-5j
return xp.real_if_close(x, tol=1e-6)
@testing.numpy_cupy_array_equal()
- def test_real_if_close_with_tol_greater_than_imag(self, xp):
- x = testing.shaped_random((10,), xp) + 1e-7j
+ def test_real_if_close_with_tol_complex128(self, xp):
+ x = testing.shaped_random((10,), xp, dtype='D') + 1e-50j
+ return xp.real_if_close(x, tol=1e-55)
+
+ @testing.numpy_cupy_array_equal()
+ def test_real_if_close_with_greater_tol_complex64(self, xp):
+ x = testing.shaped_random((10,), xp, dtype='F') + 1e-7j
return xp.real_if_close(x, tol=1e-6)
+ @testing.numpy_cupy_array_equal()
+ def test_real_if_close_with_greater_tol_complex128(self, xp):
+ x = testing.shaped_random((10,), xp, dtype='D') + 1e-60j
+ return xp.real_if_close(x, tol=1e-50)
+
@testing.for_all_dtypes(name='dtype_x', no_bool=True, no_complex=True)
@testing.for_all_dtypes(name='dtype_y', no_bool=True)
@testing.numpy_cupy_allclose(atol=1e-5)
