summaryrefslogtreecommitdiff
path: root/numpy/fft/helper.py
diff options
context:
space:
mode:
authorChristoph Gohlke <cgohlke@uci.edu>2013-09-07 19:10:21 -0700
committerChristoph Gohlke <cgohlke@uci.edu>2013-09-07 19:10:21 -0700
commitfe05eaca668e4b73ac07995017b1575f40582ca2 (patch)
tree108ed7f3ddb9b0b6fcb28480593a25ef01effc47 /numpy/fft/helper.py
parent260433c574fdf0a8e97134853e8149e95b947f9a (diff)
downloadpython-numpy-fe05eaca668e4b73ac07995017b1575f40582ca2.tar.gz
python-numpy-fe05eaca668e4b73ac07995017b1575f40582ca2.tar.bz2
python-numpy-fe05eaca668e4b73ac07995017b1575f40582ca2.zip
BUG: check axes and window length input for all integer types
On Python 2.7, the long type was excluded.
Diffstat (limited to 'numpy/fft/helper.py')
-rw-r--r--numpy/fft/helper.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/numpy/fft/helper.py b/numpy/fft/helper.py
index e70e408fa..160120e58 100644
--- a/numpy/fft/helper.py
+++ b/numpy/fft/helper.py
@@ -4,7 +4,7 @@ Discrete Fourier Transforms - helper.py
"""
from __future__ import division, absolute_import, print_function
-import numpy.core.numerictypes as nt
+from numpy.compat import integer_types
from numpy.core import (
asarray, concatenate, arange, take, integer, empty
)
@@ -13,6 +13,8 @@ from numpy.core import (
__all__ = ['fftshift', 'ifftshift', 'fftfreq', 'rfftfreq']
+integer_types = integer_types + (integer,)
+
def fftshift(x, axes=None):
"""
@@ -62,7 +64,7 @@ def fftshift(x, axes=None):
ndim = len(tmp.shape)
if axes is None:
axes = list(range(ndim))
- elif isinstance(axes, (int, nt.integer)):
+ elif isinstance(axes, integer_types):
axes = (axes,)
y = tmp
for k in axes:
@@ -111,7 +113,7 @@ def ifftshift(x, axes=None):
ndim = len(tmp.shape)
if axes is None:
axes = list(range(ndim))
- elif isinstance(axes, (int, nt.integer)):
+ elif isinstance(axes, integer_types):
axes = (axes,)
y = tmp
for k in axes:
@@ -158,7 +160,7 @@ def fftfreq(n, d=1.0):
array([ 0. , 1.25, 2.5 , 3.75, -5. , -3.75, -2.5 , -1.25])
"""
- if not (isinstance(n, int) or isinstance(n, integer)):
+ if not isinstance(n, integer_types):
raise ValueError("n should be an integer")
val = 1.0 / (n * d)
results = empty(n, int)
@@ -214,7 +216,7 @@ def rfftfreq(n, d=1.0):
array([ 0., 10., 20., 30., 40., 50.])
"""
- if not (isinstance(n, int) or isinstance(n, integer)):
+ if not isinstance(n, integer_types):
raise ValueError("n should be an integer")
val = 1.0/(n*d)
N = n//2 + 1