Skip to content

Commit

Permalink
STY: remove plain asserts from sparse, lib/lapack, linalg and stats m…
Browse files Browse the repository at this point in the history
…odules.
  • Loading branch information
rgommers committed Jun 4, 2011
1 parent db1b018 commit 7ac2646
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
8 changes: 4 additions & 4 deletions scipy/lib/lapack/tests/test_esv.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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],
Expand All @@ -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])
Expand All @@ -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])

Expand Down
4 changes: 2 additions & 2 deletions scipy/lib/lapack/tests/test_gesv.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]),
Expand Down
6 changes: 3 additions & 3 deletions scipy/lib/lapack/tests/test_lapack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions scipy/linalg/benchmarks/bench_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions scipy/sparse/dok.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/tests/test_continuous_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/tests/test_discrete_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7ac2646

Please sign in to comment.