diff options
Diffstat (limited to 'numpy')
33 files changed, 193 insertions, 193 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) diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py index 1fdf3c396..1868ee0c9 100644 --- a/numpy/ctypeslib.py +++ b/numpy/ctypeslib.py @@ -72,7 +72,7 @@ if ctypes is None: If ctypes is not available. """ - raise ImportError, "ctypes is not available." + raise ImportError("ctypes is not available.") ctypes_load_library = _dummy load_library = _dummy as_ctypes = _dummy @@ -163,7 +163,7 @@ class _ndptr(_ndptr_base): @classmethod def from_param(cls, obj): if not isinstance(obj, ndarray): - raise TypeError, "argument must be an ndarray" + 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_ @@ -251,7 +251,7 @@ def ndpointer(dtype=None, ndim=None, shape=None, flags=None): try: flags = [x.strip().upper() for x in flags] except: - raise TypeError, "invalid flags specification" + raise TypeError("invalid flags specification") num = _num_fromflags(flags) try: return _pointer_type_cache[(dtype, ndim, shape, num)] diff --git a/numpy/f2py/tests/test_array_from_pyobj.py b/numpy/f2py/tests/test_array_from_pyobj.py index ccf237ee1..e760e8e4e 100644 --- a/numpy/f2py/tests/test_array_from_pyobj.py +++ b/numpy/f2py/tests/test_array_from_pyobj.py @@ -301,7 +301,7 @@ class _test_shared_memory: if not str(msg).startswith('failed to initialize intent(inout|inplace|cache) array'): raise else: - raise SystemError,'intent(inout) should have failed on sequence' + raise SystemError('intent(inout) should have failed on sequence') def test_f_inout_23seq(self): obj = array(self.num23seq,dtype=self.type.dtype,order='F') @@ -317,7 +317,7 @@ class _test_shared_memory: if not str(msg).startswith('failed to initialize intent(inout) array'): raise else: - raise SystemError,'intent(inout) should have failed on improper array' + raise SystemError('intent(inout) should have failed on improper array') def test_c_inout_23seq(self): obj = array(self.num23seq,dtype=self.type.dtype) @@ -402,7 +402,7 @@ class _test_shared_memory: if not str(msg).startswith('failed to initialize intent(cache) array'): raise else: - raise SystemError,'intent(cache) should have failed on multisegmented array' + raise SystemError('intent(cache) should have failed on multisegmented array') def test_in_cache_from_2casttype_failure(self): for t in self.type.all_types(): if t.elsize >= self.type.elsize: @@ -415,7 +415,7 @@ class _test_shared_memory: if not str(msg).startswith('failed to initialize intent(cache) array'): raise else: - raise SystemError,'intent(cache) should have failed on smaller array' + raise SystemError('intent(cache) should have failed on smaller array') def test_cache_hidden(self): shape = (2,) @@ -433,7 +433,7 @@ class _test_shared_memory: if not str(msg).startswith('failed to create intent(cache|hide)|optional array'): raise else: - raise SystemError,'intent(cache) should have failed on undefined dimensions' + raise SystemError('intent(cache) should have failed on undefined dimensions') def test_hidden(self): shape = (2,) @@ -460,7 +460,7 @@ class _test_shared_memory: if not str(msg).startswith('failed to create intent(cache|hide)|optional array'): raise else: - raise SystemError,'intent(hide) should have failed on undefined dimensions' + raise SystemError('intent(hide) should have failed on undefined dimensions') def test_optional_none(self): shape = (2,) diff --git a/numpy/fft/fftpack.py b/numpy/fft/fftpack.py index 7f9ee57fd..2f19ba3d8 100644 --- a/numpy/fft/fftpack.py +++ b/numpy/fft/fftpack.py @@ -509,7 +509,7 @@ def _cook_nd_args(a, s=None, axes=None, invreal=0): if axes is None: axes = range(-len(s), 0) if len(s) != len(axes): - raise ValueError, "Shape and axes have different lengths." + raise ValueError("Shape and axes have different lengths.") if invreal and shapeless: s[axes[-1]] = (s[axes[-1]] - 1) * 2 return s, axes diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 0709499ea..df579a539 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -3049,7 +3049,7 @@ def _compute_qth_percentile(sorted, q, axis, out): q = q / 100.0 if (q < 0) or (q > 1): - raise ValueError, "percentile must be either in the range [0,100]" + raise ValueError("percentile must be either in the range [0,100]") indexer = [slice(None)] * sorted.ndim Nx = sorted.shape[axis] diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 69539d482..24c7bde90 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -70,7 +70,7 @@ def ix_(*args): for k in range(nd): new = _nx.asarray(args[k]) if (new.ndim != 1): - raise ValueError, "Cross index must be 1 dimensional" + raise ValueError("Cross index must be 1 dimensional") if issubclass(new.dtype.type, _nx.bool_): new = new.nonzero()[0] baseshape[k] = len(new) @@ -283,12 +283,12 @@ class AxisConcatenator(object): trans1d = int(vec[2]) continue except: - raise ValueError, "unknown special directive" + raise ValueError("unknown special directive") try: self.axis = int(key[k]) continue except (ValueError, TypeError): - raise ValueError, "unknown special directive" + raise ValueError("unknown special directive") elif type(key[k]) in ScalarType: newobj = array(key[k],ndmin=ndmin) scalars.append(k) diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 1dadc0d1a..da8074f97 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -45,7 +45,7 @@ def seek_gzip_factory(f): offset = self.offset + offset if whence not in [0, 1]: - raise IOError, "Illegal argument" + raise IOError("Illegal argument") if offset < self.offset: # for negative seek, rewind and do positive seek diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 94da4784c..47078ae88 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -125,7 +125,7 @@ def poly(seq_of_zeros): elif len(sh) == 1: pass else: - raise ValueError, "input must be 1d or square 2d array." + raise ValueError("input must be 1d or square 2d array.") if len(seq_of_zeros) == 0: return 1.0 @@ -198,7 +198,7 @@ def roots(p): # If input is scalar, this makes it an array p = atleast_1d(p) if len(p.shape) != 1: - raise ValueError,"Input must be a rank-1 array." + raise ValueError("Input must be a rank-1 array.") # find non-zero array entries non_zero = NX.nonzero(NX.ravel(p))[0] @@ -299,7 +299,7 @@ def polyint(p, m=1, k=None): """ m = int(m) if m < 0: - raise ValueError, "Order of integral must be positive (see polyder)" + raise ValueError("Order of integral must be positive (see polyder)") if k is None: k = NX.zeros(m, float) k = atleast_1d(k) @@ -377,7 +377,7 @@ def polyder(p, m=1): """ m = int(m) if m < 0: - raise ValueError, "Order of derivative must be positive (see polyint)" + raise ValueError("Order of derivative must be positive (see polyint)") truepoly = isinstance(p, poly1d) p = NX.asarray(p) @@ -531,15 +531,15 @@ def polyfit(x, y, deg, rcond=None, full=False): # check arguments. if deg < 0 : - raise ValueError, "expected deg >= 0" + raise ValueError("expected deg >= 0") if x.ndim != 1: - raise TypeError, "expected 1D vector for x" + raise TypeError("expected 1D vector for x") if x.size == 0: - raise TypeError, "expected non-empty vector for x" + raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2 : - raise TypeError, "expected 1D or 2D array for y" + raise TypeError("expected 1D or 2D array for y") if x.shape[0] != y.shape[0] : - raise TypeError, "expected x and y to have same length" + raise TypeError("expected x and y to have same length") # set rcond if rcond is None : @@ -1010,7 +1010,7 @@ class poly1d(object): c_or_r = poly(c_or_r) c_or_r = atleast_1d(c_or_r) if len(c_or_r.shape) > 1: - raise ValueError, "Polynomial must be 1d only." + raise ValueError("Polynomial must be 1d only.") c_or_r = trim_zeros(c_or_r, trim='f') if len(c_or_r) == 0: c_or_r = NX.array([0.]) @@ -1125,7 +1125,7 @@ class poly1d(object): def __pow__(self, val): if not isscalar(val) or int(val) != val or val < 0: - raise ValueError, "Power to non-negative integers only." + raise ValueError("Power to non-negative integers only.") res = [1] for _ in range(val): res = polymul(self.coeffs, res) @@ -1164,7 +1164,7 @@ class poly1d(object): return NX.any(self.coeffs != other.coeffs) def __setattr__(self, key, val): - raise ValueError, "Attributes cannot be changed this way." + raise ValueError("Attributes cannot be changed this way.") def __getattr__(self, key): if key in ['r', 'roots']: @@ -1190,7 +1190,7 @@ class poly1d(object): def __setitem__(self, key, val): ind = self.order - key if key < 0: - raise ValueError, "Does not support negative powers." + raise ValueError("Does not support negative powers.") if key > self.order: zr = NX.zeros(key-self.order, self.coeffs.dtype) self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs)) diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 5ea2648cb..719cf0814 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -383,7 +383,7 @@ def array_split(ary,indices_or_sections,axis = 0): except TypeError: #indices_or_sections is a scalar, not an array. Nsections = int(indices_or_sections) if Nsections <= 0: - raise ValueError, 'number sections must be larger than 0.' + raise ValueError('number sections must be larger than 0.') Neach_section,extras = divmod(Ntotal,Nsections) section_sizes = [0] + \ extras * [Neach_section+1] + \ @@ -474,7 +474,7 @@ def split(ary,indices_or_sections,axis=0): sections = indices_or_sections N = ary.shape[axis] if N % sections: - raise ValueError, 'array split does not result in an equal division' + raise ValueError('array split does not result in an equal division') res = array_split(ary,indices_or_sections,axis) return res @@ -534,7 +534,7 @@ def hsplit(ary,indices_or_sections): """ if len(_nx.shape(ary)) == 0: - raise ValueError, 'hsplit only works on arrays of 1 or more dimensions' + raise ValueError('hsplit only works on arrays of 1 or more dimensions') if len(ary.shape) > 1: return split(ary,indices_or_sections,1) else: @@ -588,7 +588,7 @@ def vsplit(ary,indices_or_sections): """ if len(_nx.shape(ary)) < 2: - raise ValueError, 'vsplit only works on arrays of 2 or more dimensions' + raise ValueError('vsplit only works on arrays of 2 or more dimensions') return split(ary,indices_or_sections,0) def dsplit(ary,indices_or_sections): @@ -633,7 +633,7 @@ def dsplit(ary,indices_or_sections): """ if len(_nx.shape(ary)) < 3: - raise ValueError, 'vsplit only works on arrays of 3 or more dimensions' + raise ValueError('vsplit only works on arrays of 3 or more dimensions') return split(ary,indices_or_sections,2) def get_array_prepare(*args): diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py index 024542ccc..0ce851fe4 100644 --- a/numpy/lib/type_check.py +++ b/numpy/lib/type_check.py @@ -607,10 +607,10 @@ def datetime_data(dtype): try: import ctypes except ImportError: - raise RuntimeError, "Cannot access date-time internals without ctypes installed" + raise RuntimeError("Cannot access date-time internals without ctypes installed") if dtype.kind not in ['m','M']: - raise ValueError, "Not a date-time dtype" + raise ValueError("Not a date-time dtype") obj = dtype.metadata[METADATA_DTSTR] class DATETIMEMETA(ctypes.Structure): diff --git a/numpy/lib/user_array.py b/numpy/lib/user_array.py index 43e9da3f2..01b0b1c19 100644 --- a/numpy/lib/user_array.py +++ b/numpy/lib/user_array.py @@ -149,7 +149,7 @@ class container(object): if len(self.shape) == 0: return func(self[0]) else: - raise TypeError, "only rank-0 arrays can be converted to Python scalars." + raise TypeError("only rank-0 arrays can be converted to Python scalars.") def __complex__(self): return self._scalarfunc(complex) def __float__(self): return self._scalarfunc(float) diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 87be0e8a3..043deb24f 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -57,7 +57,7 @@ class LinAlgError(Exception): in inv return wrap(solve(a, identity(a.shape[0], dtype=a.dtype))) File "...linalg.py", line 249, in solve - raise LinAlgError, 'Singular matrix' + raise LinAlgError('Singular matrix') numpy.linalg.linalg.LinAlgError: Singular matrix """ @@ -157,12 +157,12 @@ def _assertRank2(*arrays): def _assertSquareness(*arrays): for a in arrays: if max(a.shape) != min(a.shape): - raise LinAlgError, 'Array must be square' + raise LinAlgError('Array must be square') def _assertFinite(*arrays): for a in arrays: if not (isfinite(a).all()): - raise LinAlgError, "Array must not contain infs or NaNs" + raise LinAlgError("Array must not contain infs or NaNs") def _assertNonEmpty(*arrays): for a in arrays: @@ -313,7 +313,7 @@ def solve(a, b): n_eq = a.shape[0] n_rhs = b.shape[1] if n_eq != b.shape[0]: - raise LinAlgError, 'Incompatible dimensions' + raise LinAlgError('Incompatible dimensions') t, result_t = _commonType(a, b) # lapack_routine = _findLapackRoutine('gesv', t) if isComplexType(t): @@ -325,7 +325,7 @@ def solve(a, b): pivots = zeros(n_eq, fortran_int) results = lapack_routine(n_eq, n_rhs, a, n_eq, pivots, b, n_eq, 0) if results['info'] > 0: - raise LinAlgError, 'Singular matrix' + raise LinAlgError('Singular matrix') if one_eq: return wrap(b.ravel().astype(result_t)) else: @@ -393,7 +393,7 @@ def tensorinv(a, ind=2): for k in oldshape[ind:]: prod *= k else: - raise ValueError, "Invalid ind argument." + raise ValueError("Invalid ind argument.") a = a.reshape(prod, -1) ia = inv(a) return ia.reshape(*invshape) @@ -802,7 +802,7 @@ def eigvals(a): w = wr+1j*wi result_t = _complexType(result_t) if results['info'] > 0: - raise LinAlgError, 'Eigenvalues did not converge' + raise LinAlgError('Eigenvalues did not converge') return w.astype(result_t) @@ -891,7 +891,7 @@ def eigvalsh(a, UPLO='L'): results = lapack_routine(_N, UPLO, n, a, n, w, work, lwork, iwork, liwork, 0) if results['info'] > 0: - raise LinAlgError, 'Eigenvalues did not converge' + raise LinAlgError('Eigenvalues did not converge') return w.astype(result_t) def _convertarray(a): @@ -1061,7 +1061,7 @@ def eig(a): result_t = _complexType(result_t) if results['info'] > 0: - raise LinAlgError, 'Eigenvalues did not converge' + raise LinAlgError('Eigenvalues did not converge') vt = v.transpose().astype(result_t) return w.astype(result_t), wrap(vt) @@ -1184,7 +1184,7 @@ def eigh(a, UPLO='L'): results = lapack_routine(_V, UPLO, n, a, n, w, work, lwork, iwork, liwork, 0) if results['info'] > 0: - raise LinAlgError, 'Eigenvalues did not converge' + raise LinAlgError('Eigenvalues did not converge') at = a.transpose().astype(result_t) return w.astype(_realType(result_t)), wrap(at) @@ -1317,7 +1317,7 @@ def svd(a, full_matrices=1, compute_uv=1): results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt, work, lwork, iwork, 0) if results['info'] > 0: - raise LinAlgError, 'SVD did not converge' + raise LinAlgError('SVD did not converge') s = s.astype(_realType(result_t)) if compute_uv: u = u.transpose().astype(result_t) @@ -1627,7 +1627,7 @@ def slogdet(a): results = lapack_routine(n, n, a, n, pivots, 0) info = results['info'] if (info < 0): - raise TypeError, "Illegal input to Fortran routine" + raise TypeError("Illegal input to Fortran routine") elif (info > 0): return (t(0.0), _realType(t)(-Inf)) sign = 1. - 2. * (add.reduce(pivots != arange(1, n + 1)) % 2) @@ -1771,7 +1771,7 @@ def lstsq(a, b, rcond=-1): n_rhs = b.shape[1] ldb = max(n, m) if m != b.shape[0]: - raise LinAlgError, 'Incompatible dimensions' + raise LinAlgError('Incompatible dimensions') t, result_t = _commonType(a, b) result_real_t = _realType(result_t) real_t = _linalgRealType(t) @@ -1812,7 +1812,7 @@ def lstsq(a, b, rcond=-1): results = lapack_routine(m, n, n_rhs, a, m, bstar, ldb, s, rcond, 0, work, lwork, iwork, 0) if results['info'] > 0: - raise LinAlgError, 'SVD did not converge in Linear Least Squares' + raise LinAlgError('SVD did not converge in Linear Least Squares') resids = array([], result_real_t) if is_1d: x = array(ravel(bstar)[:n], dtype=result_t, copy=True) @@ -1959,7 +1959,7 @@ def norm(x, ord=None): try: ord + 1 except TypeError: - raise ValueError, "Invalid norm order for vectors." + raise ValueError("Invalid norm order for vectors.") return ((abs(x)**ord).sum())**(1.0/ord) elif nd == 2: if ord == 2: @@ -1977,6 +1977,6 @@ def norm(x, ord=None): elif ord in ['fro','f']: return sqrt(add.reduce((x.conj() * x).real.ravel())) else: - raise ValueError, "Invalid norm order for matrices." + raise ValueError("Invalid norm order for matrices.") else: - raise ValueError, "Improper number of dimensions to norm." + raise ValueError("Improper number of dimensions to norm.") diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 936df17f3..1ea40d417 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2976,7 +2976,7 @@ class MaskedArray(ndarray): """ if self is masked: - raise MaskError, 'Cannot alter the masked element.' + raise MaskError('Cannot alter the masked element.') # 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!" @@ -3792,7 +3792,7 @@ class MaskedArray(ndarray): 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.' + raise MaskError('Cannot convert masked element to a Python int.') return int(self.item()) @@ -5992,7 +5992,7 @@ def power(a, b, third=None): """ if third is not None: - raise MaskError, "3-argument power not supported." + raise MaskError("3-argument power not supported.") # Get the masks ma = getmask(a) mb = getmask(b) @@ -6536,7 +6536,7 @@ def where (condition, x=None, y=None): if x is None and y is None: return filled(condition, 0).nonzero() elif x is None or y is None: - raise ValueError, "Either both or neither x and y should be given." + raise ValueError("Either both or neither x and y should be given.") # Get the condition ............... fc = filled(condition, 0).astype(MaskType) notfc = np.logical_not(fc) diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index 1c28eadb8..27abcb2c1 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -533,7 +533,7 @@ def average(a, axis=None, weights=None, returned=False): d = add.reduce(w, axis, dtype=float) del w, r else: - raise ValueError, 'average: weights wrong shape.' + raise ValueError('average: weights wrong shape.') else: if weights is None: n = add.reduce(a, axis, dtype=float) @@ -556,7 +556,7 @@ def average(a, axis=None, weights=None, returned=False): n = add.reduce(a * w, axis, dtype=float) d = add.reduce(w, axis, dtype=float) else: - raise ValueError, 'average: weights wrong shape.' + raise ValueError('average: weights wrong shape.') del w if n is masked or d is masked: return masked @@ -718,7 +718,7 @@ def compress_rowcols(x, axis=None): """ x = asarray(x) if x.ndim != 2: - raise NotImplementedError, "compress2d works for 2D arrays only." + raise NotImplementedError("compress2d works for 2D arrays only.") m = getmask(x) # Nothing is masked: return x if m is nomask or not m.any(): @@ -842,7 +842,7 @@ def mask_rowcols(a, axis=None): """ a = asarray(a) if a.ndim != 2: - raise NotImplementedError, "compress2d works for 2D arrays only." + raise NotImplementedError("compress2d works for 2D arrays only.") m = getmask(a) # Nothing is masked: return a if m is nomask or not m.any(): @@ -1429,7 +1429,7 @@ class MAxisConcatenator(AxisConcatenator): def __getitem__(self, key): if isinstance(key, str): - raise MAError, "Unavailable for masked array." + raise MAError("Unavailable for masked array.") if type(key) is not tuple: key = (key,) objs = [] @@ -1459,7 +1459,7 @@ class MAxisConcatenator(AxisConcatenator): self.axis = int(key[k]) continue except (ValueError, TypeError): - raise ValueError, "Unknown special directive" + raise ValueError("Unknown special directive") elif type(key[k]) in np.ScalarType: newobj = asarray([key[k]]) scalars.append(k) @@ -1706,7 +1706,7 @@ def notmasked_contiguous(a, axis=None): a = asarray(a) nd = a.ndim if nd > 2: - raise NotImplementedError, "Currently limited to atmost 2D array." + raise NotImplementedError("Currently limited to atmost 2D array.") if axis is None or nd == 1: return flatnotmasked_contiguous(a) # @@ -1863,7 +1863,7 @@ def polyfit(x, y, deg, rcond=None, full=False): else: m = mx else: - raise TypeError, "Expected a 1D or 2D array for y!" + raise TypeError("Expected a 1D or 2D array for y!") if m is not nomask: x[m] = y[m] = masked # Set rcond diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index 79fa6e15b..9e06908b2 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -589,7 +589,7 @@ on the first line. An exception is raised if the file is 3D or more. if len(arr.shape) == 2 : arr = arr[0] elif len(arr.shape) > 2: - raise ValueError, "The array should be 2D at most!" + raise ValueError("The array should be 2D at most!") # Start the conversion loop ....... for f in arr: try: @@ -623,7 +623,7 @@ def openfile(fname): if f.readline()[:2] != "\\x": f.seek(0, 0) return f - raise NotImplementedError, "Wow, binary file" + raise NotImplementedError("Wow, binary file") def fromtextfile(fname, delimitor=None, commentchar='#', missingchar='', diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py index a5aa84f6d..a46f2dab0 100644 --- a/numpy/matrixlib/defmatrix.py +++ b/numpy/matrixlib/defmatrix.py @@ -47,7 +47,7 @@ def _convert_from_string(data): if count == 0: Ncols = len(newrow) elif len(newrow) != Ncols: - raise ValueError, "Rows not the same size." + raise ValueError("Rows not the same size.") count += 1 newdata.append(newrow) return newdata @@ -258,7 +258,7 @@ class matrix(N.ndarray): ndim = arr.ndim shape = arr.shape if (ndim > 2): - raise ValueError, "matrix must be 2-dimensional" + raise ValueError("matrix must be 2-dimensional") elif ndim == 0: shape = (1,1) elif ndim == 1: @@ -289,7 +289,7 @@ class matrix(N.ndarray): self.shape = newshape return elif (ndim > 2): - raise ValueError, "shape too large to be a matrix." + raise ValueError("shape too large to be a matrix.") else: newshape = self.shape if ndim == 0: @@ -373,7 +373,7 @@ class matrix(N.ndarray): elif axis==1: return self.transpose() else: - raise ValueError, "unsupported axis" + raise ValueError("unsupported axis") # Necessary because base-class tolist expects dimension # reduction by x[0] diff --git a/numpy/oldnumeric/arrayfns.py b/numpy/oldnumeric/arrayfns.py index 230b200a9..683ed309d 100644 --- a/numpy/oldnumeric/arrayfns.py +++ b/numpy/oldnumeric/arrayfns.py @@ -14,9 +14,9 @@ class error(Exception): def array_set(vals1, indices, vals2): indices = asarray(indices) if indices.ndim != 1: - raise ValueError, "index array must be 1-d" + raise ValueError("index array must be 1-d") if not isinstance(vals1, np.ndarray): - raise TypeError, "vals1 must be an ndarray" + raise TypeError("vals1 must be an ndarray") vals1 = asarray(vals1) vals2 = asarray(vals2) if vals1.ndim != vals2.ndim or vals1.ndim < 1: @@ -43,14 +43,14 @@ def interp(y, x, z, typ=None): def nz(x): x = asarray(x,dtype=np.ubyte) if x.ndim != 1: - raise TypeError, "intput must have 1 dimension." + raise TypeError("intput must have 1 dimension.") indxs = np.flatnonzero(x != 0) return indxs[-1].item()+1 def reverse(x, n): x = asarray(x,dtype='d') if x.ndim != 2: - raise ValueError, "input must be 2-d" + raise ValueError("input must be 2-d") y = np.empty_like(x) if n == 0: y[...] = x[::-1,:] @@ -71,7 +71,7 @@ def zmin_zmax(z, ireg): z = asarray(z, dtype=float) ireg = asarray(ireg, dtype=int) if z.shape != ireg.shape or z.ndim != 2: - raise ValueError, "z and ireg must be the same shape and 2-d" + raise ValueError("z and ireg must be the same shape and 2-d") ix, iy = np.nonzero(ireg) # Now, add more indices x1m = ix - 1 diff --git a/numpy/oldnumeric/compat.py b/numpy/oldnumeric/compat.py index 607dd0b90..083a1fa15 100644 --- a/numpy/oldnumeric/compat.py +++ b/numpy/oldnumeric/compat.py @@ -112,6 +112,6 @@ else: class Pickler(pickle.Pickler): def __init__(self, *args, **kwds): - raise NotImplementedError, "Don't pickle new arrays with this" + raise NotImplementedError("Don't pickle new arrays with this") def save_array(self, object): - raise NotImplementedError, "Don't pickle new arrays with this" + raise NotImplementedError("Don't pickle new arrays with this") diff --git a/numpy/oldnumeric/functions.py b/numpy/oldnumeric/functions.py index 5b2b1a8bf..db62f7cb5 100644 --- a/numpy/oldnumeric/functions.py +++ b/numpy/oldnumeric/functions.py @@ -91,7 +91,7 @@ def nonzero(a): if len(res) == 1: return res[0] else: - raise ValueError, "Input argument must be 1d" + raise ValueError("Input argument must be 1d") def reshape(a, shape): return np.reshape(a, shape) diff --git a/numpy/oldnumeric/ma.py b/numpy/oldnumeric/ma.py index 1284c6019..d30f673a8 100644 --- a/numpy/oldnumeric/ma.py +++ b/numpy/oldnumeric/ma.py @@ -122,7 +122,7 @@ def minimum_fill_value (obj): if x in typecodes['UnsignedInteger']: return sys.maxint else: - raise TypeError, 'Unsuitable type for calculating minimum.' + raise TypeError('Unsuitable type for calculating minimum.') def maximum_fill_value (obj): "Function to calculate default fill value suitable for taking maxima." @@ -139,7 +139,7 @@ def maximum_fill_value (obj): if x in typecodes['UnsignedInteger']: return 0 else: - raise TypeError, 'Unsuitable type for calculating maximum.' + raise TypeError('Unsuitable type for calculating maximum.') def set_fill_value (a, fill_value): "Set fill value of a if it is a masked array." @@ -598,7 +598,7 @@ class MaskedArray (object): self._data = fromnumeric.resize(self._data, self._mask.shape) self._data.shape = self._mask.shape else: - raise MAError, "Mask and data not compatible." + raise MAError("Mask and data not compatible.") elif nm == 1 and shape(self._mask) != shape(self._data): self.unshare_mask() self._mask.shape = self._data.shape @@ -786,14 +786,14 @@ array(data = %(data)s, "Convert self to float." self.unmask() if self._mask is not nomask: - raise MAError, 'Cannot convert masked element to a Python float.' + raise MAError('Cannot convert masked element to a Python float.') return float(self.data.item()) def __int__(self): "Convert self to int." self.unmask() if self._mask is not nomask: - raise MAError, 'Cannot convert masked element to a Python int.' + raise MAError('Cannot convert masked element to a Python int.') return int(self.data.item()) def __getitem__(self, i): @@ -827,7 +827,7 @@ array(data = %(data)s, "Set item described by index. If value is masked, mask those locations." d = self._data if self is masked: - raise MAError, 'Cannot alter masked elements.' + raise MAError('Cannot alter masked elements.') if value is masked: if self._mask is nomask: self._mask = make_mask_none(d.shape) @@ -973,14 +973,14 @@ array(data = %(data)s, if t1 in typecodes['Integer']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Float']: if t1 in typecodes['Integer']: f = f.astype(t) elif t1 in typecodes['Float']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Complex']: if t1 in typecodes['Integer']: f = f.astype(t) @@ -989,9 +989,9 @@ array(data = %(data)s, elif t1 in typecodes['Complex']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') if self._mask is nomask: self._data += f @@ -1016,14 +1016,14 @@ array(data = %(data)s, if t1 in typecodes['Integer']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Float']: if t1 in typecodes['Integer']: f = f.astype(t) elif t1 in typecodes['Float']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Complex']: if t1 in typecodes['Integer']: f = f.astype(t) @@ -1032,9 +1032,9 @@ array(data = %(data)s, elif t1 in typecodes['Complex']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') if self._mask is nomask: self._data *= f @@ -1059,14 +1059,14 @@ array(data = %(data)s, if t1 in typecodes['Integer']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Float']: if t1 in typecodes['Integer']: f = f.astype(t) elif t1 in typecodes['Float']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Complex']: if t1 in typecodes['Integer']: f = f.astype(t) @@ -1075,9 +1075,9 @@ array(data = %(data)s, elif t1 in typecodes['Complex']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') if self._mask is nomask: self._data -= f @@ -1104,14 +1104,14 @@ array(data = %(data)s, if t1 in typecodes['Integer']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Float']: if t1 in typecodes['Integer']: f = f.astype(t) elif t1 in typecodes['Float']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') elif t in typecodes['Complex']: if t1 in typecodes['Integer']: f = f.astype(t) @@ -1120,9 +1120,9 @@ array(data = %(data)s, elif t1 in typecodes['Complex']: f = f.astype(t) else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') else: - raise TypeError, 'Incorrect type for in-place operation.' + raise TypeError('Incorrect type for in-place operation.') mo = getmask(other) result = divide(self, masked_array(f, mask=mo)) self._data = result.data @@ -1567,7 +1567,7 @@ def count (a, axis = None): def power (a, b, third=None): "a**b" if third is not None: - raise MAError, "3-argument power not supported." + raise MAError("3-argument power not supported.") ma = getmask(a) mb = getmask(b) m = mask_or(ma, mb) @@ -1665,7 +1665,7 @@ def new_average (a, axis=None, weights=None, returned = 0): d = add.reduce(w, axis) del w, r else: - raise ValueError, 'average: weights wrong shape.' + raise ValueError('average: weights wrong shape.') else: if weights is None: n = add.reduce(a, axis) @@ -1688,7 +1688,7 @@ def new_average (a, axis=None, weights=None, returned = 0): n = add.reduce(a*w, axis) d = add.reduce(w, axis) else: - raise ValueError, 'average: weights wrong shape.' + raise ValueError('average: weights wrong shape.') del w #print n, d, repr(mask), repr(weights) if n is masked or d is masked: return masked @@ -2135,7 +2135,7 @@ from types import MethodType def _m(f): return MethodType(f, None, array) def not_implemented(*args, **kwds): - raise NotImplementedError, "not yet implemented for numpy.ma arrays" + raise NotImplementedError("not yet implemented for numpy.ma arrays") array.all = _m(alltrue) array.any = _m(sometrue) array.argmax = _m(argmax) diff --git a/numpy/oldnumeric/matrix.py b/numpy/oldnumeric/matrix.py index 5f8c1ca5e..ddd612266 100644 --- a/numpy/oldnumeric/matrix.py +++ b/numpy/oldnumeric/matrix.py @@ -41,7 +41,7 @@ def _convert_from_string(data): if count == 0: Ncols = len(newrow) elif len(newrow) != Ncols: - raise ValueError, "Rows not the same size." + raise ValueError("Rows not the same size.") count += 1 newdata.append(newrow) return newdata diff --git a/numpy/oldnumeric/random_array.py b/numpy/oldnumeric/random_array.py index e84aedf1e..ffae79616 100644 --- a/numpy/oldnumeric/random_array.py +++ b/numpy/oldnumeric/random_array.py @@ -41,12 +41,12 @@ def randint(minimum, maximum=None, shape=[]): """randint(min, max, shape=[]) = random integers >=min, < max If max not given, random integers >= 0, <min""" if not isinstance(minimum, int): - raise ArgumentError, "randint requires first argument integer" + raise ArgumentError("randint requires first argument integer") if maximum is None: maximum = minimum minimum = 0 if not isinstance(maximum, int): - raise ArgumentError, "randint requires second argument integer" + raise ArgumentError("randint requires second argument integer") a = ((maximum-minimum)* random(shape)) if isinstance(a, np.ndarray): return minimum + a.astype(np.int) diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py index 6b1edf497..a6482fc72 100644 --- a/numpy/polynomial/chebyshev.py +++ b/numpy/polynomial/chebyshev.py @@ -892,9 +892,9 @@ def chebder(cs, m=1, scl=1) : cnt = int(m) if cnt != m: - raise ValueError, "The order of derivation must be integer" + raise ValueError("The order of derivation must be integer") if cnt < 0 : - raise ValueError, "The order of derivation must be non-negative" + raise ValueError("The order of derivation must be non-negative") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -991,11 +991,11 @@ def chebint(cs, m=1, k=[], lbnd=0, scl=1): k = [k] if cnt != m: - raise ValueError, "The order of integration must be integer" + raise ValueError("The order of integration must be integer") if cnt < 0 : - raise ValueError, "The order of integration must be non-negative" + raise ValueError("The order of integration must be non-negative") if len(k) > cnt : - raise ValueError, "Too many integration constants" + raise ValueError("Too many integration constants") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -1226,15 +1226,15 @@ def chebfit(x, y, deg, rcond=None, full=False, w=None): # check arguments. if deg < 0 : - raise ValueError, "expected deg >= 0" + raise ValueError("expected deg >= 0") if x.ndim != 1: - raise TypeError, "expected 1D vector for x" + raise TypeError("expected 1D vector for x") if x.size == 0: - raise TypeError, "expected non-empty vector for x" + raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2 : - raise TypeError, "expected 1D or 2D array for y" + raise TypeError("expected 1D or 2D array for y") if len(x) != len(y): - raise TypeError, "expected x and y to have same length" + raise TypeError("expected x and y to have same length") # set up the least squares matrices lhs = chebvander(x, deg) @@ -1242,9 +1242,9 @@ def chebfit(x, y, deg, rcond=None, full=False, w=None): if w is not None: w = np.asarray(w) + 0.0 if w.ndim != 1: - raise TypeError, "expected 1D vector for w" + raise TypeError("expected 1D vector for w") if len(x) != len(w): - raise TypeError, "expected x and w to have same length" + raise TypeError("expected x and w to have same length") # apply weights if rhs.ndim == 2: lhs *= w[:, np.newaxis] diff --git a/numpy/polynomial/hermite.py b/numpy/polynomial/hermite.py index d266a6453..c3ff42b6c 100644 --- a/numpy/polynomial/hermite.py +++ b/numpy/polynomial/hermite.py @@ -665,9 +665,9 @@ def hermder(cs, m=1, scl=1) : cnt = int(m) if cnt != m: - raise ValueError, "The order of derivation must be integer" + raise ValueError("The order of derivation must be integer") if cnt < 0 : - raise ValueError, "The order of derivation must be non-negative" + raise ValueError("The order of derivation must be non-negative") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -766,11 +766,11 @@ def hermint(cs, m=1, k=[], lbnd=0, scl=1): k = [k] if cnt != m: - raise ValueError, "The order of integration must be integer" + raise ValueError("The order of integration must be integer") if cnt < 0 : - raise ValueError, "The order of integration must be non-negative" + raise ValueError("The order of integration must be non-negative") if len(k) > cnt : - raise ValueError, "Too many integration constants" + raise ValueError("Too many integration constants") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -1029,15 +1029,15 @@ def hermfit(x, y, deg, rcond=None, full=False, w=None): # check arguments. if deg < 0 : - raise ValueError, "expected deg >= 0" + raise ValueError("expected deg >= 0") if x.ndim != 1: - raise TypeError, "expected 1D vector for x" + raise TypeError("expected 1D vector for x") if x.size == 0: - raise TypeError, "expected non-empty vector for x" + raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2 : - raise TypeError, "expected 1D or 2D array for y" + raise TypeError("expected 1D or 2D array for y") if len(x) != len(y): - raise TypeError, "expected x and y to have same length" + raise TypeError("expected x and y to have same length") # set up the least squares matrices lhs = hermvander(x, deg) @@ -1045,9 +1045,9 @@ def hermfit(x, y, deg, rcond=None, full=False, w=None): if w is not None: w = np.asarray(w) + 0.0 if w.ndim != 1: - raise TypeError, "expected 1D vector for w" + raise TypeError("expected 1D vector for w") if len(x) != len(w): - raise TypeError, "expected x and w to have same length" + raise TypeError("expected x and w to have same length") # apply weights if rhs.ndim == 2: lhs *= w[:, np.newaxis] diff --git a/numpy/polynomial/hermite_e.py b/numpy/polynomial/hermite_e.py index e644e345a..be3c65a32 100644 --- a/numpy/polynomial/hermite_e.py +++ b/numpy/polynomial/hermite_e.py @@ -663,9 +663,9 @@ def hermeder(cs, m=1, scl=1) : cnt = int(m) if cnt != m: - raise ValueError, "The order of derivation must be integer" + raise ValueError("The order of derivation must be integer") if cnt < 0 : - raise ValueError, "The order of derivation must be non-negative" + raise ValueError("The order of derivation must be non-negative") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -764,11 +764,11 @@ def hermeint(cs, m=1, k=[], lbnd=0, scl=1): k = [k] if cnt != m: - raise ValueError, "The order of integration must be integer" + raise ValueError("The order of integration must be integer") if cnt < 0 : - raise ValueError, "The order of integration must be non-negative" + raise ValueError("The order of integration must be non-negative") if len(k) > cnt : - raise ValueError, "Too many integration constants" + raise ValueError("Too many integration constants") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -1025,15 +1025,15 @@ def hermefit(x, y, deg, rcond=None, full=False, w=None): # check arguments. if deg < 0 : - raise ValueError, "expected deg >= 0" + raise ValueError("expected deg >= 0") if x.ndim != 1: - raise TypeError, "expected 1D vector for x" + raise TypeError("expected 1D vector for x") if x.size == 0: - raise TypeError, "expected non-empty vector for x" + raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2 : - raise TypeError, "expected 1D or 2D array for y" + raise TypeError("expected 1D or 2D array for y") if len(x) != len(y): - raise TypeError, "expected x and y to have same length" + raise TypeError("expected x and y to have same length") # set up the least squares matrices lhs = hermevander(x, deg) @@ -1041,9 +1041,9 @@ def hermefit(x, y, deg, rcond=None, full=False, w=None): if w is not None: w = np.asarray(w) + 0.0 if w.ndim != 1: - raise TypeError, "expected 1D vector for w" + raise TypeError("expected 1D vector for w") if len(x) != len(w): - raise TypeError, "expected x and w to have same length" + raise TypeError("expected x and w to have same length") # apply weights if rhs.ndim == 2: lhs *= w[:, np.newaxis] diff --git a/numpy/polynomial/laguerre.py b/numpy/polynomial/laguerre.py index b6389bf63..1a75d4af4 100644 --- a/numpy/polynomial/laguerre.py +++ b/numpy/polynomial/laguerre.py @@ -662,9 +662,9 @@ def lagder(cs, m=1, scl=1) : cnt = int(m) if cnt != m: - raise ValueError, "The order of derivation must be integer" + raise ValueError("The order of derivation must be integer") if cnt < 0 : - raise ValueError, "The order of derivation must be non-negative" + raise ValueError("The order of derivation must be non-negative") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -764,11 +764,11 @@ def lagint(cs, m=1, k=[], lbnd=0, scl=1): k = [k] if cnt != m: - raise ValueError, "The order of integration must be integer" + raise ValueError("The order of integration must be integer") if cnt < 0 : - raise ValueError, "The order of integration must be non-negative" + raise ValueError("The order of integration must be non-negative") if len(k) > cnt : - raise ValueError, "Too many integration constants" + raise ValueError("Too many integration constants") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -1026,15 +1026,15 @@ def lagfit(x, y, deg, rcond=None, full=False, w=None): # check arguments. if deg < 0 : - raise ValueError, "expected deg >= 0" + raise ValueError("expected deg >= 0") if x.ndim != 1: - raise TypeError, "expected 1D vector for x" + raise TypeError("expected 1D vector for x") if x.size == 0: - raise TypeError, "expected non-empty vector for x" + raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2 : - raise TypeError, "expected 1D or 2D array for y" + raise TypeError("expected 1D or 2D array for y") if len(x) != len(y): - raise TypeError, "expected x and y to have same length" + raise TypeError("expected x and y to have same length") # set up the least squares matrices lhs = lagvander(x, deg) @@ -1042,9 +1042,9 @@ def lagfit(x, y, deg, rcond=None, full=False, w=None): if w is not None: w = np.asarray(w) + 0.0 if w.ndim != 1: - raise TypeError, "expected 1D vector for w" + raise TypeError("expected 1D vector for w") if len(x) != len(w): - raise TypeError, "expected x and w to have same length" + raise TypeError("expected x and w to have same length") # apply weights if rhs.ndim == 2: lhs *= w[:, np.newaxis] diff --git a/numpy/polynomial/legendre.py b/numpy/polynomial/legendre.py index 3ea68a5e6..e5b9ffe87 100644 --- a/numpy/polynomial/legendre.py +++ b/numpy/polynomial/legendre.py @@ -679,9 +679,9 @@ def legder(cs, m=1, scl=1) : cnt = int(m) if cnt != m: - raise ValueError, "The order of derivation must be integer" + raise ValueError("The order of derivation must be integer") if cnt < 0 : - raise ValueError, "The order of derivation must be non-negative" + raise ValueError("The order of derivation must be non-negative") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -783,11 +783,11 @@ def legint(cs, m=1, k=[], lbnd=0, scl=1): k = [k] if cnt != m: - raise ValueError, "The order of integration must be integer" + raise ValueError("The order of integration must be integer") if cnt < 0 : - raise ValueError, "The order of integration must be non-negative" + raise ValueError("The order of integration must be non-negative") if len(k) > cnt : - raise ValueError, "Too many integration constants" + raise ValueError("Too many integration constants") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -1023,15 +1023,15 @@ def legfit(x, y, deg, rcond=None, full=False, w=None): # check arguments. if deg < 0 : - raise ValueError, "expected deg >= 0" + raise ValueError("expected deg >= 0") if x.ndim != 1: - raise TypeError, "expected 1D vector for x" + raise TypeError("expected 1D vector for x") if x.size == 0: - raise TypeError, "expected non-empty vector for x" + raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2 : - raise TypeError, "expected 1D or 2D array for y" + raise TypeError("expected 1D or 2D array for y") if len(x) != len(y): - raise TypeError, "expected x and y to have same length" + raise TypeError("expected x and y to have same length") # set up the least squares matrices lhs = legvander(x, deg) @@ -1039,9 +1039,9 @@ def legfit(x, y, deg, rcond=None, full=False, w=None): if w is not None: w = np.asarray(w) + 0.0 if w.ndim != 1: - raise TypeError, "expected 1D vector for w" + raise TypeError("expected 1D vector for w") if len(x) != len(w): - raise TypeError, "expected x and w to have same length" + raise TypeError("expected x and w to have same length") # apply weights if rhs.ndim == 2: lhs *= w[:, np.newaxis] diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index 3efe25920..181716ad4 100644 --- a/numpy/polynomial/polynomial.py +++ b/numpy/polynomial/polynomial.py @@ -491,9 +491,9 @@ def polyder(cs, m=1, scl=1): cnt = int(m) if cnt != m: - raise ValueError, "The order of derivation must be integer" + raise ValueError("The order of derivation must be integer") if cnt < 0: - raise ValueError, "The order of derivation must be non-negative" + raise ValueError("The order of derivation must be non-negative") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -584,11 +584,11 @@ def polyint(cs, m=1, k=[], lbnd=0, scl=1): k = [k] if cnt != m: - raise ValueError, "The order of integration must be integer" + raise ValueError("The order of integration must be integer") if cnt < 0 : - raise ValueError, "The order of integration must be non-negative" + raise ValueError("The order of integration must be non-negative") if len(k) > cnt : - raise ValueError, "Too many integration constants" + raise ValueError("Too many integration constants") # cs is a trimmed copy [cs] = pu.as_series([cs]) @@ -825,15 +825,15 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None): # check arguments. if deg < 0 : - raise ValueError, "expected deg >= 0" + raise ValueError("expected deg >= 0") if x.ndim != 1: - raise TypeError, "expected 1D vector for x" + raise TypeError("expected 1D vector for x") if x.size == 0: - raise TypeError, "expected non-empty vector for x" + raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2 : - raise TypeError, "expected 1D or 2D array for y" + raise TypeError("expected 1D or 2D array for y") if len(x) != len(y): - raise TypeError, "expected x and y to have same length" + raise TypeError("expected x and y to have same length") # set up the least squares matrices lhs = polyvander(x, deg) @@ -841,9 +841,9 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None): if w is not None: w = np.asarray(w) + 0.0 if w.ndim != 1: - raise TypeError, "expected 1D vector for w" + raise TypeError("expected 1D vector for w") if len(x) != len(w): - raise TypeError, "expected x and w to have same length" + raise TypeError("expected x and w to have same length") # apply weights if rhs.ndim == 2: lhs *= w[:, np.newaxis] diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index 5ead74980..26118eda2 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -174,7 +174,7 @@ class NoseTester(object): argv = [__file__, self.package_path, '-s'] if label and label != 'full': if not isinstance(label, basestring): - raise TypeError, 'Selection label should be a string' + raise TypeError('Selection label should be a string') if label == 'fast': label = 'not slow' argv += ['-A', label] |