[Scipy-svn] r6801 - trunk/scipy/stats/tests

scipy-svn@scip... scipy-svn@scip...
Sun Sep 12 16:31:02 CDT 2010


Author: warren.weckesser
Date: 2010-09-12 16:31:02 -0500 (Sun, 12 Sep 2010)
New Revision: 6801

Modified:
   trunk/scipy/stats/tests/test_continuous_basic.py
   trunk/scipy/stats/tests/test_continuous_extra.py
   trunk/scipy/stats/tests/test_discrete_basic.py
   trunk/scipy/stats/tests/test_distributions.py
   trunk/scipy/stats/tests/test_mstats_basic.py
   trunk/scipy/stats/tests/test_mstats_extras.py
   trunk/scipy/stats/tests/test_stats.py
Log:
TST: stats: Don't use plain 'assert'.

Modified: trunk/scipy/stats/tests/test_continuous_basic.py
===================================================================
--- trunk/scipy/stats/tests/test_continuous_basic.py	2010-09-12 21:30:28 UTC (rev 6800)
+++ trunk/scipy/stats/tests/test_continuous_basic.py	2010-09-12 21:31:02 UTC (rev 6801)
@@ -220,15 +220,15 @@
         npt.assert_almost_equal(m1, m, decimal=10, err_msg= msg + \
                             ' - 1st moment')
     else:                     # or np.isnan(m1), 
-        assert np.isinf(m1), \
-               msg + ' - 1st moment -infinite, m1=%s' % str(m1)
+        npt.assert_(np.isinf(m1), 
+               msg + ' - 1st moment -infinite, m1=%s' % str(m1))
         #np.isnan(m1) temporary special treatment for loggamma
     if not np.isinf(v):
         npt.assert_almost_equal(m2-m1*m1, v, decimal=10, err_msg= msg + \
                             ' - 2ndt moment')
     else:                     #or np.isnan(m2), 
-        assert np.isinf(m2), \
-               msg + ' - 2nd moment -infinite, m2=%s' % str(m2)
+        npt.assert_(np.isinf(m2),
+               msg + ' - 2nd moment -infinite, m2=%s' % str(m2))
         #np.isnan(m2) temporary special treatment for loggamma
 
 def check_sample_meanvar_(distfn, arg, m, v, sm, sv, sn, msg):
@@ -260,7 +260,7 @@
     prob = stats.betai(0.5*df,0.5,df/(df+t*t))
 
     #return t,prob
-    assert prob>0.01, 'mean fail, t,prob = %f, %f, m,sm=%f,%f' % (t,prob,popmean,sm)
+    npt.assert_(prob > 0.01, 'mean fail, t,prob = %f, %f, m,sm=%f,%f' % (t,prob,popmean,sm))
 
 def check_sample_var(sv,n, popvar):
     '''
@@ -269,10 +269,9 @@
     df = n-1
     chi2 = (n-1)*popvar/float(popvar)
     pval = stats.chisqprob(chi2,df)*2
-    assert pval>0.01, 'var fail, t,pval = %f, %f, v,sv=%f,%f' % (chi2,pval,popvar,sv)
-    
+    npt.assert_(pval > 0.01, 'var fail, t,pval = %f, %f, v,sv=%f,%f' % (chi2,pval,popvar,sv))
 
-    
+
 def check_sample_skew_kurt(distfn, arg, ss, sk, msg):
     skew,kurt = distfn.stats(moments='sk',*arg)
 ##    skew = distfn.stats(moment='s',*arg)[()]
@@ -354,10 +353,9 @@
     D,pval = stats.kstest(rvs, dist, args=args, N=1000)
     if (pval < alpha):
         D,pval = stats.kstest(dist,'',args=args, N=1000)
-        assert (pval > alpha), "D = " + str(D) + "; pval = " + str(pval) + \
-               "; alpha = " + str(alpha) + "\nargs = " + str(args)
+        npt.assert_(pval > alpha, "D = " + str(D) + "; pval = " + str(pval) +
+               "; alpha = " + str(alpha) + "\nargs = " + str(args))
 
 if __name__ == "__main__":
     #nose.run(argv=['', __file__])
     nose.runmodule(argv=[__file__,'-s'], exit=False)
-

Modified: trunk/scipy/stats/tests/test_continuous_extra.py
===================================================================
--- trunk/scipy/stats/tests/test_continuous_extra.py	2010-09-12 21:30:28 UTC (rev 6800)
+++ trunk/scipy/stats/tests/test_continuous_extra.py	2010-09-12 21:31:02 UTC (rev 6801)
@@ -8,7 +8,6 @@
 
 import numpy.testing as npt
 import numpy as np
-import nose
 
 from scipy import stats
 
@@ -56,13 +55,13 @@
     #print distfn.name,below,low,upp,above
     assert_equal_inf_nan(distfn.a,low, msg + 'ppf lower bound')
     assert_equal_inf_nan(distfn.b,upp, msg + 'ppf upper bound')
-    assert np.isnan(below), msg + 'ppf out of bounds - below'
-    assert np.isnan(above), msg + 'ppf out of bounds - above'
+    npt.assert_(np.isnan(below), msg + 'ppf out of bounds - below')
+    npt.assert_(np.isnan(above), msg + 'ppf out of bounds - above')
 
 def check_ppf_private(distfn,arg,msg):
     #fails by design for trunk norm self.nb not defined
     ppfs = distfn._ppf(np.array([0.1,0.5,0.9]), *arg)
-    assert not np.any(np.isnan(ppfs)), msg + 'ppf private is nan'
+    npt.assert_(not np.any(np.isnan(ppfs)), msg + 'ppf private is nan')
 
 
 def check_isf_limits(distfn,arg,msg):
@@ -71,8 +70,8 @@
     #print distfn.name,below,low,upp,above
     assert_equal_inf_nan(distfn.a,upp, msg + 'isf lower bound')
     assert_equal_inf_nan(distfn.b,low, msg + 'isf upper bound')
-    assert np.isnan(below), msg + 'isf out of bounds - below'
-    assert np.isnan(above), msg + 'isf out of bounds - above'
+    npt.assert_(np.isnan(below), msg + 'isf out of bounds - below')
+    npt.assert_(np.isnan(above), msg + 'isf out of bounds - above')
 
 
 def check_loc_scale(distfn,arg,msg):
@@ -85,19 +84,18 @@
 def check_entropy(distfn,arg,msg):
     ent = distfn.entropy(*arg)
     #print 'Entropy =', ent
-    assert not np.isnan(ent), msg + 'test Entropy is nan'\
+    npt.assert_(not np.isnan(ent), msg + 'test Entropy is nan')
 
 def assert_equal_inf_nan(v1,v2,msg):
-    assert not np.isnan(v1)
+    npt.assert_(not np.isnan(v1))
     if not np.isinf(v1):
         npt.assert_almost_equal(v1, v2, decimal=DECIMAL, err_msg = msg + \
                                    ' - finite')
     else:
-        assert np.isinf(v2) or np.isnan(v2), \
-               msg + ' - infinite, v2=%s' % str(v2)
+        npt.assert_(np.isinf(v2) or np.isnan(v2),
+               msg + ' - infinite, v2=%s' % str(v2))
 
 if __name__ == "__main__":
     import nose
     #nose.run(argv=['', __file__])
     nose.runmodule(argv=[__file__,'-s'], exit=False)
-

Modified: trunk/scipy/stats/tests/test_discrete_basic.py
===================================================================
--- trunk/scipy/stats/tests/test_discrete_basic.py	2010-09-12 21:30:28 UTC (rev 6800)
+++ trunk/scipy/stats/tests/test_discrete_basic.py	2010-09-12 21:31:02 UTC (rev 6801)
@@ -87,7 +87,7 @@
         npt.assert_almost_equal(sm, m, decimal=DECIMAL_meanvar, err_msg=msg + \
                                 ' - finite moment')
     else:
-        assert sm > 10000, 'infinite moment, sm = ' + str(sm)
+        npt.assert_(sm > 10000, msg='infinite moment, sm = ' + str(sm))
 
 def check_sample_var(sm,m,msg):
     npt.assert_almost_equal(sm, m, decimal=DECIMAL_meanvar, err_msg= msg + 'var')
@@ -97,7 +97,7 @@
     cdf05 = distfn.cdf(ppf05,*arg)
     npt.assert_almost_equal(distfn.ppf(cdf05-1e-6,*arg),ppf05,
                             err_msg=msg + 'ppf-cdf-median')
-    assert (distfn.ppf(cdf05+1e-4,*arg)>ppf05), msg + 'ppf-cdf-next'
+    npt.assert_((distfn.ppf(cdf05+1e-4,*arg)>ppf05), msg + 'ppf-cdf-next')
 
 def check_cdf_ppf2(distfn,arg,supp,msg):
     npt.assert_array_equal(distfn.ppf(distfn.cdf(supp,*arg),*arg),
@@ -112,17 +112,17 @@
     cdf05 = distfn.cdf(ppf05,*arg)
     npt.assert_almost_equal(distfn._ppf(cdf05-1e-6,*arg),ppf05,
                             err_msg=msg + '_ppf-cdf-median ')
-    assert (distfn._ppf(cdf05+1e-4,*arg)>ppf05), msg + '_ppf-cdf-next'
+    npt.assert_((distfn._ppf(cdf05+1e-4,*arg)>ppf05), msg + '_ppf-cdf-next')
 
 def check_ppf_ppf(distfn, arg):
-    assert distfn.ppf(0.5,*arg) < np.inf
+    npt.assert_(distfn.ppf(0.5,*arg) < np.inf)
     ppfs = distfn.ppf([0.5,0.9],*arg)
     ppf_s = [distfn._ppf(0.5,*arg), distfn._ppf(0.9,*arg)]
-    assert np.all(ppfs < np.inf)
-    assert ppf_s[0] == distfn.ppf(0.5,*arg)
-    assert ppf_s[1] == distfn.ppf(0.9,*arg)
-    assert ppf_s[0] == ppfs[0]
-    assert ppf_s[1] == ppfs[1]
+    npt.assert_(np.all(ppfs < np.inf))
+    npt.assert_(ppf_s[0] == distfn.ppf(0.5,*arg))
+    npt.assert_(ppf_s[1] == distfn.ppf(0.9,*arg))
+    npt.assert_(ppf_s[0] == ppfs[0])
+    npt.assert_(ppf_s[1] == ppfs[1])
 
 def check_pmf_cdf(distfn, arg, msg):
     startind = np.int(distfn._ppf(0.01,*arg)-1)
@@ -147,8 +147,8 @@
                             distfn.cdf(meanint, *arg), decimal=8)
     median_sf = distfn.isf(0.5, *arg)
 
-    assert distfn.sf(median_sf - 1, *arg) > 0.5
-    assert distfn.cdf(median_sf + 1, *arg) > 0.5
+    npt.assert_(distfn.sf(median_sf - 1, *arg) > 0.5)
+    npt.assert_(distfn.cdf(median_sf + 1, *arg) > 0.5)
     npt.assert_equal(distfn.isf(0.5, *arg), distfn.ppf(0.5, *arg))
 
 #next 3 functions copied from test_continous_extra
@@ -160,8 +160,8 @@
     #print distfn.name,below,low,upp,above
     assert_equal_inf_nan(distfn.a-1,low, msg + 'ppf lower bound')
     assert_equal_inf_nan(distfn.b,upp, msg + 'ppf upper bound')
-    assert np.isnan(below), msg + 'ppf out of bounds - below'
-    assert np.isnan(above), msg + 'ppf out of bounds - above'
+    npt.assert_(np.isnan(below), msg + 'ppf out of bounds - below')
+    npt.assert_(np.isnan(above), msg + 'ppf out of bounds - above')
 
 def check_isf_limits(distfn,arg,msg):
     below,low,upp,above = distfn.isf([-1,0,1,2], *arg)
@@ -169,17 +169,17 @@
     #print distfn.name,below,low,upp,above
     assert_equal_inf_nan(distfn.a-1,upp, msg + 'isf lower bound')
     assert_equal_inf_nan(distfn.b,low, msg + 'isf upper bound')
-    assert np.isnan(below), msg + 'isf out of bounds - below'
-    assert np.isnan(above), msg + 'isf out of bounds - above'
+    npt.assert_(np.isnan(below), msg + 'isf out of bounds - below')
+    npt.assert_(np.isnan(above), msg + 'isf out of bounds - above')
 
 def assert_equal_inf_nan(v1,v2,msg):
-    assert not np.isnan(v1)
+    npt.assert_(not np.isnan(v1))
     if not np.isinf(v1):
         npt.assert_almost_equal(v1, v2, decimal=10, err_msg = msg + \
                                    ' - finite')
     else:
-        assert np.isinf(v2) or np.isnan(v2), \
-               msg + ' - infinite, v2=%s' % str(v2)
+        npt.assert_(np.isinf(v2) or np.isnan(v2),
+               msg + ' - infinite, v2=%s' % str(v2))
 
 def check_sample_skew_kurt(distfn, arg, sk, ss, msg):
     k,s = distfn.stats(moment='ks',*arg)
@@ -190,10 +190,9 @@
 def check_entropy(distfn,arg,msg):
     ent = distfn.entropy(*arg)
     #print 'Entropy =', ent
-    assert not np.isnan(ent), msg + 'test Entropy is nan'\
+    npt.assert_(not np.isnan(ent), msg + 'test Entropy is nan')
 
 
-
 def check_discrete_chisquare(distfn, arg, rvs, alpha, msg):
     '''perform chisquare test for random sample of a discrete distribution
 
@@ -253,8 +252,8 @@
     cdfs = distfn.cdf(distsupp,*arg)
     (chis,pval) = stats.chisquare(np.array(freq),n*distmass)
 
-    assert (pval > alpha), 'chisquare - test for %s' \
-           'at arg = %s with pval = %s' % (msg,str(arg),str(pval))
+    npt.assert_(pval > alpha, 'chisquare - test for %s' 
+           ' at arg = %s with pval = %s' % (msg,str(arg),str(pval)))
 
 
 if __name__ == "__main__":

Modified: trunk/scipy/stats/tests/test_distributions.py
===================================================================
--- trunk/scipy/stats/tests/test_distributions.py	2010-09-12 21:30:28 UTC (rev 6800)
+++ trunk/scipy/stats/tests/test_distributions.py	2010-09-12 21:31:02 UTC (rev 6801)
@@ -4,7 +4,7 @@
 
 from numpy.testing import TestCase, run_module_suite, assert_equal, \
     assert_array_equal, assert_almost_equal, assert_array_almost_equal, \
-    rand, dec
+    assert_, rand, dec
 
 
 import numpy
@@ -13,16 +13,16 @@
 import scipy.stats as stats
 from scipy.stats.distributions import argsreduce
 
-def kolmogorov_check(diststr,args=(),N=20,significance=0.01):
-    qtest = stats.ksoneisf(significance,N)
+def kolmogorov_check(diststr, args=(), N=20, significance=0.01):
+    qtest = stats.ksoneisf(significance, N)
     cdf = eval('stats.'+diststr+'.cdf')
     dist = eval('stats.'+diststr)
     # Get random numbers
     kwds = {'size':N}
-    vals = numpy.sort(dist.rvs(*args,**kwds))
-    cdfvals = cdf(vals,*args)
-    q = max(abs(cdfvals - np.arange(1.0,N+1)/N))
-    assert (q < qtest), "Failed q=%f, bound=%f, alpha=%f" % (q, qtest, significance)
+    vals = numpy.sort(dist.rvs(*args, **kwds))
+    cdfvals = cdf(vals, *args)
+    q = max(abs(cdfvals - np.arange(1.0, N+1)/N))
+    assert_(q < qtest, msg="Failed q=%f, bound=%f, alpha=%f" % (q, qtest, significance))
     return
 
 
@@ -47,8 +47,8 @@
         D,pval = stats.kstest(dist,'',args=args, N=1000)
         #if (pval < alpha):
         #    D,pval = stats.kstest(dist,'',args=args, N=1000)
-        assert (pval > alpha), "D = " + str(D) + "; pval = " + str(pval) + \
-               "; alpha = " + str(alpha) + "\nargs = " + str(args)
+        assert_(pval > alpha, msg="D = " + str(D) + "; pval = " + str(pval) + \
+               "; alpha = " + str(alpha) + "\nargs = " + str(args))
 
 # nose test generator
 def test_all_distributions():
@@ -97,16 +97,16 @@
 class TestRandInt(TestCase):
     def test_rvs(self):
         vals = stats.randint.rvs(5,30,size=100)
-        assert(numpy.all(vals < 30) & numpy.all(vals >= 5))
-        assert(len(vals) == 100)
+        assert_(numpy.all(vals < 30) & numpy.all(vals >= 5))
+        assert_(len(vals) == 100)
         vals = stats.randint.rvs(5,30,size=(2,50))
-        assert(numpy.shape(vals) == (2,50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.shape(vals) == (2,50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.randint.rvs(15,46)
-        assert((val >= 15) & (val < 46))
-        assert isinstance(val, numpy.ScalarType),`type(val)`
+        assert_((val >= 15) & (val < 46))
+        assert_(isinstance(val, numpy.ScalarType), msg=`type(val)`)
         val = stats.randint(15,46).rvs(3)
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
     def test_pdf(self):
         k = numpy.r_[0:36]
@@ -124,51 +124,51 @@
 class TestBinom(TestCase):
     def test_rvs(self):
         vals = stats.binom.rvs(10, 0.75, size=(2, 50))
-        assert(numpy.all(vals >= 0) & numpy.all(vals <= 10))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.all(vals >= 0) & numpy.all(vals <= 10))
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.binom.rvs(10, 0.75)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.binom(10, 0.75).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
 
 class TestBernoulli(TestCase):
     def test_rvs(self):
         vals = stats.bernoulli.rvs(0.75, size=(2, 50))
-        assert(numpy.all(vals >= 0) & numpy.all(vals <= 1))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.all(vals >= 0) & numpy.all(vals <= 1))
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.bernoulli.rvs(0.75)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.bernoulli(0.75).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
 class TestNBinom(TestCase):
     def test_rvs(self):
         vals = stats.nbinom.rvs(10, 0.75, size=(2, 50))
-        assert(numpy.all(vals >= 0))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.all(vals >= 0))
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.nbinom.rvs(10, 0.75)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.nbinom(10, 0.75).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
 class TestGeom(TestCase):
     def test_rvs(self):
         vals = stats.geom.rvs(0.75, size=(2, 50))
-        assert(numpy.all(vals >= 0))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.all(vals >= 0))
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.geom.rvs(0.75)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.geom(0.75).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
     def test_pmf(self):
         vals = stats.geom.pmf([1,2,3],0.5)
@@ -185,62 +185,62 @@
 class TestHypergeom(TestCase):
     def test_rvs(self):
         vals = stats.hypergeom.rvs(20, 10, 3, size=(2, 50))
-        assert(numpy.all(vals >= 0) &
+        assert_(numpy.all(vals >= 0) &
                numpy.all(vals <= 3))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.hypergeom.rvs(20, 3, 10)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.hypergeom(20, 3, 10).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
 class TestLogser(TestCase):
     def test_rvs(self):
         vals = stats.logser.rvs(0.75, size=(2, 50))
-        assert(numpy.all(vals >= 1))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.all(vals >= 1))
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.logser.rvs(0.75)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.logser(0.75).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
 class TestPoisson(TestCase):
     def test_rvs(self):
         vals = stats.poisson.rvs(0.5, size=(2, 50))
-        assert(numpy.all(vals >= 0))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.all(vals >= 0))
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.poisson.rvs(0.5)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.poisson(0.5).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
 class TestZipf(TestCase):
     def test_rvs(self):
         vals = stats.zipf.rvs(1.5, size=(2, 50))
-        assert(numpy.all(vals >= 1))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.all(vals >= 1))
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.zipf.rvs(1.5)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.zipf(1.5).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
 class TestDLaplace(TestCase):
     def test_rvs(self):
         vals = stats.dlaplace.rvs(1.5 , size=(2, 50))
-        assert(numpy.shape(vals) == (2, 50))
-        assert(vals.dtype.char in typecodes['AllInteger'])
+        assert_(numpy.shape(vals) == (2, 50))
+        assert_(vals.dtype.char in typecodes['AllInteger'])
         val = stats.dlaplace.rvs(1.5)
-        assert(isinstance(val, int))
+        assert_(isinstance(val, int))
         val = stats.dlaplace(1.5).rvs(3)
-        assert(isinstance(val, numpy.ndarray))
-        assert(val.dtype.char in typecodes['AllInteger'])
+        assert_(isinstance(val, numpy.ndarray))
+        assert_(val.dtype.char in typecodes['AllInteger'])
 
 class TestRvDiscrete(TestCase):
     def test_rvs(self):
@@ -249,13 +249,13 @@
         samples = 1000
         r = stats.rv_discrete(name='sample',values=(states,probability))
         x = r.rvs(size=samples)
-        assert(isinstance(x, numpy.ndarray))
+        assert_(isinstance(x, numpy.ndarray))
 
         for s,p in zip(states,probability):
-            assert abs(sum(x == s)/float(samples) - p) < 0.05
+            assert_(abs(sum(x == s)/float(samples) - p) < 0.05)
 
         x = r.rvs()
-        assert(isinstance(x, int))
+        assert_(isinstance(x, int))
 
 class TestExpon(TestCase):
     def test_zero(self):
@@ -276,7 +276,7 @@
     def test_cdf_bounds(self):
         # CDF should always be positive
         cdf = stats.genexpon.cdf(numpy.arange(0, 10, 0.01), 0.5, 0.5, 2.0)
-        assert(numpy.all((0 <= cdf) & (cdf <= 1)))
+        assert_(numpy.all((0 <= cdf) & (cdf <= 1)))
         
 class TestExponpow(TestCase):
     def test_tail(self):
@@ -367,8 +367,8 @@
         qk = [0.1,0.25,0.65]
         eself = stats.entropy(pk,pk)
         edouble = stats.entropy(pk,qk)
-        assert(0.0 == eself)
-        assert(edouble >= 0.0)
+        assert_(0.0 == eself)
+        assert_(edouble >= 0.0)
 
 def TestArgsreduce():
     a = array([1,3,2,1,2,3,3])
@@ -402,11 +402,11 @@
             # FIXME: should check the actual results to see if we are 'close'
             #   to what was created --- but what is 'close' enough
             if dist in ['erlang', 'frechet']:
-                assert(len(vals)==len(args))
-                assert(len(vals2)==len(args))
+                assert_(len(vals)==len(args))
+                assert_(len(vals2)==len(args))
             else:
-                assert(len(vals) == 2+len(args))
-                assert(len(vals2)==2+len(args))
+                assert_(len(vals) == 2+len(args))
+                assert_(len(vals2)==2+len(args))
                 
     @dec.slow
     def test_fix_fit(self):
@@ -419,22 +419,22 @@
             res = distfunc.rvs(*args, **{'size':200})
             vals = distfunc.fit(res,floc=0)
             vals2 = distfunc.fit(res,fscale=1)
-            assert(len(vals) == 2+len(args))
-            assert(vals[-2] == 0)
-            assert(vals2[-1] == 1)
-            assert(len(vals2) == 2+len(args))
+            assert_(len(vals) == 2+len(args))
+            assert_(vals[-2] == 0)
+            assert_(vals2[-1] == 1)
+            assert_(len(vals2) == 2+len(args))
             if len(args) > 0:
                 vals3 = distfunc.fit(res, f0=args[0])
-                assert(len(vals3) == 2+len(args)) 
-                assert(vals3[0] == args[0])
+                assert_(len(vals3) == 2+len(args)) 
+                assert_(vals3[0] == args[0])
             if len(args) > 1:
                 vals4 = distfunc.fit(res, f1=args[1])
-                assert(len(vals4) == 2+len(args)) 
-                assert(vals4[1] == args[1])
+                assert_(len(vals4) == 2+len(args)) 
+                assert_(vals4[1] == args[1])
             if len(args) > 2:
                 vals5 = distfunc.fit(res, f2=args[2])
-                assert(len(vals5) == 2+len(args)) 
-                assert(vals5[2] == args[2])
+                assert_(len(vals5) == 2+len(args)) 
+                assert_(vals5[2] == args[2])
 
 if __name__ == "__main__":
     run_module_suite()

Modified: trunk/scipy/stats/tests/test_mstats_basic.py
===================================================================
--- trunk/scipy/stats/tests/test_mstats_basic.py	2010-09-12 21:30:28 UTC (rev 6800)
+++ trunk/scipy/stats/tests/test_mstats_basic.py	2010-09-12 21:31:02 UTC (rev 6801)
@@ -11,10 +11,9 @@
 import scipy.stats.mstats as mstats
 from numpy.testing import TestCase, run_module_suite
 from numpy.ma.testutils import assert_equal, assert_almost_equal, \
-    assert_array_almost_equal
+    assert_array_almost_equal, assert_
 
 
-
 class TestMquantiles(TestCase):
     """Regression tests for mstats module.""" 
     def test_mquantiles_limit_keyword(self): 
@@ -47,7 +46,7 @@
 
         desired1 = mstats.gmean(a,axis=-1)
         assert_almost_equal(actual, desired1, decimal=14)
-        assert not isinstance(desired1, ma.MaskedArray)
+        assert_(not isinstance(desired1, ma.MaskedArray))
         #
         a = ma.array((1,2,3,4),mask=(0,0,0,1))
         actual= mstats.gmean(a)
@@ -134,8 +133,8 @@
         #
         x = ma.array(x, mask=True)
         pr = mstats.pearsonr(x,x)
-        assert(pr[0] is masked)
-        assert(pr[1] is masked)
+        assert_(pr[0] is masked)
+        assert_(pr[1] is masked)
     #
     def test_spearmanr(self):
         "Tests some computations of Spearman's rho"

Modified: trunk/scipy/stats/tests/test_mstats_extras.py
===================================================================
--- trunk/scipy/stats/tests/test_mstats_extras.py	2010-09-12 21:30:28 UTC (rev 6800)
+++ trunk/scipy/stats/tests/test_mstats_extras.py	2010-09-12 21:31:02 UTC (rev 6801)
@@ -14,7 +14,7 @@
 #import scipy.stats.mmorestats as mms
 
 from numpy.testing import TestCase, run_module_suite, assert_equal, \
-    assert_almost_equal
+    assert_almost_equal, assert_
 
 
 class TestMisc(TestCase):
@@ -49,7 +49,7 @@
                             test.repeat(2).reshape(-1,2))
         test = [0,0]
         _result = ms.idealfourths(test)
-        assert(np.isnan(_result).all())
+        assert_(np.isnan(_result).all())
 
 #..............................................................................
 class TestQuantiles(TestCase):

Modified: trunk/scipy/stats/tests/test_stats.py
===================================================================
--- trunk/scipy/stats/tests/test_stats.py	2010-09-12 21:30:28 UTC (rev 6800)
+++ trunk/scipy/stats/tests/test_stats.py	2010-09-12 21:31:02 UTC (rev 6801)
@@ -218,7 +218,7 @@
     def test_nanmean_all(self):
         """Check nanmean when all values are nan."""
         m = stats.nanmean(self.Xall)
-        assert np.isnan(m)
+        assert_(np.isnan(m))
 
     def test_nanstd_none(self):
         """Check nanstd when no values are nan."""
@@ -233,7 +233,7 @@
     def test_nanstd_all(self):
         """Check nanstd when all values are nan."""
         s = stats.nanstd(self.Xall)
-        assert np.isnan(s)
+        assert_(np.isnan(s))
 
     def test_nanstd_negative_axis(self):
         x = np.array([1, 2, 3])
@@ -252,7 +252,7 @@
     def test_nanmedian_all(self):
         """Check nanmedian when all values are nan."""
         m = stats.nanmedian(self.Xall)
-        assert np.isnan(m)
+        assert_(np.isnan(m))
 
 class TestCorr(TestCase):
     """ W.II.D. Compute a correlation matrix on all the variables.



More information about the Scipy-svn mailing list