MCPcopy Create free account
hub / github.com/numpy/numpy / test_fft_with_order

Function test_fft_with_order

numpy/fft/tests/test_pocketfft.py:497–525  ·  view source on GitHub ↗
(dtype, order, fft)

Source from the content-addressed store, hash-verified

495 [np.fft.fft, np.fft.fft2, np.fft.fftn,
496 np.fft.ifft, np.fft.ifft2, np.fft.ifftn])
497def 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"])

Callers

nothing calls this directly

Calls 4

assert_allcloseFunction · 0.90
fftFunction · 0.85
astypeMethod · 0.80
endswithMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…