[Scipy-svn] r4904 - in trunk/scipy/ndimage: . tests

scipy-svn@scip... scipy-svn@scip...
Sat Nov 1 16:16:43 CDT 2008


Author: stefan
Date: 2008-11-01 16:16:31 -0500 (Sat, 01 Nov 2008)
New Revision: 4904

Modified:
   trunk/scipy/ndimage/interpolation.py
   trunk/scipy/ndimage/tests/test_regression.py
Log:
Correctly assert output shape in `zoom` [patch by Pieter Holtzhausen].

Modified: trunk/scipy/ndimage/interpolation.py
===================================================================
--- trunk/scipy/ndimage/interpolation.py	2008-11-01 20:56:33 UTC (rev 4903)
+++ trunk/scipy/ndimage/interpolation.py	2008-11-01 21:16:31 UTC (rev 4904)
@@ -321,7 +321,7 @@
     else:
         filtered = input
     zoom = _ni_support._normalize_sequence(zoom, input.ndim)
-    output_shape = [int(ii * jj) for ii, jj in zip(input.shape, zoom)]
+    output_shape = tuple([int(ii * jj) for ii, jj in zip(input.shape, zoom)])
     zoom = (numpy.array(input.shape)-1)/(numpy.array(output_shape,float)-1)
     output, return_value = _ni_support._get_output(output, input,
                                         output_type, shape = output_shape)

Modified: trunk/scipy/ndimage/tests/test_regression.py
===================================================================
--- trunk/scipy/ndimage/tests/test_regression.py	2008-11-01 20:56:33 UTC (rev 4903)
+++ trunk/scipy/ndimage/tests/test_regression.py	2008-11-01 21:16:31 UTC (rev 4904)
@@ -11,5 +11,10 @@
     t = ndimage.filters.median_filter(b, (3, 3))
     assert_array_almost_equal(ref, t)
 
+def test_zoom_output_shape():
+    """Ticket #643"""
+    x = np.arange(12).reshape((3,4))
+    ndimage.zoom(x, 2, output=np.zeros((6,8)))
+
 if __name__ == "__main__":
     NumpyTest().run()



More information about the Scipy-svn mailing list