[Scipy-svn] r2903 - trunk/Lib/ndimage

scipy-svn@scip... scipy-svn@scip...
Wed Apr 11 16:50:58 CDT 2007


Author: stefan
Date: 2007-04-11 16:50:46 -0500 (Wed, 11 Apr 2007)
New Revision: 2903

Modified:
   trunk/Lib/ndimage/interpolation.py
Log:
Warn against using 'reflect' mode for interpolation.


Modified: trunk/Lib/ndimage/interpolation.py
===================================================================
--- trunk/Lib/ndimage/interpolation.py	2007-04-10 22:04:33 UTC (rev 2902)
+++ trunk/Lib/ndimage/interpolation.py	2007-04-11 21:50:46 UTC (rev 2903)
@@ -30,10 +30,17 @@
 
 import types
 import math
+import warnings
 import numpy
 import _ni_support
 import _nd_image
 
+def _extend_mode_to_code(mode):
+    mode = _ni_support._extend_mode_to_code(mode)
+    if mode == 2:
+        warnings.warn('Mode "reflect" may yield incorrect results on '
+                      'boundaries. Please use "mirror" instead.')
+    return mode
 
 def spline_filter1d(input, order = 3, axis = -1, output = numpy.float64,
                     output_type = None):
@@ -126,7 +133,7 @@
         output_shape = input.shape
     if input.ndim < 1 or len(output_shape) < 1:
         raise RuntimeError, 'input and output rank must be > 0'
-    mode = _ni_support._extend_mode_to_code(mode)
+    mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
     else:
@@ -188,7 +195,7 @@
         raise RuntimeError, 'input and output rank must be > 0'
     if coordinates.shape[0] != input.ndim:
         raise RuntimeError, 'invalid shape for coordinate array'
-    mode = _ni_support._extend_mode_to_code(mode)
+    mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
     else:
@@ -229,7 +236,7 @@
         output_shape = input.shape
     if input.ndim < 1 or len(output_shape) < 1:
         raise RuntimeError, 'input and output rank must be > 0'
-    mode = _ni_support._extend_mode_to_code(mode)
+    mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
     else:
@@ -277,7 +284,7 @@
         raise TypeError, 'Complex type not supported'
     if input.ndim < 1:
         raise RuntimeError, 'input and output rank must be > 0'
-    mode = _ni_support._extend_mode_to_code(mode)
+    mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
     else:
@@ -310,7 +317,7 @@
         raise TypeError, 'Complex type not supported'
     if input.ndim < 1:
         raise RuntimeError, 'input and output rank must be > 0'
-    mode = _ni_support._extend_mode_to_code(mode)
+    mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
     else:



More information about the Scipy-svn mailing list