Skip to content
Browse files

STY: remove plain asserts from sparse, lib/lapack, linalg and stats m…

…odules.
  • Loading branch information...
1 parent db1b018 commit 7ac2646241d011c38e4e6368b00e21f99cdaf8c7 @rgommers rgommers committed
View
8 scipy/lib/lapack/tests/test_esv.py
@@ -1,6 +1,6 @@
import numpy as np
from numpy.testing import TestCase, assert_array_almost_equal, dec, \
- assert_equal
+ assert_equal, assert_
from common import FUNCS_TP, FLAPACK_IS_EMPTY, CLAPACK_IS_EMPTY, FUNCS_FLAPACK, \
FUNCS_CLAPACK, PREC
@@ -22,7 +22,7 @@ def _test_base(self, func, lang):
w, v, info = f(a)
- assert not info, `info`
+ assert_(not info, msg=repr(info))
assert_array_almost_equal(w, SYEV_REF, decimal=PREC[tp])
for i in range(3):
assert_array_almost_equal(np.dot(a,v[:,i]), w[i]*v[:,i],
@@ -41,7 +41,7 @@ def _test_base_irange(self, func, irange, lang):
w, v, info = f(a, irange=irange)
rslice = slice(irange[0], irange[1]+1)
m = irange[1] - irange[0] + 1
- assert not info, `info`
+ assert_(not info, msg=repr(info))
assert_equal(len(w),m)
assert_array_almost_equal(w, SYEV_REF[rslice], decimal=PREC[tp])
@@ -63,7 +63,7 @@ def _test_base_vrange(self, func, vrange, lang):
raise ValueError("Lang %s ??" % lang)
w, v, info = f(a, vrange=vrange)
- assert not info, `info`
+ assert_(not info, msg=repr(info))
assert_array_almost_equal(w, ew, decimal=PREC[tp])
View
4 scipy/lib/lapack/tests/test_gesv.py
@@ -1,6 +1,6 @@
import numpy as np
from numpy.testing import TestCase, assert_array_almost_equal, dec, \
- assert_equal
+ assert_equal, assert_
from common import FUNCS_TP, FLAPACK_IS_EMPTY, CLAPACK_IS_EMPTY, FUNCS_FLAPACK, \
FUNCS_CLAPACK, PREC
@@ -22,7 +22,7 @@ def _test_base(self, func, lang, itype):
w, v, info = f(a, b, itype=itype)
- assert not info, `info`
+ assert_(not info, msg=repr(info))
for i in range(3):
if itype == 1:
assert_array_almost_equal(np.dot(a,v[:,i]), w[i]*np.dot(b,v[:,i]),
View
6 scipy/lib/lapack/tests/test_lapack.py
@@ -26,13 +26,13 @@ def _test_gebal_base(self, func, lang):
raise ValueError("Lang %s ??" % lang)
ba, lo, hi, pivscale, info = f(a)
- assert not info, `info`
+ assert_(not info, msg=repr(info))
assert_array_almost_equal(ba, a)
assert_equal((lo,hi), (0, len(a[0])-1))
assert_array_almost_equal(pivscale, np.ones(len(a)))
ba, lo, hi, pivscale, info = f(a1,permute=1,scale=1)
- assert not info, `info`
+ assert_(not info, msg=repr(info))
def _test_gehrd_base(self, func, lang):
tp = FUNCS_TP[func]
@@ -49,7 +49,7 @@ def _test_gehrd_base(self, func, lang):
raise ValueError("Lang %s ??" % lang)
ht, tau, info = f(a)
- assert not info,`info`
+ assert_(not info, msg=repr(info))
@dec.skipif(FLAPACK_IS_EMPTY, "Flapack empty, skip flapack test")
def test_sgebal(self):
View
6 scipy/linalg/benchmarks/bench_basic.py
@@ -34,7 +34,7 @@ def bench_random(self):
sys.stdout.flush()
a = a[-1::-1,-1::-1] # turn into a non-contiguous array
- assert not a.flags['CONTIGUOUS']
+ assert_(not a.flags['CONTIGUOUS'])
print '| %6.2f ' % measure('solve(a,b)',repeat),
sys.stdout.flush()
@@ -71,7 +71,7 @@ def bench_random(self):
sys.stdout.flush()
a = a[-1::-1,-1::-1] # turn into a non-contiguous array
- assert not a.flags['CONTIGUOUS']
+ assert_(not a.flags['CONTIGUOUS'])
print '| %6.2f ' % measure('inv(a)',repeat),
sys.stdout.flush()
@@ -107,7 +107,7 @@ def bench_random(self):
sys.stdout.flush()
a = a[-1::-1,-1::-1] # turn into a non-contiguous array
- assert not a.flags['CONTIGUOUS']
+ assert_(not a.flags['CONTIGUOUS'])
print '| %6.2f ' % measure('det(a)',repeat),
sys.stdout.flush()
View
6 scipy/sparse/dok.py
@@ -103,9 +103,7 @@ def get(self, key, default=0.):
assert isintlike(i) and isintlike(j)
except (AssertionError, TypeError, ValueError):
raise IndexError('index must be a pair of integers')
- try:
- assert not (i < 0 or i >= self.shape[0] or j < 0 or j >= self.shape[1])
- except AssertionError:
+ if (i < 0 or i >= self.shape[0] or j < 0 or j >= self.shape[1]):
raise IndexError('index out of bounds')
return dict.get(self, key, default)
@@ -532,7 +530,7 @@ def toarray(self):
def resize(self, shape):
""" Resize the matrix in-place to dimensions given by 'shape'.
-
+
Any non-zero elements that lie outside the new shape are removed.
"""
if not isshape(shape):
View
2 scipy/stats/tests/test_continuous_basic.py
@@ -300,7 +300,7 @@ def check_sample_meanvar(sm,m,msg):
npt.assert_almost_equal(sm, m, decimal=DECIMAL, err_msg= msg + \
' - finite moment')
## else:
-## assert abs(sm) > 10000, 'infinite moment, sm = ' + str(sm)
+## npt.assert_(abs(sm) > 10000), msg='infinite moment, sm = ' + str(sm))
@_silence_fp_errors
def check_cdf_ppf(distfn,arg,msg):
View
2 scipy/stats/tests/test_discrete_basic.py
@@ -31,7 +31,7 @@
def test_discrete_basic():
for distname, arg in distdiscrete:
distfn = getattr(stats,distname)
- #assert stats.dlaplace.rvs(0.8) is not None
+ #npt.assert_(stats.dlaplace.rvs(0.8) is not None)
np.random.seed(9765456)
rvs = distfn.rvs(size=2000,*arg)
supp = np.unique(rvs)

0 comments on commit 7ac2646

Please sign in to comment.
Something went wrong with that request. Please try again.