Skip to content

Commit 88030f5

Browse files
committed
unmute tests
1 parent d2c623b commit 88030f5

File tree

3 files changed

+59
-23
lines changed

3 files changed

+59
-23
lines changed

tests/test_fft.py

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313
get_all_dtypes,
1414
get_complex_dtypes,
1515
get_float_dtypes,
16-
is_cpu_device,
1716
)
1817

19-
# aspects of default device:
20-
_def_device = dpctl.SyclQueue().sycl_device
21-
_def_dev_has_fp64 = _def_device.has_aspect_fp64
22-
is_gpu_with_fp64 = not is_cpu_device() and _def_dev_has_fp64
23-
2418

2519
# TODO: `assert_dtype_allclose` calls in this file have `check_only_type_kind=True`
2620
# since stock NumPy is currently used in public CI for code coverege which
@@ -391,11 +385,17 @@ def test_hfft_1D(self, dtype, n, norm):
391385
assert_dtype_allclose(result, expected, check_only_type_kind=True)
392386

393387
@pytest.mark.parametrize("dtype", get_complex_dtypes())
394-
@pytest.mark.parametrize("n", [None, 5, 20])
388+
@pytest.mark.parametrize("n", [None, 5, 18])
395389
@pytest.mark.parametrize("norm", ["forward", "backward", "ortho"])
396390
def test_hfft_1D_complex(self, dtype, n, norm):
397391
x = dpnp.linspace(-1, 1, 11)
398392
a = dpnp.sin(x) + 1j * dpnp.cos(x)
393+
# input should be Hermitian
394+
a[0].imag = 0
395+
if n in [None, 18]:
396+
f_ny = -1 if n is None else n // 2 # Nyquist mode
397+
a[f_ny].imag = 0
398+
a[f_ny:] = 0 # no data needed after Nyquist mode
399399
a = dpnp.asarray(a, dtype=dtype)
400400
a_np = dpnp.asnumpy(a)
401401

@@ -446,13 +446,18 @@ def test_fft_1D(self, dtype, n, norm):
446446
# but dpnp return float32 if input is float32
447447
assert_dtype_allclose(result, expected, check_only_type_kind=True)
448448

449-
@pytest.mark.skipif(is_gpu_with_fp64, reason="MKLD17702")
450449
@pytest.mark.parametrize("dtype", get_complex_dtypes())
451-
@pytest.mark.parametrize("n", [None, 5, 20])
450+
@pytest.mark.parametrize("n", [None, 5, 18])
452451
@pytest.mark.parametrize("norm", ["forward", "backward", "ortho"])
453452
def test_fft_1D_complex(self, dtype, n, norm):
454453
x = dpnp.linspace(-1, 1, 11)
455454
a = dpnp.sin(x) + 1j * dpnp.cos(x)
455+
# input should be Hermitian
456+
a[0].imag = 0
457+
if n in [None, 18]:
458+
f_ny = -1 if n is None else n // 2 # Nyquist mode
459+
a[f_ny].imag = 0
460+
a[f_ny:] = 0 # no data needed after Nyquist mode
456461
a = dpnp.asarray(a, dtype=dtype)
457462
a_np = dpnp.asnumpy(a)
458463

@@ -473,29 +478,55 @@ def test_fft_1D_on_2D_array(self, dtype, n, axis, norm, order):
473478
expected = numpy.fft.irfft(a_np, n=n, axis=axis, norm=norm)
474479
assert_dtype_allclose(result, expected, check_only_type_kind=True)
475480

476-
@pytest.mark.skipif(is_gpu_with_fp64, reason="MKLD17702")
477481
@pytest.mark.parametrize("dtype", get_complex_dtypes())
478482
@pytest.mark.parametrize("n", [None, 5, 8])
479483
@pytest.mark.parametrize("axis", [0, 1, 2])
480484
@pytest.mark.parametrize("norm", ["forward", "backward", "ortho"])
481485
@pytest.mark.parametrize("order", ["C", "F"])
482486
def test_fft_1D_on_3D_array(self, dtype, n, axis, norm, order):
483-
x1 = numpy.random.uniform(-10, 10, 24)
484-
x2 = numpy.random.uniform(-10, 10, 24)
487+
x1 = numpy.random.uniform(-10, 10, 120)
488+
x2 = numpy.random.uniform(-10, 10, 120)
485489
a_np = numpy.array(x1 + 1j * x2, dtype=dtype).reshape(
486-
2, 3, 4, order=order
490+
4, 5, 6, order=order
487491
)
492+
# each 1-D array of input should be Hermitian
493+
if axis == 0:
494+
a_np[0].imag = 0
495+
if n is None:
496+
# for axis=0 and n=8, Nyquist mode is not present
497+
f_ny = -1 # Nyquist mode
498+
a_np[-1].imag = 0
499+
elif axis == 1:
500+
a_np[:, 0, :].imag = 0
501+
if n in [None, 8]:
502+
f_ny = -1 # Nyquist mode
503+
a_np[:, f_ny, :].imag = 0
504+
a_np[:, f_ny:, :] = 0 # no data needed after Nyquist mode
505+
elif axis == 2:
506+
a_np[..., 0].imag = 0
507+
if n in [None, 8]:
508+
f_ny = -1 if n is None else n // 2 # Nyquist mode
509+
a_np[..., f_ny].imag = 0
510+
a_np[..., f_ny:] = 0 # no data needed after Nyquist mode
511+
488512
a = dpnp.asarray(a_np)
489513

490514
result = dpnp.fft.irfft(a, n=n, axis=axis, norm=norm)
491515
expected = numpy.fft.irfft(a_np, n=n, axis=axis, norm=norm)
492-
assert_dtype_allclose(result, expected, check_only_type_kind=True)
516+
assert_dtype_allclose(
517+
result, expected, check_only_type_kind=True, factor=16
518+
)
493519

494-
@pytest.mark.skipif(is_gpu_with_fp64, reason="MKLD17702")
495-
@pytest.mark.parametrize("n", [None, 5, 20])
520+
@pytest.mark.parametrize("n", [None, 5, 18])
496521
def test_fft_usm_ndarray(self, n):
497522
x = dpt.linspace(-1, 1, 11)
498523
a = dpt.sin(x) + 1j * dpt.cos(x)
524+
# input should be Hermitian
525+
a[0] = dpt.sin(x[0])
526+
if n in [None, 18]:
527+
f_ny = -1 if n is None else n // 2 # Nyquist mode
528+
a[f_ny] = dpt.sin(x[f_ny])
529+
a[f_ny:] = 0 # no data needed after Nyquist mode
499530
a_usm = dpt.asarray(a, dtype=dpt.complex64)
500531
a_np = dpt.asnumpy(a_usm)
501532
out_shape = n if n is not None else 2 * (a_usm.shape[0] - 1)
@@ -506,13 +537,18 @@ def test_fft_usm_ndarray(self, n):
506537
expected = numpy.fft.irfft(a_np, n=n)
507538
assert_dtype_allclose(result, expected, check_only_type_kind=True)
508539

509-
@pytest.mark.skipif(is_gpu_with_fp64, reason="MKLD17702")
510540
@pytest.mark.parametrize("dtype", get_complex_dtypes())
511-
@pytest.mark.parametrize("n", [None, 5, 20])
541+
@pytest.mark.parametrize("n", [None, 5, 18])
512542
@pytest.mark.parametrize("norm", ["forward", "backward", "ortho"])
513543
def test_fft_1D_out(self, dtype, n, norm):
514544
x = dpnp.linspace(-1, 1, 11)
515545
a = dpnp.sin(x) + 1j * dpnp.cos(x)
546+
# input should be Hermitian
547+
a[0].imag = 0
548+
if n in [None, 18]:
549+
f_ny = -1 if n is None else n // 2 # Nyquist mode
550+
a[f_ny].imag = 0
551+
a[f_ny:] = 0 # no data needed after Nyquist mode
516552
a = dpnp.asarray(a, dtype=dtype)
517553
a_np = dpnp.asnumpy(a)
518554

@@ -624,7 +660,7 @@ def test_fft_usm_ndarray(self, n):
624660
x = dpt.linspace(-1, 1, 11)
625661
a_usm = dpt.asarray(dpt.sin(x))
626662
a_np = dpt.asnumpy(a_usm)
627-
out_shape = a_usm.shape[0] // 2 + 1 if n is None else n // 2 + 1
663+
out_shape = a_usm.shape[0] // 2 + 1 if n is None else n // 2
628664
out_dtype = map_dtype_to_device(dpnp.complex128, a_usm.sycl_device)
629665
out = dpt.empty(out_shape, dtype=out_dtype)
630666

@@ -642,7 +678,7 @@ def test_fft_1D_out(self, dtype, n, norm):
642678
a = dpnp.asarray(a, dtype=dtype)
643679
a_np = dpnp.asnumpy(a)
644680

645-
out_shape = a.shape[0] // 2 + 1 if n is None else n // 2 + 1
681+
out_shape = a.shape[0] // 2 + 1 if n is None else n // 2
646682
out_dtype = dpnp.complex64 if dtype == dpnp.float32 else dpnp.complex128
647683
out = dpnp.empty(out_shape, dtype=out_dtype)
648684

@@ -661,7 +697,7 @@ def test_fft_1D_on_2D_array_out(self, dtype, n, axis, norm, order):
661697
a = dpnp.asarray(a_np)
662698

663699
out_shape = list(a.shape)
664-
out_shape[axis] = a.shape[axis] // 2 + 1 if n is None else n // 2 + 1
700+
out_shape[axis] = a.shape[axis] // 2 + 1 if n is None else n // 2
665701
out_shape = tuple(out_shape)
666702
out_dtype = dpnp.complex64 if dtype == dpnp.float32 else dpnp.complex128
667703
out = dpnp.empty(out_shape, dtype=out_dtype)

tests/test_sycl_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ def test_fft(func, device):
12391239

12401240
expected = getattr(numpy.fft, func)(data)
12411241
result = getattr(dpnp.fft, func)(dpnp_data)
1242-
assert_dtype_allclose(result, expected)
1242+
assert_dtype_allclose(result, expected, factor=16)
12431243

12441244
expected_queue = dpnp_data.get_array().sycl_queue
12451245
result_queue = result.get_array().sycl_queue

tests/test_umath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def test_large_values(self, dtype):
313313
assert_dtype_allclose(result, expected)
314314

315315

316-
class TestLogaddexp:
316+
class TestLogAddExp:
317317
@pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True))
318318
def test_logaddexp(self, dtype):
319319
np_array1, np_array2, expected = _get_numpy_arrays_2in_1out(

0 commit comments

Comments
 (0)