From fe05eaca668e4b73ac07995017b1575f40582ca2 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Sat, 7 Sep 2013 19:10:21 -0700 Subject: BUG: check axes and window length input for all integer types On Python 2.7, the long type was excluded. --- numpy/fft/helper.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'numpy/fft/helper.py') 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 -- cgit v1.2.3