summaryrefslogtreecommitdiff
path: root/numpy/fft/tests
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2012-03-05 08:11:32 -0700
committerCharles Harris <charlesr.harris@gmail.com>2012-03-05 08:17:38 -0700
commit7d225bb13db65de26d504559d815aac775ed0426 (patch)
treed466bec115c4ed40ef8261d9e05c2f3fe35966de /numpy/fft/tests
parent88a02920daf0b408086106439c53bd488e73af29 (diff)
downloadnumpy-7d225bb13db65de26d504559d815aac775ed0426.tar.gz
STY: Code cleanups.
Don't do from numpy.testing import *, put spaces after commas, etc.
Diffstat (limited to 'numpy/fft/tests')
-rw-r--r--numpy/fft/tests/test_fftpack.py12
-rw-r--r--numpy/fft/tests/test_helper.py40
2 files changed, 29 insertions, 23 deletions
diff --git a/numpy/fft/tests/test_fftpack.py b/numpy/fft/tests/test_fftpack.py
index 4f70d3bc5..dceb3bd89 100644
--- a/numpy/fft/tests/test_fftpack.py
+++ b/numpy/fft/tests/test_fftpack.py
@@ -1,18 +1,22 @@
-from numpy.testing import *
+from __future__ import division
+
import numpy as np
+from numpy.testing import TestCase, run_module_suite, assert_array_almost_equal
def fft1(x):
L = len(x)
phase = -2j*np.pi*(np.arange(L)/float(L))
- phase = np.arange(L).reshape(-1,1) * phase
- return np.sum(x*np.exp(phase),axis=1)
+ phase = np.arange(L).reshape(-1, 1) * phase
+ return np.sum(x*np.exp(phase), axis=1)
class TestFFTShift(TestCase):
+
def test_fft_n(self):
- self.assertRaises(ValueError,np.fft.fft,[1,2,3],0)
+ self.assertRaises(ValueError, np.fft.fft, [1, 2, 3], 0)
class TestFFT1D(TestCase):
+
def test_basic(self):
rand = np.random.random
x = rand(30) + 1j*rand(30)
diff --git a/numpy/fft/tests/test_helper.py b/numpy/fft/tests/test_helper.py
index 09ccb2b18..c5578d390 100644
--- a/numpy/fft/tests/test_helper.py
+++ b/numpy/fft/tests/test_helper.py
@@ -2,30 +2,30 @@
# Copied from fftpack.helper by Pearu Peterson, October 2005
""" Test functions for fftpack.helper module
"""
+from __future__ import division
import numpy as np
-from numpy.testing import *
+from numpy.testing import TestCase, run_module_suite, assert_array_almost_equal
from numpy import fft
from numpy import pi
-def random(size):
- return rand(*size)
class TestFFTShift(TestCase):
+
def test_definition(self):
- x = [0,1,2,3,4,-4,-3,-2,-1]
- y = [-4,-3,-2,-1,0,1,2,3,4]
- assert_array_almost_equal(fft.fftshift(x),y)
- assert_array_almost_equal(fft.ifftshift(y),x)
- x = [0,1,2,3,4,-5,-4,-3,-2,-1]
- y = [-5,-4,-3,-2,-1,0,1,2,3,4]
- assert_array_almost_equal(fft.fftshift(x),y)
- assert_array_almost_equal(fft.ifftshift(y),x)
+ x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
+ y = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
+ assert_array_almost_equal(fft.fftshift(x), y)
+ assert_array_almost_equal(fft.ifftshift(y), x)
+ x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
+ y = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]
+ assert_array_almost_equal(fft.fftshift(x), y)
+ assert_array_almost_equal(fft.ifftshift(y), x)
def test_inverse(self):
for n in [1,4,9,100,211]:
- x = random((n,))
- assert_array_almost_equal(fft.ifftshift(fft.fftshift(x)),x)
+ x = np.random.random((n,))
+ assert_array_almost_equal(fft.ifftshift(fft.fftshift(x)), x)
def test_axes_keyword(self):
freqs = [[ 0, 1, 2], [ 3, 4, -4], [-3, -2, -1]]
@@ -39,13 +39,15 @@ class TestFFTShift(TestCase):
class TestFFTFreq(TestCase):
+
def test_definition(self):
- x = [0,1,2,3,4,-4,-3,-2,-1]
- assert_array_almost_equal(9*fft.fftfreq(9),x)
- assert_array_almost_equal(9*pi*fft.fftfreq(9,pi),x)
- x = [0,1,2,3,4,-5,-4,-3,-2,-1]
- assert_array_almost_equal(10*fft.fftfreq(10),x)
- assert_array_almost_equal(10*pi*fft.fftfreq(10,pi),x)
+ x = [0, 1, 2, 3, 4, -4, -3, -2, -1]
+ assert_array_almost_equal(9*fft.fftfreq(9), x)
+ assert_array_almost_equal(9*pi*fft.fftfreq(9, pi), x)
+ x = [0, 1, 2, 3, 4, -5, -4, -3, -2, -1]
+ assert_array_almost_equal(10*fft.fftfreq(10), x)
+ assert_array_almost_equal(10*pi*fft.fftfreq(10, pi), x)
+
class TestIRFFTN(TestCase):