[Scipy-svn] r6220 - in trunk/scipy/fftpack: . tests

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Feb 8 10:18:27 EST 2010


Author: cdavid
Date: 2010-02-08 09:18:27 -0600 (Mon, 08 Feb 2010)
New Revision: 6220

Modified:
   trunk/scipy/fftpack/basic.py
   trunk/scipy/fftpack/tests/test_basic.py
Log:
BUG: fftn did not call single precision implementation if input was single precision.

Modified: trunk/scipy/fftpack/basic.py
===================================================================
--- trunk/scipy/fftpack/basic.py	2010-02-08 13:18:36 UTC (rev 6219)
+++ trunk/scipy/fftpack/basic.py	2010-02-08 15:18:27 UTC (rev 6220)
@@ -358,10 +358,13 @@
                                       hasattr(x,'__array__'))
         work_function = fftpack.zfftnd
     elif istype(tmp, numpy.complex64):
-        raise NotImplementedError
+        work_function = fftpack.cfftnd
     else:
         overwrite_x = 1
-        work_function = fftpack.zfftnd
+        if istype(tmp, numpy.float32):
+            work_function = fftpack.cfftnd
+        else:
+            work_function = fftpack.zfftnd
     return _raw_fftnd(tmp,shape,axes,1,overwrite_x,work_function)
 
 

Modified: trunk/scipy/fftpack/tests/test_basic.py
===================================================================
--- trunk/scipy/fftpack/tests/test_basic.py	2010-02-08 13:18:36 UTC (rev 6219)
+++ trunk/scipy/fftpack/tests/test_basic.py	2010-02-08 15:18:27 UTC (rev 6220)
@@ -321,6 +321,17 @@
         y_r = numpy.fft.fftn(x, s=(8, 8), axes=(-3,  -2))
         assert_array_almost_equal(y, y_r)
 
+class TestFftnSingle(TestCase):
+    def test_definition(self):
+        x = [[1,2,3],[4,5,6],[7,8,9]]
+        y = fftn(np.array(x, np.float32))
+        if not y.dtype == np.complex64:
+            raise ValueError("double precision output with single precision")
+
+        y_r = np.array(fftn(x), np.complex64)
+        assert_array_almost_equal_nulp(np.real(y), np.real(y_r))
+        assert_array_almost_equal_nulp(np.imag(y), np.imag(y_r))
+
 class TestFftn(TestCase):
 
     def test_definition(self):




More information about the Scipy-svn mailing list