summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/function_base.py2
-rw-r--r--numpy/lib/index_tricks.py6
-rw-r--r--numpy/lib/npyio.py2
-rw-r--r--numpy/lib/polynomial.py26
-rw-r--r--numpy/lib/shape_base.py10
-rw-r--r--numpy/lib/type_check.py4
-rw-r--r--numpy/lib/user_array.py2
7 files changed, 26 insertions, 26 deletions
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)