diff options
-rw-r--r-- | numpy/core/_mx_datetime_parser.py | 14 | ||||
-rw-r--r-- | numpy/core/getlimits.py | 2 | ||||
-rw-r--r-- | numpy/core/machar.py | 16 | ||||
-rw-r--r-- | numpy/core/numeric.py | 4 | ||||
-rw-r--r-- | numpy/distutils/mingw32ccompiler.py | 2 | ||||
-rw-r--r-- | numpy/lib/_datasource.py | 4 | ||||
-rw-r--r-- | numpy/lib/npyio.py | 6 | ||||
-rw-r--r-- | numpy/lib/polynomial.py | 4 | ||||
-rw-r--r-- | numpy/ma/core.py | 12 | ||||
-rw-r--r-- | numpy/oldnumeric/ma.py | 4 | ||||
-rw-r--r-- | numpy/oldnumeric/precision.py | 3 | ||||
-rw-r--r-- | numpy/oldnumeric/random_array.py | 8 | ||||
-rw-r--r-- | numpy/testing/nulltester.py | 6 |
13 files changed, 43 insertions, 42 deletions
diff --git a/numpy/core/_mx_datetime_parser.py b/numpy/core/_mx_datetime_parser.py index dd950c01f..d8db18793 100644 --- a/numpy/core/_mx_datetime_parser.py +++ b/numpy/core/_mx_datetime_parser.py @@ -1,5 +1,5 @@ #-*- coding: latin-1 -*- -""" +""" Date/Time string parsing module. This code is a slightly modified version of Parser.py found in mx.DateTime @@ -540,8 +540,8 @@ def _parse_date(text): try: month = litmonthtable[litmonth] except KeyError: - raise ValueError,\ - 'wrong month name: "%s"' % litmonth + raise ValueError( + 'wrong month name: "%s"' % litmonth) elif month: month = int(month) else: @@ -726,8 +726,8 @@ def datetime_from_string(text): return dt.datetime(year,month,day,hour,minute,second, microsecond) - \ dt.timedelta(minutes=offset) except ValueError, why: - raise RangeError,\ - 'Failed to parse "%s": %s' % (origtext, why) + raise RangeError( + 'Failed to parse "%s": %s' % (origtext, why)) def date_from_string(text): @@ -745,8 +745,8 @@ def date_from_string(text): try: return dt.datetime(year,month,day) except ValueError, why: - raise RangeError,\ - 'Failed to parse "%s": %s' % (text, why) + raise RangeError( + 'Failed to parse "%s": %s' % (text, why)) def validateDateTimeString(text): diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py index 518067a3c..0cb1fd7f4 100644 --- a/numpy/core/getlimits.py +++ b/numpy/core/getlimits.py @@ -140,7 +140,7 @@ class finfo(object): fmt = '%12.5e' precname = 'half' else: - raise ValueError, repr(dtype) + raise ValueError(repr(dtype)) machar = MachAr(lambda v:array([v], dtype), lambda v:_frz(v.astype(itype))[0], diff --git a/numpy/core/machar.py b/numpy/core/machar.py index 08ea2ae61..ea9174017 100644 --- a/numpy/core/machar.py +++ b/numpy/core/machar.py @@ -128,7 +128,7 @@ class MachAr(object): if any(temp1 - one != zero): break else: - raise RuntimeError, msg % (_, one.dtype) + raise RuntimeError(msg % (_, one.dtype)) b = one for _ in xrange(max_iterN): b = b + b @@ -137,7 +137,7 @@ class MachAr(object): if any(itemp != 0): break else: - raise RuntimeError, msg % (_, one.dtype) + raise RuntimeError(msg % (_, one.dtype)) ibeta = itemp beta = float_conv(ibeta) @@ -152,7 +152,7 @@ class MachAr(object): if any(temp1 - one != zero): break else: - raise RuntimeError, msg % (_, one.dtype) + raise RuntimeError(msg % (_, one.dtype)) betah = beta / two a = one @@ -163,7 +163,7 @@ class MachAr(object): if any(temp1 - one != zero): break else: - raise RuntimeError, msg % (_, one.dtype) + raise RuntimeError(msg % (_, one.dtype)) temp = a + betah irnd = 0 if any(temp-a != zero): @@ -191,7 +191,7 @@ class MachAr(object): raise RuntimeError("could not determine machine tolerance " "for 'negep', locals() -> %s" % (locals())) else: - raise RuntimeError, msg % (_, one.dtype) + raise RuntimeError(msg % (_, one.dtype)) negep = -negep epsneg = a @@ -206,7 +206,7 @@ class MachAr(object): a = a * beta machep = machep + 1 else: - raise RuntimeError, msg % (_, one.dtype) + raise RuntimeError(msg % (_, one.dtype)) eps = a # Determine ngrd @@ -234,7 +234,7 @@ class MachAr(object): i = i + 1 k = k + k else: - raise RuntimeError, msg % (_, one.dtype) + raise RuntimeError(msg % (_, one.dtype)) if ibeta != 10: iexp = i + 1 mx = k + k @@ -262,7 +262,7 @@ class MachAr(object): else: break else: - raise RuntimeError, msg % (_, one.dtype) + raise RuntimeError(msg % (_, one.dtype)) minexp = -k # Determine maxexp, xmax diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 28c3cffd7..55ab74168 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1109,9 +1109,9 @@ def rollaxis(a, axis, start=0): start += n msg = 'rollaxis: %s (%d) must be >=0 and < %d' if not (0 <= axis < n): - raise ValueError, msg % ('axis', axis, n) + raise ValueError(msg % ('axis', axis, n)) if not (0 <= start < n+1): - raise ValueError, msg % ('start', start, n+1) + raise ValueError(msg % ('start', start, n+1)) if (axis < start): # it's been removed start -= 1 if axis==start: diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py index f5d996490..5b352c300 100644 --- a/numpy/distutils/mingw32ccompiler.py +++ b/numpy/distutils/mingw32ccompiler.py @@ -355,7 +355,7 @@ def _build_import_library_x86(): log.warn('Failed to build import library for gcc. Linking will fail.') #if not success: # msg = "Couldn't find import library, and failed to build it." - # raise DistutilsPlatformError, msg + # raise DistutilsPlatformError(msg) return #===================================== diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py index ce6d2391b..390c56d36 100644 --- a/numpy/lib/_datasource.py +++ b/numpy/lib/_datasource.py @@ -633,7 +633,7 @@ class Repository (DataSource): """ if self._isurl(self._baseurl): - raise NotImplementedError, \ - "Directory listing of URLs, not supported yet." + raise NotImplementedError( + "Directory listing of URLs, not supported yet.") else: return os.listdir(self._baseurl) diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index c657f7f41..f8c24b1a0 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -113,7 +113,7 @@ class BagObj(object): try: return object.__getattribute__(self, '_obj')[key] except KeyError: - raise AttributeError, key + raise AttributeError(key) def zipfile_factory(*args, **kwargs): import zipfile @@ -353,8 +353,8 @@ def load(file, mmap_mode=None): try: return _cload(fid) except: - raise IOError, \ - "Failed to interpret file %s as a pickle" % repr(file) + raise IOError( + "Failed to interpret file %s as a pickle" % repr(file)) finally: if own_fid: fid.close() diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 47078ae88..229fe020d 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -306,8 +306,8 @@ def polyint(p, m=1, k=None): if len(k) == 1 and m > 1: k = k[0]*NX.ones(m, float) if len(k) < m: - raise ValueError, \ - "k must be a scalar or a rank-1 array of length 1 or >m." + raise ValueError( + "k must be a scalar or a rank-1 array of length 1 or >m.") truepoly = isinstance(p, poly1d) p = NX.asarray(p) diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 1ea40d417..bbd855cf8 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -1798,7 +1798,7 @@ def masked_where(condition, a, copy=True): (cshape, ashape) = (cond.shape, a.shape) if cshape and cshape != ashape: - raise IndexError("Inconsistant shape between the condition and the input"\ + raise IndexError("Inconsistant shape between the condition and the input" " (got %s and %s)" % (cshape, ashape)) if hasattr(a, '_mask'): cond = mask_or(cond, a._mask) @@ -2703,7 +2703,7 @@ class MaskedArray(ndarray): else: msg = "Mask and data not compatible: data size is %i, " + \ "mask size is %i." - raise MaskError, msg % (nd, nm) + raise MaskError(msg % (nd, nm)) copy = True # Set the mask to the new value if _data._mask is nomask: @@ -2930,7 +2930,7 @@ class MaskedArray(ndarray): # 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!" -# raise IndexError, msg +# raise IndexError(msg) _data = ndarray.view(self, ndarray) dout = ndarray.__getitem__(_data, indx) # We could directly use ndarray.__getitem__ on self... @@ -2980,7 +2980,7 @@ class MaskedArray(ndarray): # 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!" -# raise IndexError, msg +# raise IndexError(msg) _data = ndarray.view(self, ndarray.__getattribute__(self, '_baseclass')) _mask = ndarray.__getattribute__(self, '_mask') if isinstance(indx, basestring): @@ -3779,7 +3779,7 @@ class MaskedArray(ndarray): def __float__(self): "Convert to float." if self.size > 1: - raise TypeError("Only length-1 arrays can be converted "\ + raise TypeError("Only length-1 arrays can be converted " "to Python scalars") elif self._mask: warnings.warn("Warning: converting a masked element to nan.") @@ -3789,7 +3789,7 @@ class MaskedArray(ndarray): def __int__(self): "Convert to int." if self.size > 1: - raise TypeError("Only length-1 arrays can be converted "\ + 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.') diff --git a/numpy/oldnumeric/ma.py b/numpy/oldnumeric/ma.py index e383560b2..732e8447a 100644 --- a/numpy/oldnumeric/ma.py +++ b/numpy/oldnumeric/ma.py @@ -614,10 +614,10 @@ class MaskedArray (object): "numeric because data\n is masked in one or "\ "more locations."); return self._data - #raise MAError, \ + #raise MAError( # """Cannot automatically convert masked array to numeric because data # is masked in one or more locations. - # """ + # """) else: func, args, i = context fills = ufunc_fills.get(func) diff --git a/numpy/oldnumeric/precision.py b/numpy/oldnumeric/precision.py index c095ceb19..c773e9478 100644 --- a/numpy/oldnumeric/precision.py +++ b/numpy/oldnumeric/precision.py @@ -33,7 +33,8 @@ def _lookup(table, key, required_bits): for bits, typecode in lst: if bits >= required_bits: return typecode - raise PrecisionError, key+" of "+str(required_bits)+" bits not available on this system" + raise PrecisionError(key + " of " + str(required_bits) + + " bits not available on this system") Character = 'c' diff --git a/numpy/oldnumeric/random_array.py b/numpy/oldnumeric/random_array.py index ffae79616..777e2a645 100644 --- a/numpy/oldnumeric/random_array.py +++ b/numpy/oldnumeric/random_array.py @@ -19,10 +19,10 @@ def seed(x=0, y=0): mt.seed((x,y)) def get_seed(): - raise NotImplementedError, \ - "If you want to save the state of the random number generator.\n"\ - "Then you should use obj = numpy.random.get_state() followed by.\n"\ - "numpy.random.set_state(obj)." + raise NotImplementedError( + "If you want to save the state of the random number generator.\n" + "Then you should use obj = numpy.random.get_state() followed by.\n" + "numpy.random.set_state(obj).") def random(shape=[]): "random(n) or random([n, m, ...]) returns array of random numbers" diff --git a/numpy/testing/nulltester.py b/numpy/testing/nulltester.py index 50d5484f6..8cee43495 100644 --- a/numpy/testing/nulltester.py +++ b/numpy/testing/nulltester.py @@ -9,7 +9,7 @@ See pkgtester, nosetester modules class NullTester(object): def test(self, labels=None, *args, **kwargs): - raise ImportError, \ - 'Need nose >=0.10 for tests - see %s' % \ - 'http://somethingaboutorange.com/mrl/projects/nose' + raise ImportError( + 'Need nose >=0.10 for tests - see %s' % + 'http://somethingaboutorange.com/mrl/projects/nose') bench = test |