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

Function test_fft_with_order

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

Source from the content-addressed store, hash-verified

238 [np.fft.fft, np.fft.fft2, np.fft.fftn,
239 np.fft.ifft, np.fft.ifft2, np.fft.ifftn])
240def test_fft_with_order(dtype, order, fft):
241 # Check that FFT/IFFT produces identical results for C, Fortran and
242 # non contiguous arrays
243 rng = np.random.RandomState(42)
244 X = rng.rand(8, 7, 13).astype(dtype, copy=False)
245 # See discussion in pull/14178
246 _tol = 8.0 * np.sqrt(np.log2(X.size)) * np.finfo(X.dtype).eps
247 if order == 'F':
248 Y = np.asfortranarray(X)
249 else:
250 # Make a non contiguous array
251 Y = X[::-1]
252 X = np.ascontiguousarray(X[::-1])
253
254 if fft.__name__.endswith('fft'):
255 for axis in range(3):
256 X_res = fft(X, axis=axis)
257 Y_res = fft(Y, axis=axis)
258 assert_allclose(X_res, Y_res, atol=_tol, rtol=_tol)
259 elif fft.__name__.endswith(('fft2', 'fftn')):
260 axes = [(0, 1), (1, 2), (0, 2)]
261 if fft.__name__.endswith('fftn'):
262 axes.extend([(0,), (1,), (2,), None])
263 for ax in axes:
264 X_res = fft(X, axes=ax)
265 Y_res = fft(Y, axes=ax)
266 assert_allclose(X_res, Y_res, atol=_tol, rtol=_tol)
267 else:
268 raise ValueError()
269
270
271@pytest.mark.skipif(IS_WASM, reason="Cannot start thread")

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