[Scipy-svn] r5196 - trunk/scipy/stats/tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Wed Nov 26 14:24:24 EST 2008
Author: josef
Date: 2008-11-26 13:24:18 -0600 (Wed, 26 Nov 2008)
New Revision: 5196
Modified:
trunk/scipy/stats/tests/test_continuous_basic.py
Log:
merge tests to speed up, reuse rvs across tests
Modified: trunk/scipy/stats/tests/test_continuous_basic.py
===================================================================
--- trunk/scipy/stats/tests/test_continuous_basic.py 2008-11-26 18:24:03 UTC (rev 5195)
+++ trunk/scipy/stats/tests/test_continuous_basic.py 2008-11-26 19:24:18 UTC (rev 5196)
@@ -122,10 +122,23 @@
## ['genextreme', (-0.01,)]
## ]
+distmissing = ['wald', 'gausshyper', 'genexpon', 'rv_continuous',
+ 'loglaplace', 'rdist', 'semicircular', 'invweibull', 'ksone',
+ 'cosine', 'kstwobign', 'truncnorm', 'mielke', 'recipinvgauss', 'levy',
+ 'johnsonsu', 'levy_l', 'powernorm', 'wrapcauchy',
+ 'johnsonsb', 'truncexpon', 'rice', 'invnorm', 'invgamma',
+ 'powerlognorm']
+
+distmiss = [[dist,args] for dist,args in distcont if dist in distmissing]
+distslow = ['rdist', 'gausshyper', 'recipinvgauss', 'ksone', 'genexpon',
+ 'vonmises', 'rice', 'mielke', 'semicircular', 'cosine']
+
+
@npt.dec.slow
def test_cont_basic():
for distname, arg in distcont[:]:
distfn = getattr(stats, distname)
+ np.random.seed(765456)
rvs = distfn.rvs(size=1000,*arg)
sm = rvs.mean()
sv = rvs.var()
@@ -140,6 +153,9 @@
yield check_sf_isf, distfn, arg, distname
yield check_pdf, distfn, arg, distname
#yield check_oth, distfn, arg # is still missing
+ if distname in distmissing:
+ alpha = 0.01
+ yield check_distribution_rvs, dist, args, alpha, rvs
@@ -207,17 +223,10 @@
npt.assert_almost_equal(pdfv, cdfdiff,
decimal=DECIMAL, err_msg= msg + ' - cdf-pdf relationship')
-distmissing = ['wald', 'gausshyper', 'genexpon', 'rv_continuous',
- 'loglaplace', 'rdist', 'semicircular', 'invweibull', 'ksone',
- 'cosine', 'kstwobign', 'truncnorm', 'mielke', 'recipinvgauss', 'levy',
- 'johnsonsu', 'levy_l', 'powernorm', 'wrapcauchy',
- 'johnsonsb', 'truncexpon', 'rice', 'invnorm', 'invgamma',
- 'powerlognorm']
-distmiss = [[dist,args] for dist,args in distcont if dist in distmissing]
@npt.dec.slow
-def test_missing_distributions():
+def _est_missing_distributions_old():
# K-S test of distributions missing in test_distributions.py
for dist, args in distmiss:
distfunc = getattr(stats, dist)
@@ -233,6 +242,15 @@
assert (pval > alpha), "D = " + str(D) + "; pval = " + str(pval) + \
"; alpha = " + str(alpha) + "\nargs = " + str(args)
+def check_distribution_rvs(dist, args, alpha, rvs):
+ #test from scipy.stats.tests
+ #this version reuses existing random variables
+ 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)
+
if __name__ == "__main__":
#nose.run(argv=['', __file__])
nose.runmodule(argv=[__file__,'-s'], exit=False)
More information about the Scipy-svn
mailing list