diff options
author | Jaime <jaime.frio@gmail.com> | 2015-06-02 15:44:02 -0700 |
---|---|---|
committer | Jaime <jaime.frio@gmail.com> | 2015-06-02 15:44:02 -0700 |
commit | 17d7e4147c8eaf908bf84a3ee4741568da95e182 (patch) | |
tree | 0dc3862a4c3ad1f84e9d8f872797dfcdad450995 | |
parent | f535f71dfced2164e095871bf2d7f82b9e6d052d (diff) | |
parent | d1f656a3a8d79d6562541c83e55e79ea06fdfce8 (diff) | |
download | numpy-17d7e4147c8eaf908bf84a3ee4741568da95e182.tar.gz |
Merge pull request #5910 from argriffing/more-astype-auditing
MAINT: explicit fft copy
-rw-r--r-- | numpy/fft/fftpack.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/numpy/fft/fftpack.py b/numpy/fft/fftpack.py index 4efb2a9a0..e12ae1eec 100644 --- a/numpy/fft/fftpack.py +++ b/numpy/fft/fftpack.py @@ -35,13 +35,13 @@ from __future__ import division, absolute_import, print_function __all__ = ['fft', 'ifft', 'rfft', 'irfft', 'hfft', 'ihfft', 'rfftn', 'irfftn', 'rfft2', 'irfft2', 'fft2', 'ifft2', 'fftn', 'ifftn'] -from numpy.core import asarray, zeros, swapaxes, shape, conjugate, \ - take +from numpy.core import array, asarray, zeros, swapaxes, shape, conjugate, take from . import fftpack_lite as fftpack _fft_cache = {} _real_fft_cache = {} + def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti, work_function=fftpack.cfftf, fft_cache=_fft_cache): a = asarray(a) @@ -248,8 +248,8 @@ def ifft(a, n=None, axis=-1): >>> plt.show() """ - - a = asarray(a).astype(complex) + # The copy may be required for multithreading. + a = array(a, copy=True, dtype=complex) if n is None: n = shape(a)[axis] return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftb, _fft_cache) / n @@ -329,8 +329,8 @@ def rfft(a, n=None, axis=-1): exploited to compute only the non-negative frequency terms. """ - - a = asarray(a).astype(float) + # The copy may be required for multithreading. + a = array(a, copy=True, dtype=float) return _raw_fft(a, n, axis, fftpack.rffti, fftpack.rfftf, _real_fft_cache) @@ -410,8 +410,8 @@ def irfft(a, n=None, axis=-1): specified, and the output array is purely real. """ - - a = asarray(a).astype(complex) + # The copy may be required for multithreading. + a = array(a, copy=True, dtype=complex) if n is None: n = (shape(a)[axis] - 1) * 2 return _raw_fft(a, n, axis, fftpack.rffti, fftpack.rfftb, @@ -484,8 +484,8 @@ def hfft(a, n=None, axis=-1): [ 2., -2.]]) """ - - a = asarray(a).astype(complex) + # The copy may be required for multithreading. + a = array(a, copy=True, dtype=complex) if n is None: n = (shape(a)[axis] - 1) * 2 return irfft(conjugate(a), n, axis) * n @@ -538,8 +538,8 @@ def ihfft(a, n=None, axis=-1): array([ 1.-0.j, 2.-0.j, 3.-0.j, 4.-0.j]) """ - - a = asarray(a).astype(float) + # The copy may be required for multithreading. + a = array(a, copy=True, dtype=float) if n is None: n = shape(a)[axis] return conjugate(rfft(a, n, axis))/n @@ -1007,8 +1007,8 @@ def rfftn(a, s=None, axes=None): [ 0.+0.j, 0.+0.j]]]) """ - - a = asarray(a).astype(float) + # The copy may be required for multithreading. + a = array(a, copy=True, dtype=float) s, axes = _cook_nd_args(a, s, axes) a = rfft(a, s[-1], axes[-1]) for ii in range(len(axes)-1): @@ -1128,8 +1128,8 @@ def irfftn(a, s=None, axes=None): [ 1., 1.]]]) """ - - a = asarray(a).astype(complex) + # The copy may be required for multithreading. + a = array(a, copy=True, dtype=complex) s, axes = _cook_nd_args(a, s, axes, invreal=1) for ii in range(len(axes)-1): a = ifft(a, s[ii], axes[ii]) |