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/core | |
parent | cfd766456368777bcb0d5edabd360b3aeb02d3f8 (diff) | |
download | numpy-e1a9692cc36e4353798a332c834fce7aa6cf9b54.tar.gz |
STY: Update exception styles, trickier ones.
Diffstat (limited to 'numpy/core')
-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 |
5 files changed, 16 insertions, 16 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). |