[Scipy-svn] r6922 - trunk/scipy/ndimage

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Nov 20 02:52:46 EST 2010


Author: warren.weckesser
Date: 2010-11-20 01:52:46 -0600 (Sat, 20 Nov 2010)
New Revision: 6922

Modified:
   trunk/scipy/ndimage/_ni_support.py
   trunk/scipy/ndimage/filters.py
   trunk/scipy/ndimage/fourier.py
   trunk/scipy/ndimage/interpolation.py
   trunk/scipy/ndimage/measurements.py
   trunk/scipy/ndimage/morphology.py
Log:
ENH: ndimage: update 'raise' statements

Modified: trunk/scipy/ndimage/_ni_support.py
===================================================================
--- trunk/scipy/ndimage/_ni_support.py	2010-11-20 07:33:29 UTC (rev 6921)
+++ trunk/scipy/ndimage/_ni_support.py	2010-11-20 07:52:46 UTC (rev 6922)
@@ -45,7 +45,7 @@
     elif mode == 'constant':
         return 4
     else:
-        raise RuntimeError, 'boundary mode not supported'
+        raise RuntimeError('boundary mode not supported')
 
 def _normalize_sequence(input, rank, array_type = None):
     """If input is a scalar, create a sequence of length equal to the
@@ -59,7 +59,7 @@
         normalized = list(input)
         if len(normalized) != rank:
             err = "sequence argument must have length equal to input rank"
-            raise RuntimeError, err
+            raise RuntimeError(err)
     return normalized
 
 import warnings
@@ -67,13 +67,13 @@
     if output_type is not None:
         msg = "'output_type' argument is deprecated."
         msg += " Assign type to 'output' instead."
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
         warnings.warn(msg, DeprecationWarning)
         if output is None:
             output = output_type
         elif ((type(output) is not type(types.TypeType)) or
               output.dtype != output_type):
-            raise RuntimeError, "'output' type and 'output_type' not equal"
+            raise RuntimeError("'output' type and 'output_type' not equal")
     if shape is None:
         shape = input.shape
     if output is None:
@@ -88,7 +88,7 @@
         return_value = output
     else:
         if output.shape != shape:
-            raise RuntimeError, "output shape not correct"
+            raise RuntimeError("output shape not correct")
         return_value = None
     return output, return_value
 
@@ -96,5 +96,5 @@
     if axis < 0:
         axis += rank
     if axis < 0 or axis >= rank:
-        raise ValueError, 'invalid axis'
+        raise ValueError('invalid axis')
     return axis

Modified: trunk/scipy/ndimage/filters.py
===================================================================
--- trunk/scipy/ndimage/filters.py	2010-11-20 07:33:29 UTC (rev 6921)
+++ trunk/scipy/ndimage/filters.py	2010-11-20 07:52:46 UTC (rev 6922)
@@ -113,17 +113,17 @@
     """
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     output, return_value = _ni_support._get_output(output, input)
     weights = numpy.asarray(weights, dtype=numpy.float64)
     if weights.ndim != 1 or weights.shape[0] < 1:
-        raise RuntimeError, 'no filter weights given'
+        raise RuntimeError('no filter weights given')
     if not weights.flags.contiguous:
         weights = weights.copy()
     axis = _ni_support._check_axis(axis, input.ndim)
     if ((len(weights) // 2 + origin < 0) or
         (len(weights) // 2 + origin > len(weights))):
-        raise ValueError, 'invalid origin'
+        raise ValueError('invalid origin')
     mode = _ni_support._extend_mode_to_code(mode)
     _nd_image.correlate1d(input, weights, axis, output, mode, cval,
                           origin)
@@ -473,12 +473,12 @@
                            convolution):
     input = numpy.asarray(input)
     if numpy.iscomplexobj(int):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     origins = _ni_support._normalize_sequence(origin, input.ndim)
     weights = numpy.asarray(weights, dtype=numpy.float64)
     wshape = [ii for ii in weights.shape if ii > 0]
     if len(wshape) != input.ndim:
-        raise RuntimeError, 'filter weights array has incorrect shape.'
+        raise RuntimeError('filter weights array has incorrect shape.')
     if convolution:
         weights = weights[tuple([slice(None, None, -1)] * weights.ndim)]
         for ii in range(len(origins)):
@@ -487,7 +487,7 @@
                 origins[ii] -= 1
     for origin, lenw in zip(origins, wshape):
         if (lenw // 2 + origin < 0) or (lenw // 2 + origin > lenw):
-            raise ValueError, 'invalid origin'
+            raise ValueError('invalid origin')
     if not weights.flags.contiguous:
         weights = weights.copy()
     output, return_value = _ni_support._get_output(output, input)
@@ -667,13 +667,13 @@
     """
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     axis = _ni_support._check_axis(axis, input.ndim)
     if size < 1:
-        raise RuntimeError, 'incorrect filter size'
+        raise RuntimeError('incorrect filter size')
     output, return_value = _ni_support._get_output(output, input)
     if (size // 2 + origin < 0) or (size // 2 + origin > size):
-        raise ValueError, 'invalid origin'
+        raise ValueError('invalid origin')
     mode = _ni_support._extend_mode_to_code(mode)
     _nd_image.uniform_filter1d(input, size, axis, output, mode, cval,
                                origin)
@@ -743,13 +743,13 @@
     """
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     axis = _ni_support._check_axis(axis, input.ndim)
     if size < 1:
-        raise RuntimeError, 'incorrect filter size'
+        raise RuntimeError('incorrect filter size')
     output, return_value = _ni_support._get_output(output, input)
     if (size // 2 + origin < 0) or (size // 2 + origin > size):
-        raise ValueError, 'invalid origin'
+        raise ValueError('invalid origin')
     mode = _ni_support._extend_mode_to_code(mode)
     _nd_image.min_or_max_filter1d(input, size, axis, output, mode, cval,
                                   origin, 1)
@@ -777,13 +777,13 @@
     """
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     axis = _ni_support._check_axis(axis, input.ndim)
     if size < 1:
-        raise RuntimeError, 'incorrect filter size'
+        raise RuntimeError('incorrect filter size')
     output, return_value = _ni_support._get_output(output, input)
     if (size // 2 + origin < 0) or (size // 2 + origin > size):
-        raise ValueError, 'invalid origin'
+        raise ValueError('invalid origin')
     mode = _ni_support._extend_mode_to_code(mode)
     _nd_image.min_or_max_filter1d(input, size, axis, output, mode, cval,
                                   origin, 0)
@@ -795,7 +795,7 @@
     if structure is None:
         if footprint is None:
             if size is None:
-                raise RuntimeError, "no footprint provided"
+                raise RuntimeError("no footprint provided")
             separable= True
         else:
             footprint = numpy.asarray(footprint)
@@ -816,7 +816,7 @@
             footprint = footprint.astype(bool)
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     output, return_value = _ni_support._get_output(output, input)
     origins = _ni_support._normalize_sequence(origin, input.ndim)
     if separable:
@@ -837,15 +837,15 @@
     else:
         fshape = [ii for ii in footprint.shape if ii > 0]
         if len(fshape) != input.ndim:
-            raise RuntimeError, 'footprint array has incorrect shape.'
+            raise RuntimeError('footprint array has incorrect shape.')
         for origin, lenf in zip(origins, fshape):
             if (lenf // 2 + origin < 0) or (lenf // 2 + origin > lenf):
-                raise ValueError, 'invalid origin'
+                raise ValueError('invalid origin')
         if not footprint.flags.contiguous:
             footprint = footprint.copy()
         if structure is not None:
             if len(structure.shape) != input.ndim:
-                raise RuntimeError, 'structure array has incorrect shape'
+                raise RuntimeError('structure array has incorrect shape')
             if not structure.flags.contiguous:
                 structure = structure.copy()
         mode = _ni_support._extend_mode_to_code(mode)
@@ -895,21 +895,21 @@
      mode = "reflect", cval = 0.0, origin = 0, operation = 'rank'):
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     origins = _ni_support._normalize_sequence(origin, input.ndim)
     if footprint is None:
         if size is None:
-            raise RuntimeError, "no footprint or filter size provided"
+            raise RuntimeError("no footprint or filter size provided")
         sizes = _ni_support._normalize_sequence(size, input.ndim)
         footprint = numpy.ones(sizes, dtype=bool)
     else:
         footprint = numpy.asarray(footprint, dtype=bool)
     fshape = [ii for ii in footprint.shape if ii > 0]
     if len(fshape) != input.ndim:
-        raise RuntimeError, 'filter footprint array has incorrect shape.'
+        raise RuntimeError('filter footprint array has incorrect shape.')
     for origin, lenf in zip(origins, fshape):
         if (lenf // 2 + origin < 0) or (lenf // 2 + origin > lenf):
-            raise ValueError, 'invalid origin'
+            raise ValueError('invalid origin')
     if not footprint.flags.contiguous:
         footprint = footprint.copy()
     filter_size = numpy.where(footprint, 1, 0).sum()
@@ -920,7 +920,7 @@
         if percentile < 0.0:
             percentile += 100.0
         if percentile < 0 or percentile > 100:
-            raise RuntimeError, 'invalid percentile'
+            raise RuntimeError('invalid percentile')
         if percentile == 100.0:
             rank = filter_size - 1
         else:
@@ -928,7 +928,7 @@
     if rank < 0:
         rank += filter_size
     if rank < 0  or rank >= filter_size:
-        raise RuntimeError, 'rank not within filter footprint size'
+        raise RuntimeError('rank not within filter footprint size')
     if rank == 0:
         return minimum_filter(input, None, footprint, output, mode, cval,
                               origin)
@@ -1059,14 +1059,14 @@
         extra_keywords = {}
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     output, return_value = _ni_support._get_output(output, input)
     if filter_size < 1:
-        raise RuntimeError, 'invalid filter size'
+        raise RuntimeError('invalid filter size')
     axis = _ni_support._check_axis(axis, input.ndim)
     if ((filter_size // 2 + origin < 0) or
         (filter_size // 2 + origin > filter_size)):
-        raise ValueError, 'invalid origin'
+        raise ValueError('invalid origin')
     mode = _ni_support._extend_mode_to_code(mode)
     _nd_image.generic_filter1d(input, function, filter_size, axis, output,
                       mode, cval, origin, extra_arguments, extra_keywords)
@@ -1100,11 +1100,11 @@
         extra_keywords = {}
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     origins = _ni_support._normalize_sequence(origin, input.ndim)
     if footprint is None:
         if size is None:
-            raise RuntimeError, "no footprint or filter size provided"
+            raise RuntimeError("no footprint or filter size provided")
         sizes = _ni_support._normalize_sequence(size, input.ndim)
         footprint = numpy.ones(sizes, dtype=bool)
     else:
@@ -1112,10 +1112,10 @@
         footprint = footprint.astype(bool)
     fshape = [ii for ii in footprint.shape if ii > 0]
     if len(fshape) != input.ndim:
-        raise RuntimeError, 'filter footprint array has incorrect shape.'
+        raise RuntimeError('filter footprint array has incorrect shape.')
     for origin, lenf in zip(origins, fshape):
         if (lenf // 2 + origin < 0) or (lenf // 2 + origin > lenf):
-            raise ValueError, 'invalid origin'
+            raise ValueError('invalid origin')
     if not footprint.flags.contiguous:
         footprint = footprint.copy()
     output, return_value = _ni_support._get_output(output, input)

Modified: trunk/scipy/ndimage/fourier.py
===================================================================
--- trunk/scipy/ndimage/fourier.py	2010-11-20 07:33:29 UTC (rev 6921)
+++ trunk/scipy/ndimage/fourier.py	2010-11-20 07:52:46 UTC (rev 6922)
@@ -44,12 +44,12 @@
     elif type(output) is types.TypeType:
         if output not in [numpy.complex64, numpy.complex128,
                           numpy.float32, numpy.float64]:
-            raise RuntimeError, "output type not supported"
+            raise RuntimeError("output type not supported")
         output = numpy.zeros(input.shape, dtype = output)
         return_value = output
     else:
         if output.shape != input.shape:
-            raise RuntimeError, "output shape not correct"
+            raise RuntimeError("output shape not correct")
         return_value = None
     return output, return_value
 
@@ -62,12 +62,12 @@
         return_value = output
     elif type(output) is types.TypeType:
         if output not in [numpy.complex64, numpy.complex128]:
-            raise RuntimeError, "output type not supported"
+            raise RuntimeError("output type not supported")
         output = numpy.zeros(input.shape, dtype = output)
         return_value = output
     else:
         if output.shape != input.shape:
-            raise RuntimeError, "output shape not correct"
+            raise RuntimeError("output shape not correct")
         return_value = None
     return output, return_value
 

Modified: trunk/scipy/ndimage/interpolation.py
===================================================================
--- trunk/scipy/ndimage/interpolation.py	2010-11-20 07:33:29 UTC (rev 6921)
+++ trunk/scipy/ndimage/interpolation.py	2010-11-20 07:52:46 UTC (rev 6922)
@@ -68,10 +68,10 @@
 
     """
     if order < 0 or order > 5:
-        raise RuntimeError, 'spline order not supported'
+        raise RuntimeError('spline order not supported')
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     output, return_value = _ni_support._get_output(output, input,
                                                     output_type)
     if order in [0, 1]:
@@ -103,10 +103,10 @@
 
     """
     if order < 2 or order > 5:
-        raise RuntimeError, 'spline order not supported'
+        raise RuntimeError('spline order not supported')
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     output, return_value = _ni_support._get_output(output, input,
                                                     output_type)
     if order not in [0, 1] and input.ndim > 0:
@@ -188,14 +188,14 @@
 
     """
     if order < 0 or order > 5:
-        raise RuntimeError, 'spline order not supported'
+        raise RuntimeError('spline order not supported')
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     if output_shape is None:
         output_shape = input.shape
     if input.ndim < 1 or len(output_shape) < 1:
-        raise RuntimeError, 'input and output rank must be > 0'
+        raise RuntimeError('input and output rank must be > 0')
     mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
@@ -285,18 +285,18 @@
 
     """
     if order < 0 or order > 5:
-        raise RuntimeError, 'spline order not supported'
+        raise RuntimeError('spline order not supported')
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     coordinates = numpy.asarray(coordinates)
     if numpy.iscomplexobj(coordinates):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     output_shape = coordinates.shape[1:]
     if input.ndim < 1 or len(output_shape) < 1:
-        raise RuntimeError, 'input and output rank must be > 0'
+        raise RuntimeError('input and output rank must be > 0')
     if coordinates.shape[0] != input.ndim:
-        raise RuntimeError, 'invalid shape for coordinate array'
+        raise RuntimeError('invalid shape for coordinate array')
     mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
@@ -366,14 +366,14 @@
 
     """
     if order < 0 or order > 5:
-        raise RuntimeError, 'spline order not supported'
+        raise RuntimeError('spline order not supported')
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     if output_shape is None:
         output_shape = input.shape
     if input.ndim < 1 or len(output_shape) < 1:
-        raise RuntimeError, 'input and output rank must be > 0'
+        raise RuntimeError('input and output rank must be > 0')
     mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
@@ -383,17 +383,17 @@
                                         output_type, shape = output_shape)
     matrix = numpy.asarray(matrix, dtype = numpy.float64)
     if matrix.ndim not in [1, 2] or matrix.shape[0] < 1:
-        raise RuntimeError, 'no proper affine matrix provided'
+        raise RuntimeError('no proper affine matrix provided')
     if matrix.shape[0] != input.ndim:
-        raise RuntimeError, 'affine matrix has wrong number of rows'
+        raise RuntimeError('affine matrix has wrong number of rows')
     if matrix.ndim == 2 and matrix.shape[1] != output.ndim:
-        raise RuntimeError, 'affine matrix has wrong number of columns'
+        raise RuntimeError('affine matrix has wrong number of columns')
     if not matrix.flags.contiguous:
         matrix = matrix.copy()
     offset = _ni_support._normalize_sequence(offset, input.ndim)
     offset = numpy.asarray(offset, dtype = numpy.float64)
     if offset.ndim != 1 or offset.shape[0] < 1:
-        raise RuntimeError, 'no proper offset provided'
+        raise RuntimeError('no proper offset provided')
     if not offset.flags.contiguous:
         offset = offset.copy()
     if matrix.ndim == 1:
@@ -450,12 +450,12 @@
 
     """
     if order < 0 or order > 5:
-        raise RuntimeError, 'spline order not supported'
+        raise RuntimeError('spline order not supported')
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     if input.ndim < 1:
-        raise RuntimeError, 'input and output rank must be > 0'
+        raise RuntimeError('input and output rank must be > 0')
     mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
@@ -515,12 +515,12 @@
 
     """
     if order < 0 or order > 5:
-        raise RuntimeError, 'spline order not supported'
+        raise RuntimeError('spline order not supported')
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     if input.ndim < 1:
-        raise RuntimeError, 'input and output rank must be > 0'
+        raise RuntimeError('input and output rank must be > 0')
     mode = _extend_mode_to_code(mode)
     if prefilter and order > 1:
         filtered = spline_filter(input, order, output = numpy.float64)
@@ -604,7 +604,7 @@
     if axes[1] < 0:
         axes[1] += rank
     if axes[0] < 0 or axes[1] < 0 or axes[0] > rank or axes[1] > rank:
-        raise RuntimeError, 'invalid rotation plane specified'
+        raise RuntimeError('invalid rotation plane specified')
     if axes[0] > axes[1]:
         axes = axes[1], axes[0]
     angle = numpy.pi / 180 * angle

Modified: trunk/scipy/ndimage/measurements.py
===================================================================
--- trunk/scipy/ndimage/measurements.py	2010-11-20 07:33:29 UTC (rev 6921)
+++ trunk/scipy/ndimage/measurements.py	2010-11-20 07:52:46 UTC (rev 6922)
@@ -141,20 +141,20 @@
     """
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     if structure is None:
         structure = morphology.generate_binary_structure(input.ndim, 1)
     structure = numpy.asarray(structure, dtype = bool)
     if structure.ndim != input.ndim:
-        raise RuntimeError, 'structure and input must have equal rank'
+        raise RuntimeError('structure and input must have equal rank')
     for ii in structure.shape:
         if ii != 3:
-            raise  RuntimeError, 'structure dimensions must be equal to 3'
+            raise  RuntimeError('structure dimensions must be equal to 3')
     if not structure.flags.contiguous:
         structure = structure.copy()
     if isinstance(output, numpy.ndarray):
         if output.dtype.type != numpy.int32:
-            raise RuntimeError, 'output type must be int32'
+            raise RuntimeError('output type must be int32')
     else:
         output = numpy.int32
     output, return_value = _ni_support._get_output(output, input)
@@ -217,7 +217,7 @@
     """
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     if max_label < 1:
         max_label = input.max()
     return _nd_image.find_objects(input, max_label)
@@ -299,7 +299,7 @@
 
     if labels is None:
         if index is not None:
-            raise ValueError, "index without defined labels"
+            raise ValueError("index without defined labels")
         if not pass_positions:
             return func(input.ravel())
         else:
@@ -308,7 +308,8 @@
     try:
         input, labels = numpy.broadcast_arrays(input, labels)
     except ValueError:
-        raise ValueError, "input and labels must have the same shape (excepting dimensions with width 1)"
+        raise ValueError("input and labels must have the same shape "
+                            "(excepting dimensions with width 1)")
 
     if index is None:
         if not pass_positions:
@@ -318,7 +319,9 @@
 
     index = numpy.atleast_1d(index)
     if np.any(index.astype(labels.dtype).astype(index.dtype) != index):
-        raise ValueError, "Cannot convert index values from <%s> to <%s> (labels' type) without loss of precision"%(index.dtype, labels.dtype)
+        raise ValueError("Cannot convert index values from <%s> to <%s> "
+                            "(labels' type) without loss of precision" %
+                            (index.dtype, labels.dtype))
     index = index.astype(labels.dtype)
 
     # optimization: find min/max in index, and select those parts of labels, input, and positions
@@ -1105,20 +1108,20 @@
     """
     input = numpy.asarray(input)
     if input.dtype.type not in [numpy.uint8, numpy.uint16]:
-        raise TypeError, 'only 8 and 16 unsigned inputs are supported'
+        raise TypeError('only 8 and 16 unsigned inputs are supported')
     if structure is None:
         structure = morphology.generate_binary_structure(input.ndim, 1)
     structure = numpy.asarray(structure, dtype = bool)
     if structure.ndim != input.ndim:
-        raise RuntimeError, 'structure and input must have equal rank'
+        raise RuntimeError('structure and input must have equal rank')
     for ii in structure.shape:
         if ii != 3:
-            raise  RuntimeError, 'structure dimensions must be equal to 3'
+            raise  RuntimeError('structure dimensions must be equal to 3')
     if not structure.flags.contiguous:
         structure = structure.copy()
     markers = numpy.asarray(markers)
     if input.shape != markers.shape:
-        raise RuntimeError, 'input and markers must have equal shape'
+        raise RuntimeError('input and markers must have equal shape')
 
     integral_types = [numpy.int0,
                       numpy.int8,
@@ -1130,10 +1133,10 @@
                       numpy.intp]
 
     if markers.dtype.type not in integral_types:
-        raise RuntimeError, 'marker should be of integer type'
+        raise RuntimeError('marker should be of integer type')
     if isinstance(output, numpy.ndarray):
         if output.dtype.type not in integral_types:
-            raise RuntimeError, 'output should be of integer type'
+            raise RuntimeError('output should be of integer type')
     else:
         output = markers.dtype
     output, return_value = _ni_support._get_output(output, input)

Modified: trunk/scipy/ndimage/morphology.py
===================================================================
--- trunk/scipy/ndimage/morphology.py	2010-11-20 07:33:29 UTC (rev 6921)
+++ trunk/scipy/ndimage/morphology.py	2010-11-20 07:52:46 UTC (rev 6922)
@@ -219,27 +219,27 @@
                     border_value, origin, invert, brute_force):
     input = numpy.asarray(input)
     if numpy.iscomplexobj(input):
-        raise TypeError, 'Complex type not supported'
+        raise TypeError('Complex type not supported')
     if structure is None:
         structure = generate_binary_structure(input.ndim, 1)
     else:
         structure = numpy.asarray(structure)
         structure = structure.astype(bool)
     if structure.ndim != input.ndim:
-        raise RuntimeError, 'structure rank must equal input rank'
+        raise RuntimeError('structure rank must equal input rank')
     if not structure.flags.contiguous:
         structure = structure.copy()
     if numpy.product(structure.shape,axis=0) < 1:
-        raise RuntimeError, 'structure must not be empty'
+        raise RuntimeError('structure must not be empty')
     if mask is not None:
         mask = numpy.asarray(mask)
         if mask.shape != input.shape:
-            raise RuntimeError, 'mask and input must have equal sizes'
+            raise RuntimeError('mask and input must have equal sizes')
     origin = _ni_support._normalize_sequence(origin, input.ndim)
     cit = _center_is_true(structure, origin)
     if isinstance(output, numpy.ndarray):
         if numpy.iscomplexobj(output):
-            raise TypeError, 'Complex output type not supported'
+            raise TypeError('Complex output type not supported')
     else:
         output = bool
     output, return_value = _ni_support._get_output(output, input)
@@ -1864,7 +1864,7 @@
     """
     if (not return_distances) and (not return_indices):
         msg = 'at least one of distances/indices must be specified'
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
     tmp1 = numpy.asarray(input) != 0
     struct = generate_binary_structure(tmp1.ndim, tmp1.ndim)
     tmp2 = binary_dilation(tmp1, struct)
@@ -1879,7 +1879,7 @@
     elif metric == 'chessboard':
         metric = 3
     else:
-        raise RuntimeError, 'distance metric not supported'
+        raise RuntimeError('distance metric not supported')
     if sampling is not None:
         sampling = _ni_support._normalize_sequence(sampling, tmp1.ndim)
         sampling = numpy.asarray(sampling, dtype = numpy.float64)
@@ -1897,13 +1897,13 @@
                 dt = numpy.zeros(tmp1.shape, dtype = numpy.uint32)
         else:
             if distances.shape != tmp1.shape:
-                raise RuntimeError, 'distances array has wrong shape'
+                raise RuntimeError('distances array has wrong shape')
             if metric == 1:
                 if distances.dtype.type != numpy.float64:
-                    raise RuntimeError, 'distances array must be float64'
+                    raise RuntimeError('distances array must be float64')
             else:
                 if distances.dtype.type != numpy.uint32:
-                    raise RuntimeError, 'distances array must be uint32'
+                    raise RuntimeError('distances array must be uint32')
             dt = distances
     else:
         dt = None
@@ -1911,9 +1911,9 @@
     if return_indices:
         if isinstance(indices, numpy.ndarray):
             if indices.dtype.type != numpy.int32:
-                raise RuntimeError, 'indices must of int32 type'
+                raise RuntimeError('indices must of int32 type')
             if indices.shape != (tmp1.ndim,) + tmp1.shape:
-                raise RuntimeError, 'indices has wrong shape'
+                raise RuntimeError('indices has wrong shape')
             tmp2 = indices
         else:
             tmp2 = numpy.indices(tmp1.shape, dtype = numpy.int32)
@@ -1963,7 +1963,7 @@
     """
     if (not return_distances) and (not return_indices):
         msg = 'at least one of distances/indices must be specified'
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
     ft_inplace = isinstance(indices, numpy.ndarray)
     dt_inplace = isinstance(distances, numpy.ndarray)
     input = numpy.asarray(input)
@@ -1977,17 +1977,17 @@
         try:
             metric = numpy.asarray(metric)
         except:
-            raise RuntimeError, 'invalid metric provided'
+            raise RuntimeError('invalid metric provided')
         for s in metric.shape:
             if s != 3:
-                raise RuntimeError, 'metric sizes must be equal to 3'
+                raise RuntimeError('metric sizes must be equal to 3')
     if not metric.flags.contiguous:
         metric = metric.copy()
     if dt_inplace:
         if distances.dtype.type != numpy.int32:
-            raise RuntimeError, 'distances must be of int32 type'
+            raise RuntimeError('distances must be of int32 type')
         if distances.shape != input.shape:
-            raise RuntimeError, 'distances has wrong shape'
+            raise RuntimeError('distances has wrong shape')
         dt = distances
         dt[...] = numpy.where(input, -1, 0).astype(numpy.int32)
     else:
@@ -2010,9 +2010,9 @@
         ft = numpy.ravel(ft)
         if ft_inplace:
             if indices.dtype.type != numpy.int32:
-                raise RuntimeError, 'indices must of int32 type'
+                raise RuntimeError('indices must of int32 type')
             if indices.shape != (dt.ndim,) + dt.shape:
-                raise RuntimeError, 'indices has wrong shape'
+                raise RuntimeError('indices has wrong shape')
             tmp = indices
         else:
             tmp = numpy.indices(dt.shape, dtype = numpy.int32)
@@ -2148,7 +2148,7 @@
     """
     if (not return_distances) and (not return_indices):
         msg = 'at least one of distances/indices must be specified'
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
     ft_inplace = isinstance(indices, numpy.ndarray)
     dt_inplace = isinstance(distances, numpy.ndarray)
     # calculate the feature transform
@@ -2161,9 +2161,9 @@
     if ft_inplace:
         ft = indices
         if ft.shape != (input.ndim,) + input.shape:
-            raise RuntimeError, 'indices has wrong shape'
+            raise RuntimeError('indices has wrong shape')
         if ft.dtype.type != numpy.int32:
-            raise RuntimeError, 'indices must be of int32 type'
+            raise RuntimeError('indices must be of int32 type')
     else:
         ft = numpy.zeros((input.ndim,) + input.shape,
                             dtype = numpy.int32)
@@ -2179,9 +2179,9 @@
         if dt_inplace:
             dt = numpy.add.reduce(dt, axis = 0)
             if distances.shape != dt.shape:
-                raise RuntimeError, 'indices has wrong shape'
+                raise RuntimeError('indices has wrong shape')
             if distances.dtype.type != numpy.float64:
-                raise RuntimeError, 'indices must be of float64 type'
+                raise RuntimeError('indices must be of float64 type')
             numpy.sqrt(dt, distances)
             del dt
         else:




More information about the Scipy-svn mailing list