diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2011-04-05 15:08:23 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-04-05 17:38:00 -0600 |
commit | e1a9692cc36e4353798a332c834fce7aa6cf9b54 (patch) | |
tree | fc499f8768c8d2d99c64547cd1a0b7ae7e6018be /numpy | |
parent | cfd766456368777bcb0d5edabd360b3aeb02d3f8 (diff) | |
download | numpy-e1a9692cc36e4353798a332c834fce7aa6cf9b54.tar.gz |
STY: Update exception styles, trickier ones.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/_mx_datetime_parser.py | 8 | ||||
-rw-r--r-- | numpy/core/getlimits.py | 2 | ||||
-rw-r--r-- | numpy/core/numeric.py | 6 | ||||
-rw-r--r-- | numpy/core/records.py | 12 | ||||
-rw-r--r-- | numpy/core/src/multiarray/testcalcs.py | 4 | ||||
-rw-r--r-- | numpy/ctypeslib.py | 6 | ||||
-rw-r--r-- | numpy/dual.py | 4 | ||||
-rwxr-xr-x | numpy/f2py/crackfortran.py | 2 | ||||
-rwxr-xr-x | numpy/f2py/f2py2e.py | 2 | ||||
-rw-r--r-- | numpy/lib/npyio.py | 4 | ||||
-rw-r--r-- | numpy/linalg/linalg.py | 8 | ||||
-rw-r--r-- | numpy/ma/mrecords.py | 6 | ||||
-rw-r--r-- | numpy/matrixlib/defmatrix.py | 2 | ||||
-rw-r--r-- | numpy/oldnumeric/ma.py | 2 |
14 files changed, 34 insertions, 34 deletions
diff --git a/numpy/core/_mx_datetime_parser.py b/numpy/core/_mx_datetime_parser.py index f1b330f00..dd950c01f 100644 --- a/numpy/core/_mx_datetime_parser.py +++ b/numpy/core/_mx_datetime_parser.py @@ -282,10 +282,10 @@ def utc_offset(zone): return _zonetable[uzone]*60 offset = _zoneoffsetRE.match(zone) if not offset: - raise ValueError,'wrong format or unkown time zone: "%s"' % zone + raise ValueError('wrong format or unkown time zone: "%s"' % zone) zonesign,hours,minutes,extra = offset.groups() if extra: - raise ValueError,'illegal time zone offset: "%s"' % zone + raise ValueError('illegal time zone offset: "%s"' % zone) offset = int(hours or 0) * 60 + int(minutes or 0) if zonesign == '-': offset = -offset @@ -518,7 +518,7 @@ def _parse_date(text): elif not style: # Not recognized: raise an error - raise ValueError, 'unknown date format: "%s"' % text + raise ValueError('unknown date format: "%s"' % text) # Literal date post-processing if style in ('lit', 'altlit', 'eurlit'): @@ -610,7 +610,7 @@ def _parse_time(text): if not style: # If no default handling should be applied, raise an error - raise ValueError, 'unknown time format: "%s"' % text + raise ValueError('unknown time format: "%s"' % text) # Post-processing if match is not None: diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py index 37f33c66d..518067a3c 100644 --- a/numpy/core/getlimits.py +++ b/numpy/core/getlimits.py @@ -104,7 +104,7 @@ class finfo(object): dtypes.append(newdtype) dtype = newdtype if not issubclass(dtype, numeric.inexact): - raise ValueError, "data type %r not inexact" % (dtype) + raise ValueError("data type %r not inexact" % (dtype)) obj = cls._finfo_cache.get(dtype,None) if obj is not None: return obj diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 6891ea768..28c3cffd7 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -2179,11 +2179,11 @@ def setbufsize(size): """ if size > 10e6: - raise ValueError, "Buffer size, %s, is too big." % size + raise ValueError("Buffer size, %s, is too big." % size) if size < 5: - raise ValueError, "Buffer size, %s, is too small." %size + raise ValueError("Buffer size, %s, is too small." %size) if size % 16 != 0: - raise ValueError, "Buffer size, %s, is not a multiple of 16." %size + raise ValueError("Buffer size, %s, is not a multiple of 16." %size) pyvals = umath.geterrobj() old = getbufsize() diff --git a/numpy/core/records.py b/numpy/core/records.py index 25d6f9513..b2425ec6a 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -174,7 +174,7 @@ class format_parser: elif (type(names) == str): names = names.split(',') else: - raise NameError, "illegal input names %s" % `names` + raise NameError("illegal input names %s" % `names`) self._names = [n.strip() for n in names[:self._nfields]] else: @@ -189,7 +189,7 @@ class format_parser: # check for redundant names _dup = find_duplicate(self._names) if _dup: - raise ValueError, "Duplicate field names: %s" % _dup + raise ValueError("Duplicate field names: %s" % _dup) if (titles): self._titles = [n.strip() for n in titles[:self._nfields]] @@ -250,7 +250,7 @@ class record(nt.void): def __setattr__(self, attr, val): if attr in ['setfield', 'getfield', 'dtype']: - raise AttributeError, "Cannot set '%s' attribute" % attr + raise AttributeError("Cannot set '%s' attribute" % attr) fielddict = nt.void.__getattribute__(self, 'dtype').fields res = fielddict.get(attr, None) if res: @@ -413,7 +413,7 @@ class recarray(ndarray): try: res = fielddict[attr][:2] except (TypeError, KeyError): - raise AttributeError, "record array has no attribute %s" % attr + raise AttributeError("record array has no attribute %s" % attr) obj = self.getfield(*res) # if it has fields return a recarray, otherwise return # normal array @@ -450,7 +450,7 @@ class recarray(ndarray): try: res = fielddict[attr][:2] except (TypeError, KeyError): - raise AttributeError, "record array has no attribute %s" % attr + raise AttributeError("record array has no attribute %s" % attr) return self.setfield(val, *res) def __getitem__(self, indx): @@ -557,7 +557,7 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None, nn = len(descr[k].shape) testshape = obj.shape[:len(obj.shape) - nn] if testshape != shape: - raise ValueError, "array-shape mismatch in array %d" % k + raise ValueError("array-shape mismatch in array %d" % k) _array = recarray(shape, descr) diff --git a/numpy/core/src/multiarray/testcalcs.py b/numpy/core/src/multiarray/testcalcs.py index d7ea67faf..8cb440820 100644 --- a/numpy/core/src/multiarray/testcalcs.py +++ b/numpy/core/src/multiarray/testcalcs.py @@ -41,12 +41,12 @@ def days_from_ymd(year, month, day): # Negative month values indicate months relative to the years end */ if (month < 0): month += 13 if not (month >= 1 and month<=12): - raise ValueError, "month out of range (1-21): %d" % month + raise ValueError("month out of range (1-21): %d" % month) # Negative values indicate days relative to the months end */ if (day < 0): day += days_in_month[leap][month - 1] + 1 if not (day >= 1 and day <= days_in_month[leap][month-1]): - raise ValueError, "day out of range: %d" % day + raise ValueError("day out of range: %d" % day) # Number of days between Dec 31, (year - 1) and Dec 31, 1969 # (can be negative). diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py index 1868ee0c9..e590645a8 100644 --- a/numpy/ctypeslib.py +++ b/numpy/ctypeslib.py @@ -166,13 +166,13 @@ class _ndptr(_ndptr_base): raise TypeError("argument must be an ndarray") if cls._dtype_ is not None \ and obj.dtype != cls._dtype_: - raise TypeError, "array must have data type %s" % cls._dtype_ + raise TypeError("array must have data type %s" % cls._dtype_) if cls._ndim_ is not None \ and obj.ndim != cls._ndim_: - raise TypeError, "array must have %d dimension(s)" % cls._ndim_ + raise TypeError("array must have %d dimension(s)" % cls._ndim_) if cls._shape_ is not None \ and obj.shape != cls._shape_: - raise TypeError, "array must have shape %s" % str(cls._shape_) + raise TypeError("array must have shape %s" % str(cls._shape_)) if cls._flags_ is not None \ and ((obj.flags.num & cls._flags_) != cls._flags_): raise TypeError, "array must have flags %s" % \ diff --git a/numpy/dual.py b/numpy/dual.py index 3c863bf6f..4aa01cd30 100644 --- a/numpy/dual.py +++ b/numpy/dual.py @@ -49,14 +49,14 @@ _restore_dict = {} def register_func(name, func): if name not in __all__: - raise ValueError, "%s not a dual function." % name + raise ValueError("%s not a dual function." % name) f = sys._getframe(0).f_globals _restore_dict[name] = f[name] f[name] = func def restore_func(name): if name not in __all__: - raise ValueError, "%s not a dual function." % name + raise ValueError("%s not a dual function." % name) try: val = _restore_dict[name] except KeyError: diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 76d7716f9..8299e0aa6 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -399,7 +399,7 @@ def readfortrancode(ffile,dowithline=show,istop=1): ll=l cont=(r is not None) else: - raise ValueError,"Flag sourcecodeform must be either 'fix' or 'free': %s"%`sourcecodeform` + raise ValueError("Flag sourcecodeform must be either 'fix' or 'free': %s"%`sourcecodeform`) filepositiontext='Line #%d in %s:"%s"\n\t' % (fin.filelineno()-1,currentfilename,l1) m=includeline.match(origfinalline) if m: diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 86c4b31a4..2c9aca25a 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -378,7 +378,7 @@ def run_main(comline_list): if postlist[i]['block']!='python module': if 'python module' not in options: errmess('Tip: If your original code is Fortran source then you must use -m option.\n') - raise TypeError,'All blocks must be python module blocks but got %s'%(`postlist[i]['block']`) + raise TypeError('All blocks must be python module blocks but got %s'%(`postlist[i]['block']`)) auxfuncs.debugoptions=options['debug'] f90mod_rules.options=options auxfuncs.wrapfuncs=options['wrapfuncs'] diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index da8074f97..c657f7f41 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -233,7 +233,7 @@ class NpzFile(object): else: return bytes else: - raise KeyError, "%s is not a file in the archive" % key + raise KeyError("%s is not a file in the archive" % key) def __iter__(self): @@ -530,7 +530,7 @@ def _savez(file, args, kwds, compress): for i, val in enumerate(args): key = 'arr_%d' % i if key in namedict.keys(): - raise ValueError, "Cannot use un-named variables and keyword %s" % key + raise ValueError("Cannot use un-named variables and keyword %s" % key) namedict[key] = val if compress: diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 043deb24f..1aaefd089 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -643,7 +643,7 @@ def qr(a, mode='full'): work = zeros((lwork,), t) results = lapack_routine(m, n, a, m, tau, work, -1, 0) if results['info'] != 0: - raise LinAlgError, '%s returns %d' % (routine_name, results['info']) + raise LinAlgError('%s returns %d' % (routine_name, results['info'])) # do qr decomposition lwork = int(abs(work[0])) @@ -651,7 +651,7 @@ def qr(a, mode='full'): results = lapack_routine(m, n, a, m, tau, work, lwork, 0) if results['info'] != 0: - raise LinAlgError, '%s returns %d' % (routine_name, results['info']) + raise LinAlgError('%s returns %d' % (routine_name, results['info'])) # economic mode. Isn't actually economic. if mode[0] == 'e': @@ -682,14 +682,14 @@ def qr(a, mode='full'): work = zeros((lwork,), t) results = lapack_routine(m, mn, mn, a, m, tau, work, -1, 0) if results['info'] != 0: - raise LinAlgError, '%s returns %d' % (routine_name, results['info']) + raise LinAlgError('%s returns %d' % (routine_name, results['info'])) # compute q lwork = int(abs(work[0])) work = zeros((lwork,), t) results = lapack_routine(m, mn, mn, a, m, tau, work, lwork, 0) if results['info'] != 0: - raise LinAlgError, '%s returns %d' % (routine_name, results['info']) + raise LinAlgError('%s returns %d' % (routine_name, results['info'])) q = _fastCopyAndTranspose(result_t, a[:mn,:]) diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index 9e06908b2..d2ef8e0c7 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -197,7 +197,7 @@ class MaskedRecords(MaskedArray, object): try: res = fielddict[attr][:2] except (TypeError, KeyError): - raise AttributeError, "record array has no attribute %s" % attr + raise AttributeError("record array has no attribute %s" % attr) # So far, so good... _localdict = ndarray.__getattribute__(self, '__dict__') _data = ndarray.view(self, _localdict['_baseclass']) @@ -269,7 +269,7 @@ class MaskedRecords(MaskedArray, object): try: res = fielddict[attr][:2] except (TypeError, KeyError): - raise AttributeError, "record array has no attribute %s" % attr + raise AttributeError("record array has no attribute %s" % attr) # if val is masked: _fill_value = _localdict['_fill_value'] @@ -619,7 +619,7 @@ def openfile(fname): try: f = open(fname) except IOError: - raise IOError, "No such file: '%s'" % fname + raise IOError("No such file: '%s'" % fname) if f.readline()[:2] != "\\x": f.seek(0, 0) return f diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py index a46f2dab0..0ad798200 100644 --- a/numpy/matrixlib/defmatrix.py +++ b/numpy/matrixlib/defmatrix.py @@ -995,7 +995,7 @@ def _from_string(str,gdict,ldict): try: thismat = gdict[col] except KeyError: - raise KeyError, "%s not found" % (col,) + raise KeyError("%s not found" % (col,)) coltup.append(thismat) rowtup.append(concatenate(coltup,axis=-1)) diff --git a/numpy/oldnumeric/ma.py b/numpy/oldnumeric/ma.py index d30f673a8..e383560b2 100644 --- a/numpy/oldnumeric/ma.py +++ b/numpy/oldnumeric/ma.py @@ -622,7 +622,7 @@ class MaskedArray (object): func, args, i = context fills = ufunc_fills.get(func) if fills is None: - raise MAError, "%s not known to ma" % func + raise MAError("%s not known to ma" % func) return self.filled(fills[i]) else: # Mask is all false # Optimize to avoid future invocations of this section. |