(dtype, order, fft)
| 495 | [np.fft.fft, np.fft.fft2, np.fft.fftn, |
| 496 | np.fft.ifft, np.fft.ifft2, np.fft.ifftn]) |
| 497 | def test_fft_with_order(dtype, order, fft): |
| 498 | # Check that FFT/IFFT produces identical results for C, Fortran and |
| 499 | # non contiguous arrays |
| 500 | rng = np.random.RandomState(42) |
| 501 | X = rng.rand(8, 7, 13).astype(dtype, copy=False) |
| 502 | # See discussion in pull/14178 |
| 503 | _tol = 8.0 * np.sqrt(np.log2(X.size)) * np.finfo(X.dtype).eps |
| 504 | if order == 'F': |
| 505 | Y = np.asfortranarray(X) |
| 506 | else: |
| 507 | # Make a non contiguous array |
| 508 | Y = X[::-1] |
| 509 | X = np.ascontiguousarray(X[::-1]) |
| 510 | |
| 511 | if fft.__name__.endswith('fft'): |
| 512 | for axis in range(3): |
| 513 | X_res = fft(X, axis=axis) |
| 514 | Y_res = fft(Y, axis=axis) |
| 515 | assert_allclose(X_res, Y_res, atol=_tol, rtol=_tol) |
| 516 | elif fft.__name__.endswith(('fft2', 'fftn')): |
| 517 | axes = [(0, 1), (1, 2), (0, 2)] |
| 518 | if fft.__name__.endswith('fftn'): |
| 519 | axes.extend([(0,), (1,), (2,), None]) |
| 520 | for ax in axes: |
| 521 | X_res = fft(X, axes=ax) |
| 522 | Y_res = fft(Y, axes=ax) |
| 523 | assert_allclose(X_res, Y_res, atol=_tol, rtol=_tol) |
| 524 | else: |
| 525 | raise ValueError |
| 526 | |
| 527 | |
| 528 | @pytest.mark.parametrize("order", ["F", "C"]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…