[Scipy-svn] r5115 - trunk/scipy/stats/tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Fri Nov 14 23:16:04 EST 2008
Author: josef
Date: 2008-11-14 22:16:00 -0600 (Fri, 14 Nov 2008)
New Revision: 5115
Modified:
trunk/scipy/stats/tests/test_continuous_extra.py
Log:
corrections to tests, add loc and scale test for continuous rv stats
Modified: trunk/scipy/stats/tests/test_continuous_extra.py
===================================================================
--- trunk/scipy/stats/tests/test_continuous_extra.py 2008-11-15 04:03:44 UTC (rev 5114)
+++ trunk/scipy/stats/tests/test_continuous_extra.py 2008-11-15 04:16:00 UTC (rev 5115)
@@ -16,29 +16,52 @@
## sv = rvs.var()
## skurt = stats.kurtosis(rvs)
## sskew = stats.skew(rvs)
+
yield check_ppf_limits, distfn, arg, distname + \
' ppf limit test'
+ yield check_isf_limits, distfn, arg, distname + \
+ ' isf limit test'
+ yield check_loc_scale, distfn, arg, distname + \
+ ' loc, scale test'
+ #entropy test checks only for isnan, currently 6 isnan
+ #
+## yield check_entropy, distfn, arg, distname + \
+## ' loc, scale test'
+
def check_ppf_limits(distfn,arg,msg):
below,low,upp,above = distfn.ppf([-1,0,1,2], *arg)
#print distfn.name, distfn.a, low, distfn.b, upp
- print distfn.name,below,low,upp,above
+ #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'
-def check_ppf_limits(distfn,arg,msg):
+def check_isf_limits(distfn,arg,msg):
below,low,upp,above = distfn.isf([-1,0,1,2], *arg)
#print distfn.name, distfn.a, low, distfn.b, upp
- print distfn.name,below,low,upp,above
- assert_equal_inf_nan(distfn.a,upp, msg + 'ppf lower bound')
- assert_equal_inf_nan(distfn.b,low, msg + 'ppf upper bound')
- assert np.isnan(below), msg + 'ppf out of bounds - below'
- assert np.isnan(above), msg + 'ppf out of bounds - above'
+ #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'
+def check_loc_scale(distfn,arg,msg):
+ m,v = distfn.stats(*arg)
+ loc, scale = 10.0, 10.0
+ mt,vt = distfn.stats(loc=loc, scale=scale, *arg)
+ assert_equal_inf_nan(m*scale+loc,mt,msg + 'mean')
+ assert_equal_inf_nan(v*scale*scale,vt,msg + 'var')
+
+def check_entropy(distfn,arg,msg):
+ ent = distfn.entropy(*arg)
+ #print 'Entropy =', ent
+ assert not np.isnan(ent), msg + 'test Entropy is nan'\
+
def assert_equal_inf_nan(v1,v2,msg):
+ assert not np.isnan(v1)
if not np.isinf(v1):
npt.assert_almost_equal(v1, v2, decimal=DECIMAL, err_msg= msg + \
' - finite')
@@ -49,7 +72,7 @@
if __name__ == "__main__":
import nose
#nose.run(argv=['', __file__])
- print distcont[:5]
- test_cont_extra()
+ #print distcont[:5]
+ #test_cont_extra()
nose.runmodule(argv=[__file__,'-s'], exit=False)
More information about the Scipy-svn
mailing list