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/core | |
parent | a4100ba6c440bdf2a2b3cfc31995eb5e009846ee (diff) | |
download | numpy-cfd766456368777bcb0d5edabd360b3aeb02d3f8.tar.gz |
STY: Update exception style, easy ones.
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/defchararray.py | 8 | ||||
-rw-r--r-- | numpy/core/memmap.py | 2 | ||||
-rw-r--r-- | numpy/core/numeric.py | 4 | ||||
-rw-r--r-- | numpy/core/numerictypes.py | 2 | ||||
-rw-r--r-- | numpy/core/records.py | 8 |
5 files changed, 12 insertions, 12 deletions
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 3facd08fa..850e2dae2 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -301,7 +301,7 @@ def multiply(a, i): a_arr = numpy.asarray(a) i_arr = numpy.asarray(i) if not issubclass(i_arr.dtype.type, integer): - raise ValueError, "Can only multiply by integers" + raise ValueError("Can only multiply by integers") out_size = _get_num_chars(a_arr) * max(long(i_arr.max()), 0) return _vec_string( a_arr, (a_arr.dtype.type, out_size), '__mul__', (i_arr,)) @@ -1660,7 +1660,7 @@ def isnumeric(a): unicode.isnumeric """ if _use_unicode(a) != unicode_: - raise TypeError, "isnumeric is only available for Unicode strings and arrays" + raise TypeError("isnumeric is only available for Unicode strings and arrays") return _vec_string(a, bool_, 'isnumeric') def isdecimal(a): @@ -1688,7 +1688,7 @@ def isdecimal(a): unicode.isdecimal """ if _use_unicode(a) != unicode_: - raise TypeError, "isnumeric is only available for Unicode strings and arrays" + raise TypeError("isnumeric is only available for Unicode strings and arrays") return _vec_string(a, bool_, 'isdecimal') @@ -1872,7 +1872,7 @@ class chararray(ndarray): def __array_finalize__(self, obj): # The b is a special case because it is used for reconstructing. if not _globalvar and self.dtype.char not in 'SUbc': - raise ValueError, "Can only create a chararray from string data." + raise ValueError("Can only create a chararray from string data.") def __getitem__(self, obj): val = ndarray.__getitem__(self, obj) diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index 844e13c4e..c445ee641 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -193,7 +193,7 @@ class memmap(ndarray): fid = open(filename, (mode == 'c' and 'r' or mode)+'b') if (mode == 'w+') and shape is None: - raise ValueError, "shape must be given" + raise ValueError("shape must be given") fid.seek(0, 2) flen = fid.tell() diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 2dace5de1..6891ea768 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -977,7 +977,7 @@ def tensordot(a, b, axes=2): if axes_b[k] < 0: axes_b[k] += ndb if not equal: - raise ValueError, "shape-mismatch for sum" + raise ValueError("shape-mismatch for sum") # Move the axes to sum over to the end of "a" # and to the front of "b" @@ -2279,7 +2279,7 @@ def seterrcall(func): """ if func is not None and not callable(func): if not hasattr(func, 'write') or not callable(func.write): - raise ValueError, "Only callable can be used as callback" + raise ValueError("Only callable can be used as callback") pyvals = umath.geterrobj() old = geterrcall() pyvals[2] = func diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index 8874667d8..7bdfd98c1 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -842,7 +842,7 @@ def sctype2char(sctype): """ sctype = obj2sctype(sctype) if sctype is None: - raise ValueError, "unrecognized type" + raise ValueError("unrecognized type") return _sctype2char_dict[sctype] # Create dictionary of casting functions that wrap sequences diff --git a/numpy/core/records.py b/numpy/core/records.py index 58cead0d9..25d6f9513 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -149,7 +149,7 @@ class format_parser: """ Parse the field formats """ if formats is None: - raise ValueError, "Need formats argument" + raise ValueError("Need formats argument") if isinstance(formats, list): if len(formats) < 2: formats.append('') @@ -528,7 +528,7 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None, formats = '' for obj in arrayList: if not isinstance(obj, ndarray): - raise ValueError, "item in the array list must be an ndarray." + raise ValueError("item in the array list must be an ndarray.") formats += _typestr[obj.dtype.type] if issubclass(obj.dtype.type, nt.flexible): formats += `obj.itemsize` @@ -618,7 +618,7 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None, if isinstance(shape, (int, long)): shape = (shape,) if len(shape) > 1: - raise ValueError, "Can only deal with 1-d array." + raise ValueError("Can only deal with 1-d array.") _array = recarray(shape, descr) for k in xrange(_array.size): _array[k] = tuple(recList[k]) @@ -639,7 +639,7 @@ def fromstring(datastring, dtype=None, shape=None, offset=0, formats=None, if dtype is None and formats is None: - raise ValueError, "Must have dtype= or formats=" + raise ValueError("Must have dtype= or formats=") if dtype is not None: descr = sb.dtype(dtype) |