diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2011-04-05 15:01:52 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-04-05 17:38:00 -0600 |
commit | cfd766456368777bcb0d5edabd360b3aeb02d3f8 (patch) | |
tree | b38cd1bf7520faba8e2c0268e85253df7fe1f23f /numpy/oldnumeric | |
parent | a4100ba6c440bdf2a2b3cfc31995eb5e009846ee (diff) | |
download | numpy-cfd766456368777bcb0d5edabd360b3aeb02d3f8.tar.gz |
STY: Update exception style, easy ones.
Diffstat (limited to 'numpy/oldnumeric')
-rw-r--r-- | numpy/oldnumeric/arrayfns.py | 10 | ||||
-rw-r--r-- | numpy/oldnumeric/compat.py | 4 | ||||
-rw-r--r-- | numpy/oldnumeric/functions.py | 2 | ||||
-rw-r--r-- | numpy/oldnumeric/ma.py | 52 | ||||
-rw-r--r-- | numpy/oldnumeric/matrix.py | 2 | ||||
-rw-r--r-- | numpy/oldnumeric/random_array.py | 4 |
6 files changed, 37 insertions, 37 deletions
diff --git a/numpy/oldnumeric/arrayfns.py b/numpy/oldnumeric/arrayfns.py index 230b200a9..683ed309d 100644 --- a/numpy/oldnumeric/arrayfns.py +++ b/numpy/oldnumeric/arrayfns.py @@ -14,9 +14,9 @@ class error(Exception): def array_set(vals1, indices, vals2): indices = asarray(indices) if indices.ndim != 1: - raise ValueError, "index array must be 1-d" + raise ValueError("index array must be 1-d") if not isinstance(vals1, np.ndarray): - raise TypeError, "vals1 must be an ndarray" + raise TypeError("vals1 must be an ndarray") vals1 = asarray(vals1) vals2 = asarray(vals2) if vals1.ndim != vals2.ndim or vals1.ndim < 1: @@ -43,14 +43,14 @@ def interp(y, x, z, typ=None): def nz(x): x = asarray(x,dtype=np.ubyte) if x.ndim != 1: - raise TypeError, "intput must have 1 dimension." + raise TypeError("intput must have 1 dimension.") indxs = np.flatnonzero(x != 0) return indxs[-1].item()+1 def reverse(x, n): x = asarray(x,dtype='d') if x.ndim != 2: - raise ValueError, "input must be 2-d" + raise ValueError("input must be 2-d") y = np.empty_like(x) if n == 0: y[...] = x[::-1,:] @@ -71,7 +71,7 @@ def zmin_zmax(z, ireg): z = asarray(z, dtype=float) ireg = asarray(ireg, dtype=int) if z.shape != ireg.shape or z.ndim != 2: - raise ValueError, "z and ireg must be the same shape and 2-d" + raise ValueError("z and ireg must be the same shape and 2-d") ix, iy = np.nonzero(ireg) # Now, add more indices x1m = ix - 1 diff --git a/numpy/oldnumeric/compat.py b/numpy/oldnumeric/compat.py index 607dd0b90..083a1fa15 100644 --- a/numpy/oldnumeric/compat.py +++ b/numpy/oldnumeric/compat.py @@ -112,6 +112,6 @@ else: class Pickler(pickle.Pickler): def __init__(self, *args, **kwds): - raise NotImplementedError, "Don't pickle new arrays with this" + raise NotImplementedError("Don't pickle new arrays with this") def save_array(self, object): - raise NotImplementedError, "Don't pickle new arrays with this" + raise NotImplementedError("Don't pickle new arrays with this") diff --git a/numpy/oldnumeric/functions.py b/numpy/oldnumeric/functions.py index 5b2b1a8bf..db62f7cb5 100644 --- a/numpy/oldnumeric/functions.py +++ b/numpy/oldnumeric/functions.py @@ -91,7 +91,7 @@ def nonzero(a): if len(res) == 1: return res[0] else: - raise ValueError, "Input argument must be 1d" + raise ValueError("Input argument must be 1d") def reshape(a, shape): return np.reshape(a, shape) diff --git a/numpy/oldnumeric/ma.py b/numpy/oldnumeric/ma.py index 1284c6019..d30f673a8 100644 --- a/numpy/oldnumeric/ma.py +++ b/numpy/oldnumeric/ma.py @@ -122,7 +122,7 @@ def minimum_fill_value (obj): if x in typecodes['UnsignedInteger']: return sys.maxint else: - raise TypeError, 'Unsuitable type for calculating minimum.' + raise TypeError('Unsuitable type for calculating minimum.') def maximum_fill_value (obj): "Function to calculate default fill value suitable for taking maxima." @@ -139,7 +139,7 @@ def maximum_fill_value (obj): if x in typecodes['UnsignedInteger']: return 0 else: - raise TypeError, 'Unsuitable type for calculating maximum.' + raise TypeError('Unsuitable type for calculating maximum.') def set_fill_value (a, fill_value): "Set fill value of a if it is a masked array." @@ -598,7 +598,7 @@ class MaskedArray (object): self._data = fromnumeric.resize(self._data, self._mask.shape) self._data.shape = self._mask.shape else: - raise MAError, "Mask and data not compatible." + raise MAError("Mask and data not compatible.") elif nm == 1 and shape(self._mask) != shape(self._data): self.unshare_mask() self._mask.shape = self._data.shape @@ -786,14 +786,14 @@ array(data = %(data)s, "Convert self to float." self.unmask() if self._mask is not nomask: - raise MAError, 'Cannot convert masked element to a Python float.' + raise MAError('Cannot convert masked element to a Python float.') return float(self.data.item()) def __int__(self): "Convert self to int." self.unmask() if self._mask is not nomask: - raise MAError, 'Cannot convert masked element to a Python int.' + raise MAError('Cannot convert masked element to a Python int.') return int(self.data.item()) def __getitem__(self, i): @@ -827,7 +827,7 @@ array(data = %(data)s, "Set item described by index. If value is masked, mask those locations." d = self._data if self is masked: - raise MAError, 'Cannot alter masked elements.' + raise MAError('Cannot alter masked elements.') if value is masked: if self._mask is nomask: self._mask = make_mask_none(d.shape) @@ -973,14 +973,14 @@ array(data = %(data)s, if t1 in typecodes['Integer']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Float']: if t1 in typecodes['Integer']: f = f.astype(t) elif t1 in typecodes['Float']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Complex']: if t1 in typecodes['Integer']: f = f.astype(t) @@ -989,9 +989,9 @@ array(data = %(data)s, elif t1 in typecodes['Complex']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') if self._mask is nomask: self._data += f @@ -1016,14 +1016,14 @@ array(data = %(data)s, if t1 in typecodes['Integer']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Float']: if t1 in typecodes['Integer']: f = f.astype(t) elif t1 in typecodes['Float']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Complex']: if t1 in typecodes['Integer']: f = f.astype(t) @@ -1032,9 +1032,9 @@ array(data = %(data)s, elif t1 in typecodes['Complex']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') if self._mask is nomask: self._data *= f @@ -1059,14 +1059,14 @@ array(data = %(data)s, if t1 in typecodes['Integer']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Float']: if t1 in typecodes['Integer']: f = f.astype(t) elif t1 in typecodes['Float']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Complex']: if t1 in typecodes['Integer']: f = f.astype(t) @@ -1075,9 +1075,9 @@ array(data = %(data)s, elif t1 in typecodes['Complex']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') if self._mask is nomask: self._data -= f @@ -1104,14 +1104,14 @@ array(data = %(data)s, if t1 in typecodes['Integer']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Float']: if t1 in typecodes['Integer']: f = f.astype(t) elif t1 in typecodes['Float']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Complex']: if t1 in typecodes['Integer']: f = f.astype(t) @@ -1120,9 +1120,9 @@ array(data = %(data)s, elif t1 in typecodes['Complex']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') mo = getmask(other) result = divide(self, masked_array(f, mask=mo)) self._data = result.data @@ -1567,7 +1567,7 @@ def count (a, axis = None): def power (a, b, third=None): "a**b" if third is not None: - raise MAError, "3-argument power not supported." + raise MAError("3-argument power not supported.") ma = getmask(a) mb = getmask(b) m = mask_or(ma, mb) @@ -1665,7 +1665,7 @@ def new_average (a, axis=None, weights=None, returned = 0): d = add.reduce(w, axis) del w, r else: - raise ValueError, 'average: weights wrong shape.' + raise ValueError('average: weights wrong shape.') else: if weights is None: n = add.reduce(a, axis) @@ -1688,7 +1688,7 @@ def new_average (a, axis=None, weights=None, returned = 0): n = add.reduce(a*w, axis) d = add.reduce(w, axis) else: - raise ValueError, 'average: weights wrong shape.' + raise ValueError('average: weights wrong shape.') del w #print n, d, repr(mask), repr(weights) if n is masked or d is masked: return masked @@ -2135,7 +2135,7 @@ from types import MethodType def _m(f): return MethodType(f, None, array) def not_implemented(*args, **kwds): - raise NotImplementedError, "not yet implemented for numpy.ma arrays" + raise NotImplementedError("not yet implemented for numpy.ma arrays") array.all = _m(alltrue) array.any = _m(sometrue) array.argmax = _m(argmax) diff --git a/numpy/oldnumeric/matrix.py b/numpy/oldnumeric/matrix.py index 5f8c1ca5e..ddd612266 100644 --- a/numpy/oldnumeric/matrix.py +++ b/numpy/oldnumeric/matrix.py @@ -41,7 +41,7 @@ def _convert_from_string(data): if count == 0: Ncols = len(newrow) elif len(newrow) != Ncols: - raise ValueError, "Rows not the same size." + raise ValueError("Rows not the same size.") count += 1 newdata.append(newrow) return newdata diff --git a/numpy/oldnumeric/random_array.py b/numpy/oldnumeric/random_array.py index e84aedf1e..ffae79616 100644 --- a/numpy/oldnumeric/random_array.py +++ b/numpy/oldnumeric/random_array.py @@ -41,12 +41,12 @@ def randint(minimum, maximum=None, shape=[]): """randint(min, max, shape=[]) = random integers >=min, < max If max not given, random integers >= 0, <min""" if not isinstance(minimum, int): - raise ArgumentError, "randint requires first argument integer" + raise ArgumentError("randint requires first argument integer") if maximum is None: maximum = minimum minimum = 0 if not isinstance(maximum, int): - raise ArgumentError, "randint requires second argument integer" + raise ArgumentError("randint requires second argument integer") a = ((maximum-minimum)* random(shape)) if isinstance(a, np.ndarray): return minimum + a.astype(np.int) |