summaryrefslogtreecommitdiff
path: root/numpy/fft
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/fft')
-rw-r--r--numpy/fft/__init__.py10
-rw-r--r--numpy/fft/_pocketfft.c31
-rw-r--r--numpy/fft/_pocketfft.py5
-rw-r--r--numpy/fft/helper.py2
-rw-r--r--numpy/fft/setup.py2
-rw-r--r--numpy/fft/tests/test_helper.py11
-rw-r--r--numpy/fft/tests/test_pocketfft.py14
7 files changed, 25 insertions, 50 deletions
diff --git a/numpy/fft/__init__.py b/numpy/fft/__init__.py
index fe95d8b17..36cfe81b3 100644
--- a/numpy/fft/__init__.py
+++ b/numpy/fft/__init__.py
@@ -118,8 +118,16 @@ The inverse DFT is defined as
It differs from the forward transform by the sign of the exponential
argument and the default normalization by :math:`1/n`.
+Type Promotion
+--------------
+
+`numpy.fft` promotes ``float32`` and ``complex64`` arrays to ``float64`` and
+``complex128`` arrays respectively. For an FFT implementation that does not
+promote input arrays, see `scipy.fftpack`.
+
Normalization
-------------
+
The default normalization has the direct transforms unscaled and the inverse
transforms are scaled by :math:`1/n`. It is possible to obtain unitary
transforms by setting the keyword argument ``norm`` to ``"ortho"`` (default is
@@ -183,8 +191,6 @@ For examples, see the various functions.
"""
-from __future__ import division, absolute_import, print_function
-
from ._pocketfft import *
from .helper import *
diff --git a/numpy/fft/_pocketfft.c b/numpy/fft/_pocketfft.c
index d75b9983c..764116a84 100644
--- a/numpy/fft/_pocketfft.c
+++ b/numpy/fft/_pocketfft.c
@@ -10,6 +10,11 @@
* \author Martin Reinecke
*/
+#define NPY_NO_DEPRECATED_API NPY_API_VERSION
+
+#include "Python.h"
+#include "numpy/arrayobject.h"
+
#include <math.h>
#include <string.h>
#include <stdlib.h>
@@ -2184,11 +2189,6 @@ WARN_UNUSED_RESULT static int rfft_forward(rfft_plan plan, double c[], double fc
return rfftblue_forward(plan->blueplan,c,fct);
}
-#define NPY_NO_DEPRECATED_API NPY_API_VERSION
-
-#include "Python.h"
-#include "numpy/arrayobject.h"
-
static PyObject *
execute_complex(PyObject *a1, int is_forward, double fct)
{
@@ -2359,7 +2359,6 @@ static struct PyMethodDef methods[] = {
{NULL, NULL, 0, NULL} /* sentinel */
};
-#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_pocketfft_internal",
@@ -2371,30 +2370,14 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
/* Initialization function for the module */
-#if PY_MAJOR_VERSION >= 3
-#define RETVAL(x) x
PyMODINIT_FUNC PyInit__pocketfft_internal(void)
-#else
-#define RETVAL(x)
-PyMODINIT_FUNC
-init_pocketfft_internal(void)
-#endif
{
PyObject *m;
-#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&moduledef);
-#else
- static const char module_documentation[] = "";
-
- m = Py_InitModule4("_pocketfft_internal", methods,
- module_documentation,
- (PyObject*)NULL,PYTHON_API_VERSION);
-#endif
if (m == NULL) {
- return RETVAL(NULL);
+ return NULL;
}
/* Import the array object */
@@ -2402,5 +2385,5 @@ init_pocketfft_internal(void)
/* XXXX Add constants here */
- return RETVAL(m);
+ return m;
}
diff --git a/numpy/fft/_pocketfft.py b/numpy/fft/_pocketfft.py
index 50720cda4..3eab242e5 100644
--- a/numpy/fft/_pocketfft.py
+++ b/numpy/fft/_pocketfft.py
@@ -27,8 +27,6 @@ n = n-dimensional transform
behavior.)
"""
-from __future__ import division, absolute_import, print_function
-
__all__ = ['fft', 'ifft', 'rfft', 'irfft', 'hfft', 'ihfft', 'rfftn',
'irfftn', 'rfft2', 'irfft2', 'fft2', 'ifft2', 'fftn', 'ifftn']
@@ -61,12 +59,11 @@ def _raw_fft(a, n, axis, is_real, is_forward, inv_norm):
if a.shape[axis] != n:
s = list(a.shape)
+ index = [slice(None)]*len(s)
if s[axis] > n:
- index = [slice(None)]*len(s)
index[axis] = slice(0, n)
a = a[tuple(index)]
else:
- index = [slice(None)]*len(s)
index[axis] = slice(0, s[axis])
s[axis] = n
z = zeros(s, a.dtype.char)
diff --git a/numpy/fft/helper.py b/numpy/fft/helper.py
index a920a4ac0..3dacd9ee1 100644
--- a/numpy/fft/helper.py
+++ b/numpy/fft/helper.py
@@ -2,8 +2,6 @@
Discrete Fourier Transforms - helper.py
"""
-from __future__ import division, absolute_import, print_function
-
from numpy.compat import integer_types
from numpy.core import integer, empty, arange, asarray, roll
from numpy.core.overrides import array_function_dispatch, set_module
diff --git a/numpy/fft/setup.py b/numpy/fft/setup.py
index 8c3a31557..40d632ec5 100644
--- a/numpy/fft/setup.py
+++ b/numpy/fft/setup.py
@@ -1,5 +1,3 @@
-from __future__ import division, print_function
-
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
diff --git a/numpy/fft/tests/test_helper.py b/numpy/fft/tests/test_helper.py
index 6613c8002..68f5990af 100644
--- a/numpy/fft/tests/test_helper.py
+++ b/numpy/fft/tests/test_helper.py
@@ -3,13 +3,12 @@
Copied from fftpack.helper by Pearu Peterson, October 2005
"""
-from __future__ import division, absolute_import, print_function
import numpy as np
-from numpy.testing import assert_array_almost_equal, assert_equal
+from numpy.testing import assert_array_almost_equal
from numpy import fft, pi
-class TestFFTShift(object):
+class TestFFTShift:
def test_definition(self):
x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
@@ -135,7 +134,7 @@ class TestFFTShift(object):
original_ifftshift(inp, axes_keyword))
-class TestFFTFreq(object):
+class TestFFTFreq:
def test_definition(self):
x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
@@ -146,7 +145,7 @@ class TestFFTFreq(object):
assert_array_almost_equal(10*pi*fft.fftfreq(10, pi), x)
-class TestRFFTFreq(object):
+class TestRFFTFreq:
def test_definition(self):
x = [0, 1, 2, 3, 4]
@@ -157,7 +156,7 @@ class TestRFFTFreq(object):
assert_array_almost_equal(10*pi*fft.rfftfreq(10, pi), x)
-class TestIRFFTN(object):
+class TestIRFFTN:
def test_not_last_axis_success(self):
ar, ai = np.random.random((2, 16, 8, 32))
diff --git a/numpy/fft/tests/test_pocketfft.py b/numpy/fft/tests/test_pocketfft.py
index 453e964fa..7c3db0485 100644
--- a/numpy/fft/tests/test_pocketfft.py
+++ b/numpy/fft/tests/test_pocketfft.py
@@ -1,5 +1,3 @@
-from __future__ import division, absolute_import, print_function
-
import numpy as np
import pytest
from numpy.random import random
@@ -7,11 +5,7 @@ from numpy.testing import (
assert_array_equal, assert_raises, assert_allclose
)
import threading
-import sys
-if sys.version_info[0] >= 3:
- import queue
-else:
- import Queue as queue
+import queue
def fft1(x):
@@ -21,13 +15,13 @@ def fft1(x):
return np.sum(x*np.exp(phase), axis=1)
-class TestFFTShift(object):
+class TestFFTShift:
def test_fft_n(self):
assert_raises(ValueError, np.fft.fft, [1, 2, 3], 0)
-class TestFFT1D(object):
+class TestFFT1D:
def test_identity(self):
maxlen = 512
@@ -222,7 +216,7 @@ def test_fft_with_order(dtype, order, fft):
raise ValueError()
-class TestFFTThreadSafe(object):
+class TestFFTThreadSafe:
threads = 16
input_shape = (800, 200)