diff options
-rw-r--r-- | numpy/core/machar.py | 4 | ||||
-rw-r--r-- | numpy/core/memmap.py | 6 | ||||
-rw-r--r-- | numpy/core/records.py | 12 | ||||
-rw-r--r-- | numpy/ctypeslib.py | 10 | ||||
-rw-r--r-- | numpy/lib/index_tricks.py | 4 | ||||
-rw-r--r-- | numpy/lib/shape_base.py | 4 | ||||
-rw-r--r-- | numpy/linalg/linalg.py | 8 | ||||
-rw-r--r-- | numpy/oldnumeric/mlab.py | 3 |
8 files changed, 25 insertions, 26 deletions
diff --git a/numpy/core/machar.py b/numpy/core/machar.py index 290f33746..08ea2ae61 100644 --- a/numpy/core/machar.py +++ b/numpy/core/machar.py @@ -188,8 +188,8 @@ class MachAr(object): negep = negep - 1 # Prevent infinite loop on PPC with gcc 4.0: if negep < 0: - raise RuntimeError, "could not determine machine tolerance " \ - "for 'negep', locals() -> %s" % (locals()) + raise RuntimeError("could not determine machine tolerance " + "for 'negep', locals() -> %s" % (locals())) else: raise RuntimeError, msg % (_, one.dtype) negep = -negep diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index c445ee641..5a7aaba1c 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -184,7 +184,7 @@ class memmap(ndarray): mode = mode_equivalents[mode] except KeyError: if mode not in valid_filemodes: - raise ValueError("mode must be one of %s" % \ + raise ValueError("mode must be one of %s" % (valid_filemodes + mode_equivalents.keys())) if hasattr(filename,'read'): @@ -204,8 +204,8 @@ class memmap(ndarray): bytes = flen - offset if (bytes % _dbytes): fid.close() - raise ValueError, "Size of available data is not a "\ - "multiple of data-type size." + raise ValueError("Size of available data is not a " + "multiple of the data-type size.") size = bytes // _dbytes shape = (size,) else: diff --git a/numpy/core/records.py b/numpy/core/records.py index b2425ec6a..964b4a54e 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -244,8 +244,8 @@ class record(nt.void): return obj.view(chararray) return obj else: - raise AttributeError, "'record' object has no "\ - "attribute '%s'" % attr + raise AttributeError("'record' object has no " + "attribute '%s'" % attr) def __setattr__(self, attr, val): @@ -259,8 +259,8 @@ class record(nt.void): if getattr(self, attr, None): return nt.void.__setattr__(self, attr, val) else: - raise AttributeError, "'record' object has no "\ - "attribute '%s'" % attr + raise AttributeError("'record' object has no " + "attribute '%s'" % attr) def pprint(self): """Pretty-print all fields.""" @@ -545,8 +545,8 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None, # Determine shape from data-type. if len(descr) != len(arrayList): - raise ValueError, "mismatch between the number of fields "\ - "and the number of arrays" + raise ValueError("mismatch between the number of fields " + "and the number of arrays") d0 = descr[0].shape nn = len(d0) diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py index e590645a8..2caca3f4f 100644 --- a/numpy/ctypeslib.py +++ b/numpy/ctypeslib.py @@ -159,7 +159,7 @@ class _ndptr(_ndptr_base): 'typestr': self._dtype_.descr[0][1], 'data': (self.value, False), } - + @classmethod def from_param(cls, obj): if not isinstance(obj, ndarray): @@ -175,8 +175,8 @@ class _ndptr(_ndptr_base): 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" % \ - _flags_fromnum(cls._flags_) + raise TypeError("array must have flags %s" % + _flags_fromnum(cls._flags_)) return obj.ctypes @@ -386,7 +386,7 @@ if ctypes is not None: # public functions def as_array(obj, shape=None): - """Create a numpy array from a ctypes array or a ctypes POINTER. + """Create a numpy array from a ctypes array or a ctypes POINTER. The numpy array shares the memory with the ctypes object. The size parameter must be given if converting from a ctypes POINTER. @@ -394,7 +394,7 @@ if ctypes is not None: """ tp = type(obj) try: tp.__array_interface__ - except AttributeError: + except AttributeError: if hasattr(obj, 'contents'): prep_pointer(obj, shape) else: diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 24c7bde90..c29f3a6d3 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -267,8 +267,8 @@ class AxisConcatenator(object): newobj = newobj.swapaxes(-1,trans1d) elif isinstance(key[k],str): if k != 0: - raise ValueError, "special directives must be the"\ - "first entry." + raise ValueError("special directives must be the " + "first entry.") key0 = key[0] if key0 in 'rc': self.matrix = True diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 719cf0814..946cf172a 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -187,8 +187,8 @@ def apply_over_axes(func, a, axes): if res.ndim == val.ndim: val = res else: - raise ValueError, "function is not returning"\ - " an array of correct shape" + raise ValueError("function is not returning " + "an array of the correct shape") return val def expand_dims(a, axis): diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 1aaefd089..44396f075 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -151,8 +151,8 @@ def _fastCopyAndTranspose(type, *arrays): def _assertRank2(*arrays): for a in arrays: if len(a.shape) != 2: - raise LinAlgError, '%d-dimensional array given. Array must be \ - two-dimensional' % len(a.shape) + raise LinAlgError('%d-dimensional array given. Array must be ' + 'two-dimensional' % len(a.shape)) def _assertSquareness(*arrays): for a in arrays: @@ -527,8 +527,8 @@ def cholesky(a): lapack_routine = lapack_lite.dpotrf results = lapack_routine(_L, n, a, m, 0) if results['info'] > 0: - raise LinAlgError, 'Matrix is not positive definite - \ - Cholesky decomposition cannot be computed' + raise LinAlgError('Matrix is not positive definite - ' + 'Cholesky decomposition cannot be computed') s = triu(a, k=0).transpose() if (s.dtype != result_t): s = s.astype(result_t) diff --git a/numpy/oldnumeric/mlab.py b/numpy/oldnumeric/mlab.py index e2a0262f0..2c84b6960 100644 --- a/numpy/oldnumeric/mlab.py +++ b/numpy/oldnumeric/mlab.py @@ -80,8 +80,7 @@ def cov(m, y=None, rowvar=0, bias=0): y = transpose(y) N = m.shape[0] if (y.shape[0] != N): - raise ValueError, "x and y must have the same number "\ - "of observations" + raise ValueError("x and y must have the same number of observations") m = m - _Nmean(m,axis=0) y = y - _Nmean(y,axis=0) if bias: |