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/ma | |
parent | a4100ba6c440bdf2a2b3cfc31995eb5e009846ee (diff) | |
download | numpy-cfd766456368777bcb0d5edabd360b3aeb02d3f8.tar.gz |
STY: Update exception style, easy ones.
Diffstat (limited to 'numpy/ma')
-rw-r--r-- | numpy/ma/core.py | 8 | ||||
-rw-r--r-- | numpy/ma/extras.py | 16 | ||||
-rw-r--r-- | numpy/ma/mrecords.py | 4 |
3 files changed, 14 insertions, 14 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 936df17f3..1ea40d417 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2976,7 +2976,7 @@ class MaskedArray(ndarray): """ if self is masked: - raise MaskError, 'Cannot alter the masked element.' + raise MaskError('Cannot alter the masked element.') # This test is useful, but we should keep things light... # if getmask(indx) is not nomask: # msg = "Masked arrays must be filled before they can be used as indices!" @@ -3792,7 +3792,7 @@ class MaskedArray(ndarray): raise TypeError("Only length-1 arrays can be converted "\ "to Python scalars") elif self._mask: - raise MaskError, 'Cannot convert masked element to a Python int.' + raise MaskError('Cannot convert masked element to a Python int.') return int(self.item()) @@ -5992,7 +5992,7 @@ def power(a, b, third=None): """ if third is not None: - raise MaskError, "3-argument power not supported." + raise MaskError("3-argument power not supported.") # Get the masks ma = getmask(a) mb = getmask(b) @@ -6536,7 +6536,7 @@ def where (condition, x=None, y=None): if x is None and y is None: return filled(condition, 0).nonzero() elif x is None or y is None: - raise ValueError, "Either both or neither x and y should be given." + raise ValueError("Either both or neither x and y should be given.") # Get the condition ............... fc = filled(condition, 0).astype(MaskType) notfc = np.logical_not(fc) diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index 1c28eadb8..27abcb2c1 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -533,7 +533,7 @@ def average(a, axis=None, weights=None, returned=False): d = add.reduce(w, axis, dtype=float) 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, dtype=float) @@ -556,7 +556,7 @@ def average(a, axis=None, weights=None, returned=False): n = add.reduce(a * w, axis, dtype=float) d = add.reduce(w, axis, dtype=float) else: - raise ValueError, 'average: weights wrong shape.' + raise ValueError('average: weights wrong shape.') del w if n is masked or d is masked: return masked @@ -718,7 +718,7 @@ def compress_rowcols(x, axis=None): """ x = asarray(x) if x.ndim != 2: - raise NotImplementedError, "compress2d works for 2D arrays only." + raise NotImplementedError("compress2d works for 2D arrays only.") m = getmask(x) # Nothing is masked: return x if m is nomask or not m.any(): @@ -842,7 +842,7 @@ def mask_rowcols(a, axis=None): """ a = asarray(a) if a.ndim != 2: - raise NotImplementedError, "compress2d works for 2D arrays only." + raise NotImplementedError("compress2d works for 2D arrays only.") m = getmask(a) # Nothing is masked: return a if m is nomask or not m.any(): @@ -1429,7 +1429,7 @@ class MAxisConcatenator(AxisConcatenator): def __getitem__(self, key): if isinstance(key, str): - raise MAError, "Unavailable for masked array." + raise MAError("Unavailable for masked array.") if type(key) is not tuple: key = (key,) objs = [] @@ -1459,7 +1459,7 @@ class MAxisConcatenator(AxisConcatenator): self.axis = int(key[k]) continue except (ValueError, TypeError): - raise ValueError, "Unknown special directive" + raise ValueError("Unknown special directive") elif type(key[k]) in np.ScalarType: newobj = asarray([key[k]]) scalars.append(k) @@ -1706,7 +1706,7 @@ def notmasked_contiguous(a, axis=None): a = asarray(a) nd = a.ndim if nd > 2: - raise NotImplementedError, "Currently limited to atmost 2D array." + raise NotImplementedError("Currently limited to atmost 2D array.") if axis is None or nd == 1: return flatnotmasked_contiguous(a) # @@ -1863,7 +1863,7 @@ def polyfit(x, y, deg, rcond=None, full=False): else: m = mx else: - raise TypeError, "Expected a 1D or 2D array for y!" + raise TypeError("Expected a 1D or 2D array for y!") if m is not nomask: x[m] = y[m] = masked # Set rcond diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index 79fa6e15b..9e06908b2 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -589,7 +589,7 @@ on the first line. An exception is raised if the file is 3D or more. if len(arr.shape) == 2 : arr = arr[0] elif len(arr.shape) > 2: - raise ValueError, "The array should be 2D at most!" + raise ValueError("The array should be 2D at most!") # Start the conversion loop ....... for f in arr: try: @@ -623,7 +623,7 @@ def openfile(fname): if f.readline()[:2] != "\\x": f.seek(0, 0) return f - raise NotImplementedError, "Wow, binary file" + raise NotImplementedError("Wow, binary file") def fromtextfile(fname, delimitor=None, commentchar='#', missingchar='', |