[Scipy-svn] r6927 - trunk/scipy/ndimage/tests

scipy-svn@scip... scipy-svn@scip...
Sat Nov 20 08:54:24 CST 2010


Author: warren.weckesser
Date: 2010-11-20 08:54:23 -0600 (Sat, 20 Nov 2010)
New Revision: 6927

Modified:
   trunk/scipy/ndimage/tests/test_ndimage.py
Log:
TST: ndimage: update a test to take into account single precision accuracy

Modified: trunk/scipy/ndimage/tests/test_ndimage.py
===================================================================
--- trunk/scipy/ndimage/tests/test_ndimage.py	2010-11-20 08:27:43 UTC (rev 6926)
+++ trunk/scipy/ndimage/tests/test_ndimage.py	2010-11-20 14:54:23 UTC (rev 6927)
@@ -457,7 +457,7 @@
         assert_equal(input.shape, output.shape)
 
     def test_gauss03(self):
-        "gaussian filter 3"
+        "gaussian filter 3 - single precision data"
         input = numpy.arange(100 * 100).astype(numpy.float32)
         input.shape = (100, 100)
         output = ndimage.gaussian_filter(input, [1.0, 1.0])
@@ -465,7 +465,9 @@
         assert_equal(input.dtype, output.dtype)
         assert_equal(input.shape, output.shape)
 
-        assert_almost_equal(output.sum(), input.sum())
+        # input.sum() is 49995000.0.  With single precision floats, we can't
+        # expect more than 8 digits of accuracy, so use decimal=0 in this test.
+        assert_almost_equal(output.sum(dtype='d'), input.sum(dtype='d'), decimal=0)
         assert_(sumsq(input, output) > 1.0)
 
     def test_gauss04(self):



More information about the Scipy-svn mailing list