# [Scipy-svn] r6921 - trunk/scipy/misc

scipy-svn@scip... scipy-svn@scip...
Sat Nov 20 01:33:29 CST 2010

Author: warren.weckesser
Date: 2010-11-20 01:33:29 -0600 (Sat, 20 Nov 2010)
New Revision: 6921

Modified:
trunk/scipy/misc/common.py
trunk/scipy/misc/pilutil.py
Log:
ENH: misc: update 'raise' statements

Modified: trunk/scipy/misc/common.py
===================================================================
--- trunk/scipy/misc/common.py	2010-11-20 07:28:02 UTC (rev 6920)
+++ trunk/scipy/misc/common.py	2010-11-20 07:33:29 UTC (rev 6921)
@@ -319,8 +319,7 @@
N = len(an) - 1
n = N-m
if (n < 0):
-        raise ValueError, \
-              "Order of q <m> must be smaller than len(an)-1."
+        raise ValueError("Order of q <m> must be smaller than len(an)-1.")
Akj = eye(N+1,n+1)
Bkj = zeros((N+1,m),'d')
for row in range(1,m+1):

Modified: trunk/scipy/misc/pilutil.py
===================================================================
--- trunk/scipy/misc/pilutil.py	2010-11-20 07:28:02 UTC (rev 6920)
+++ trunk/scipy/misc/pilutil.py	2010-11-20 07:33:29 UTC (rev 6921)
@@ -167,7 +167,7 @@
"""
data = asarray(arr)
if iscomplexobj(data):
-        raise ValueError, "Cannot convert a complex-valued array."
+        raise ValueError("Cannot convert a complex-valued array.")
shape = list(data.shape)
valid = len(shape)==2 or ((len(shape)==3) and \
((3 in shape) or (4 in shape)))
@@ -202,7 +202,7 @@
data32 = data.astype(numpy.uint32)
image = Image.fromstring(mode,shape,data32.tostring())
else:
-            raise ValueError, _errstr
+            raise ValueError(_errstr)
return image

# if here then 3-d array with a 3 or a 4 in the shape length.
@@ -215,13 +215,13 @@
if len(ca):
ca = ca[0]
else:
-                raise ValueError, "Could not find channel dimension."
+                raise ValueError("Could not find channel dimension.")
else:
ca = channel_axis

numch = shape[ca]
if numch not in [3,4]:
-        raise ValueError, "Channel axis dimension is not valid."
+        raise ValueError("Channel axis dimension is not valid.")

bytedata = bytescale(data,high=high,low=low,cmin=cmin,cmax=cmax)
if ca == 2:
@@ -239,7 +239,7 @@

if mode not in ['RGB','RGBA','YCbCr','CMYK']:
-        raise ValueError, _errstr
+        raise ValueError(_errstr)

if mode in ['RGB', 'YCbCr']:
assert numch == 3, "Invalid array shape for mode."
@@ -405,7 +405,7 @@

im = toimage(arr)
if ftype not in _tdict.keys():
-        raise ValueError, "Unknown filter type."
+        raise ValueError("Unknown filter type.")
return fromimage(im.filter(_tdict[ftype]))