Skip to content
Merged
Changes from 2 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
32 changes: 21 additions & 11 deletions dpnp/tests/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,13 @@ def test_basic(self, dtype, n, norm):

result = dpnp.fft.hfft(ia, n=n, norm=norm)
expected = numpy.fft.hfft(a, n=n, norm=norm)
# check_only_type_kind=True since NumPy always returns float64
# but dpnp return float32 if input is float32
assert_dtype_allclose(result, expected, check_only_type_kind=True)
# TODO: change to the commented line when mkl_fft-2.0.0 is released
# and being used with Intel NumPy >= 2.0.0
flag = True
# flag = True if numpy_version() < "2.0.0" else False
assert_dtype_allclose(
result, expected, factor=24, check_only_type_kind=flag
)

@pytest.mark.parametrize(
"dtype", get_all_dtypes(no_none=True, no_complex=True)
Expand All @@ -579,7 +583,7 @@ def test_inverse(self, dtype, n, norm):
result = dpnp.fft.ihfft(ia, n=n, norm=norm)
expected = numpy.fft.ihfft(a, n=n, norm=norm)
flag = True if numpy_version() < "2.0.0" else False
assert_dtype_allclose(result, expected, check_only_type_kind=True)
assert_dtype_allclose(result, expected, check_only_type_kind=flag)

def test_error(self):
a = dpnp.ones(11)
Expand All @@ -600,14 +604,16 @@ class TestIrfft:
@pytest.mark.parametrize("n", [None, 5, 18])
@pytest.mark.parametrize("norm", [None, "backward", "forward", "ortho"])
def test_basic(self, dtype, n, norm):
a = generate_random_numpy_array(11)
a = generate_random_numpy_array(11, dtype=dtype)
ia = dpnp.array(a)

result = dpnp.fft.irfft(ia, n=n, norm=norm)
expected = numpy.fft.irfft(a, n=n, norm=norm)
# check_only_type_kind=True since NumPy always returns float64
# but dpnp return float32 if input is float32
assert_dtype_allclose(result, expected, check_only_type_kind=True)
# TODO: change to the commented line when mkl_fft-2.0.0 is released
# and being used with Intel NumPy >= 2.0.0
flag = True
# flag = True if numpy_version() < "2.0.0" else False
assert_dtype_allclose(result, expected, check_only_type_kind=flag)

@pytest.mark.parametrize("dtype", get_complex_dtypes())
@pytest.mark.parametrize("n", [None, 5, 8])
Expand Down Expand Up @@ -771,8 +777,11 @@ def test_float16(self):

expected = numpy.fft.rfft(a)
result = dpnp.fft.rfft(ia)
# check_only_type_kind=True since Intel NumPy returns complex128
assert_dtype_allclose(result, expected, check_only_type_kind=True)
# TODO: change to the commented line when mkl_fft-2.0.0 is released
# and being used with Intel NumPy >= 2.0.0
flag = True
# flag = True if numpy_version() < "2.0.0" else False
assert_dtype_allclose(result, expected, check_only_type_kind=flag)

@testing.with_requires("numpy>=2.0.0")
@pytest.mark.parametrize("xp", [numpy, dpnp])
Expand Down Expand Up @@ -954,7 +963,8 @@ def test_1d_array(self):

result = dpnp.fft.irfftn(ia)
expected = numpy.fft.irfftn(a)
# TODO: change to the commented line when mkl_fft-gh-180 is merged
# TODO: change to the commented line when mkl_fft-2.0.0 is released
# and being used with Intel NumPy >= 2.0.0
flag = True
# flag = True if numpy_version() < "2.0.0" else False
assert_dtype_allclose(result, expected, check_only_type_kind=flag)
Loading