|
1 | 1 | import itertools |
2 | 2 | import os |
3 | | -import sys |
4 | 3 |
|
5 | 4 | if int(os.environ.get("TEST_CUPY_PYLOPS", 0)): |
6 | 5 | import cupy as np |
|
17 | 16 |
|
18 | 17 | from pylops.optimization.basic import lsqr |
19 | 18 | from pylops.signalprocessing import FFT, FFT2D, FFTND |
20 | | -from pylops.utils import dottest |
| 19 | +from pylops.utils import dottest, mkl_fft_enabled |
21 | 20 |
|
22 | 21 |
|
23 | 22 | # Utility function |
@@ -323,8 +322,8 @@ def test_unknown_engine(par): |
323 | 322 |
|
324 | 323 | @pytest.mark.parametrize("par", pars_fft_small_real) |
325 | 324 | def test_FFT_small_real(par): |
326 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
327 | | - pytest.skip("mkl_fft not supported on macOS") |
| 325 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 326 | + pytest.skip("mkl_fft is not installed") |
328 | 327 | np.random.seed(5) |
329 | 328 |
|
330 | 329 | if backend == "numpy" or (backend == "cupy" and par["engine"] == "numpy"): |
@@ -402,8 +401,8 @@ def test_FFT_small_real(par): |
402 | 401 | ) |
403 | 402 | @pytest.mark.parametrize("par", pars_fft_random_real) |
404 | 403 | def test_FFT_random_real(par): |
405 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
406 | | - pytest.skip("mkl_fft not supported on macOS") |
| 404 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 405 | + pytest.skip("mkl_fft is not installed") |
407 | 406 | np.random.seed(5) |
408 | 407 |
|
409 | 408 | shape = par["shape"] |
@@ -460,8 +459,8 @@ def test_FFT_random_real(par): |
460 | 459 |
|
461 | 460 | @pytest.mark.parametrize("par", pars_fft_small_cpx) |
462 | 461 | def test_FFT_small_complex(par): |
463 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
464 | | - pytest.skip("mkl_fft not supported on macOS") |
| 462 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 463 | + pytest.skip("mkl_fft is not installed") |
465 | 464 | np.random.seed(5) |
466 | 465 | dtype, decimal = par["dtype_precision"] |
467 | 466 | norm = par["norm"] |
@@ -534,8 +533,8 @@ def test_FFT_small_complex(par): |
534 | 533 |
|
535 | 534 | @pytest.mark.parametrize("par", pars_fft_random_cpx) |
536 | 535 | def test_FFT_random_complex(par): |
537 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
538 | | - pytest.skip("mkl_fft not supported on macOS") |
| 536 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 537 | + pytest.skip("mkl_fft is not installed") |
539 | 538 | np.random.seed(5) |
540 | 539 | if backend == "numpy" or (backend == "cupy" and par["engine"] == "numpy"): |
541 | 540 | shape = par["shape"] |
@@ -623,8 +622,8 @@ def test_FFT_random_complex(par): |
623 | 622 | ) |
624 | 623 | @pytest.mark.parametrize("par", pars_fft2d_random_real) |
625 | 624 | def test_FFT2D_random_real(par): |
626 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
627 | | - pytest.skip("mkl_fft not supported on macOS") |
| 625 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 626 | + pytest.skip("mkl_fft is not installed") |
628 | 627 | np.random.seed(5) |
629 | 628 | if backend == "numpy" or (backend == "cupy" and par["engine"] == "numpy"): |
630 | 629 | shape = par["shape"] |
@@ -686,8 +685,8 @@ def test_FFT2D_random_real(par): |
686 | 685 |
|
687 | 686 | @pytest.mark.parametrize("par", pars_fft2d_random_cpx) |
688 | 687 | def test_FFT2D_random_complex(par): |
689 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
690 | | - pytest.skip("mkl_fft not supported on macOS") |
| 688 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 689 | + pytest.skip("mkl_fft is not installed") |
691 | 690 | np.random.seed(5) |
692 | 691 | if backend == "numpy" or (backend == "cupy" and par["engine"] == "numpy"): |
693 | 692 | shape = par["shape"] |
@@ -769,8 +768,8 @@ def test_FFT2D_random_complex(par): |
769 | 768 |
|
770 | 769 | @pytest.mark.parametrize("par", pars_fftnd_random_real) |
771 | 770 | def test_FFTND_random_real(par): |
772 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
773 | | - pytest.skip("mkl_fft not supported on macOS") |
| 771 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 772 | + pytest.skip("mkl_fft is not installed") |
774 | 773 | np.random.seed(5) |
775 | 774 | if backend == "numpy" or (backend == "cupy" and par["engine"] == "numpy"): |
776 | 775 | shape = par["shape"] |
@@ -832,8 +831,8 @@ def test_FFTND_random_real(par): |
832 | 831 |
|
833 | 832 | @pytest.mark.parametrize("par", pars_fftnd_random_cpx) |
834 | 833 | def test_FFTND_random_complex(par): |
835 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
836 | | - pytest.skip("mkl_fft not supported on macOS") |
| 834 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 835 | + pytest.skip("mkl_fft is not installed") |
837 | 836 | np.random.seed(5) |
838 | 837 | shape = par["shape"] |
839 | 838 | dtype, decimal = par["dtype_precision"] |
@@ -910,8 +909,8 @@ def test_FFTND_random_complex(par): |
910 | 909 |
|
911 | 910 | @pytest.mark.parametrize("par", pars_fft2dnd_small_cpx) |
912 | 911 | def test_FFT2D_small_complex(par): |
913 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
914 | | - pytest.skip("mkl_fft not supported on macOS") |
| 912 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 913 | + pytest.skip("mkl_fft is not installed") |
915 | 914 | np.random.seed(5) |
916 | 915 | dtype, decimal = par["dtype_precision"] |
917 | 916 | norm = par["norm"] |
@@ -962,8 +961,8 @@ def test_FFT2D_small_complex(par): |
962 | 961 |
|
963 | 962 | @pytest.mark.parametrize("par", pars_fft2dnd_small_cpx) |
964 | 963 | def test_FFTND_small_complex(par): |
965 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
966 | | - pytest.skip("mkl_fft not supported on macOS") |
| 964 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 965 | + pytest.skip("mkl_fft is not installed") |
967 | 966 | np.random.seed(5) |
968 | 967 | dtype, decimal = par["dtype_precision"] |
969 | 968 | norm = par["norm"] |
@@ -1039,8 +1038,8 @@ def test_FFTND_small_complex(par): |
1039 | 1038 | ], |
1040 | 1039 | ) |
1041 | 1040 | def test_FFT_1dsignal(par): |
1042 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
1043 | | - pytest.skip("mkl_fft not supported on macOS") |
| 1041 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 1042 | + pytest.skip("mkl_fft is not installed") |
1044 | 1043 | np.random.seed(5) |
1045 | 1044 | """Dot-test and inversion for FFT operator for 1d signal""" |
1046 | 1045 | decimal = 3 if np.real(np.ones(1, par["dtype"])).dtype == np.float32 else 8 |
@@ -1158,8 +1157,8 @@ def test_FFT_2dsignal(par): |
1158 | 1157 | """Dot-test and inversion for fft operator for 2d signal |
1159 | 1158 | (fft on single dimension) |
1160 | 1159 | """ |
1161 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
1162 | | - pytest.skip("mkl_fft not supported on macOS") |
| 1160 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 1161 | + pytest.skip("mkl_fft is not installed") |
1163 | 1162 | np.random.seed(5) |
1164 | 1163 | decimal = 3 if np.real(np.ones(1, par["dtype"])).dtype == np.float32 else 8 |
1165 | 1164 |
|
@@ -1375,8 +1374,8 @@ def test_FFT_3dsignal(par): |
1375 | 1374 | """Dot-test and inversion for fft operator for 3d signal |
1376 | 1375 | (fft on single dimension) |
1377 | 1376 | """ |
1378 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
1379 | | - pytest.skip("mkl_fft not supported on macOS") |
| 1377 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 1378 | + pytest.skip("mkl_fft is not installed") |
1380 | 1379 | np.random.seed(5) |
1381 | 1380 | decimal = 3 if np.real(np.ones(1, par["dtype"])).dtype == np.float32 else 8 |
1382 | 1381 |
|
@@ -1603,8 +1602,8 @@ def test_FFT_3dsignal(par): |
1603 | 1602 | ) |
1604 | 1603 | def test_FFT2D(par): |
1605 | 1604 | """Dot-test and inversion for FFT2D operator for 2d signal""" |
1606 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
1607 | | - pytest.skip("mkl_fft not supported on macOS") |
| 1605 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 1606 | + pytest.skip("mkl_fft is not installed") |
1608 | 1607 | np.random.seed(5) |
1609 | 1608 | decimal = 3 if np.real(np.ones(1, par["dtype"])).dtype == np.float32 else 8 |
1610 | 1609 |
|
@@ -1740,8 +1739,8 @@ def test_FFT2D(par): |
1740 | 1739 | ) |
1741 | 1740 | def test_FFT3D(par): |
1742 | 1741 | """Dot-test and inversion for FFTND operator for 3d signal""" |
1743 | | - if par["engine"] == "mkl_fft" and sys.platform == "darwin": |
1744 | | - pytest.skip("mkl_fft not supported on macOS") |
| 1742 | + if par["engine"] == "mkl_fft" and not mkl_fft_enabled: |
| 1743 | + pytest.skip("mkl_fft is not installed") |
1745 | 1744 | np.random.seed(5) |
1746 | 1745 | decimal = 3 if np.real(np.ones(1, par["dtype"])).dtype == np.float32 else 8 |
1747 | 1746 |
|
|
0 commit comments