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

scipy-svn@scip... scipy-svn@scip...
Sun Dec 14 16:42:38 CST 2008


Author: matthew.brett@gmail.com
Date: 2008-12-14 16:42:33 -0600 (Sun, 14 Dec 2008)
New Revision: 5261

Modified:
   trunk/scipy/ndimage/doccer.py
   trunk/scipy/ndimage/filters.py
   trunk/scipy/ndimage/tests/test_filters.py
Log:
New checks for order parameters for Gaussians, with tests

Modified: trunk/scipy/ndimage/doccer.py
===================================================================
--- trunk/scipy/ndimage/doccer.py	2008-12-14 17:30:56 UTC (rev 5260)
+++ trunk/scipy/ndimage/doccer.py	2008-12-14 22:42:33 UTC (rev 5261)
@@ -1,3 +1,6 @@
+''' Utilities to allow inserting docstring fragments for common
+parameters into function and method docstrings'''
+
 import sys
 
 def docformat(docstring, docdict=None):

Modified: trunk/scipy/ndimage/filters.py
===================================================================
--- trunk/scipy/ndimage/filters.py	2008-12-14 17:30:56 UTC (rev 5260)
+++ trunk/scipy/ndimage/filters.py	2008-12-14 22:42:33 UTC (rev 5261)
@@ -72,9 +72,6 @@
 """origin : scalar, optional
 The ``origin`` parameter controls the placement of the filter. Default 0"""
 _extra_arguments_doc = \
-"""extra_arguments : sequence
-    Sequence of extra positional arguments to pass to passed function"""
-_extra_arguments_doc = \
 """extra_arguments : sequence, optional
     Sequence of extra positional arguments to pass to passed function"""
 _extra_keywords_doc = \
@@ -179,6 +176,8 @@
     %(mode)s
     %(cval)s
     """
+    if order not in range(4):
+        raise ValueError('Order outside 0..3 not implemented')
     sd = float(sigma)
     # make the length of the filter equal to 4 times the standard
     # deviations:
@@ -257,6 +256,8 @@
     input = numpy.asarray(input)
     output, return_value = _ni_support._get_output(output, input)
     orders = _ni_support._normalize_sequence(order, input.ndim)
+    if not set(orders).issubset(set(range(4))):
+        raise ValueError('Order outside 0..4 not implemented')
     sigmas = _ni_support._normalize_sequence(sigma, input.ndim)
     axes = range(input.ndim)
     axes = [(axes[ii], sigmas[ii], orders[ii])

Modified: trunk/scipy/ndimage/tests/test_filters.py
===================================================================
--- trunk/scipy/ndimage/tests/test_filters.py	2008-12-14 17:30:56 UTC (rev 5260)
+++ trunk/scipy/ndimage/tests/test_filters.py	2008-12-14 22:42:33 UTC (rev 5261)
@@ -16,3 +16,15 @@
     # The following raises an error unless ticket 701 is fixed
     res2 = sndi.generic_filter(arr, func, size=1)
     assert_equal(res, res2)
+
+def test_orders_gauss():
+    # Check order inputs to Gaussians
+    arr = np.zeros((1,))
+    yield assert_equal, 0, sndi.gaussian_filter(arr, 1, order=0)
+    yield assert_equal, 0, sndi.gaussian_filter(arr, 1, order=3)
+    yield assert_raises, ValueError, sndi.gaussian_filter, arr, 1, -1
+    yield assert_raises, ValueError, sndi.gaussian_filter, arr, 1, 4
+    yield assert_equal, 0, sndi.gaussian_filter1d(arr, 1, axis=-1, order=0)
+    yield assert_equal, 0, sndi.gaussian_filter1d(arr, 1, axis=-1, order=3)
+    yield assert_raises, ValueError, sndi.gaussian_filter1d, arr, 1, -1, -1
+    yield assert_raises, ValueError, sndi.gaussian_filter1d, arr, 1, -1, 4



More information about the Scipy-svn mailing list