[Scipy-svn] r2890 - in trunk/Lib/ndimage: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Thu Mar 29 08:36:58 EDT 2007
Author: stefan
Date: 2007-03-29 07:36:36 -0500 (Thu, 29 Mar 2007)
New Revision: 2890
Modified:
trunk/Lib/ndimage/_ni_support.py
trunk/Lib/ndimage/tests/test_ndimage.py
Log:
Add boundary tests. Enable 'mirror' mode.
Modified: trunk/Lib/ndimage/_ni_support.py
===================================================================
--- trunk/Lib/ndimage/_ni_support.py 2007-03-29 12:07:01 UTC (rev 2889)
+++ trunk/Lib/ndimage/_ni_support.py 2007-03-29 12:36:36 UTC (rev 2890)
@@ -40,6 +40,8 @@
return 1
elif mode == 'reflect':
return 2
+ elif mode == 'mirror':
+ return 3
elif mode == 'constant':
return 4
else:
Modified: trunk/Lib/ndimage/tests/test_ndimage.py
===================================================================
--- trunk/Lib/ndimage/tests/test_ndimage.py 2007-03-29 12:07:01 UTC (rev 2889)
+++ trunk/Lib/ndimage/tests/test_ndimage.py 2007-03-29 12:36:36 UTC (rev 2890)
@@ -70,8 +70,6 @@
numpy.uint16, numpy.int32, numpy.uint32,
numpy.int64, numpy.uint64,
numpy.float32, numpy.float64]
-## if numinclude.hasUInt64:
-## self.types.append(numpy.UInt64)
# list of boundary modes:
self.modes = ['nearest', 'wrap', 'reflect', 'constant']
@@ -1296,6 +1294,24 @@
mode = mode, cval = 0)
self.failUnless(diff(output, true_value) < eps)
+ def test_boundaries(self):
+ "boundary modes"
+ def shift(x):
+ return (x[0] + 0.1,)
+
+ data = numpy.array([1,2,3,4])
+ expected = {'constant': [1,2,3,-1,-1,-1],
+ 'wrap': [1,2,3,4,1,2],
+ 'reflect' : [1,2,3,4,4,3],
+ 'mirror' : [1,2,3,4,3,2],
+ 'nearest' : [1,2,3,4,4,4]}
+
+ for mode in expected.keys():
+ assert_array_equal(expected[mode],
+ ndimage.geometric_transform(data,shift,
+ cval=-1,mode=mode,
+ output_shape=(6,)))
+
def test_fourier_gaussian_real01(self):
"gaussian fourier filter for real transforms 1"
for shape in [(32, 16), (31, 15)]:
More information about the Scipy-svn
mailing list