Skip to content

Commit ca96ee8

Browse files
committed
added more continuous tests
1 parent 8ddd6ff commit ca96ee8

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

tests/test_distributions.py

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,54 @@
2222
Natbig = array([0, 3,4,5, 1000], 'int64')
2323

2424

25+
def test_unif():
26+
checkd(Uniform, Runif, {'lower' : -Rplusunif, 'upper' : Rplusunif})
2527

26-
def test_distributions():
28+
def test_flat():
29+
checkd(Flat, Runif, {}, False)
2730

28-
yield checkd, Uniform, Runif, {'lower' : -Rplusunif, 'upper' : Rplusunif}
29-
yield checkd, Normal, R, {'mu' : R, 'tau' : Rplus}
30-
yield checkd, Beta, Unit, {'alpha' : Rplus*5, 'beta' : Rplus*5}
31-
yield checkd, Exponential, Rplus, {'lam' : Rplus}
32-
yield checkd, T, R, {'nu' : Rplus, 'mu' : R, 'lam' : Rplus}
33-
yield checkd, Cauchy, R, {'alpha' : R, 'beta' : Rplusbig}
34-
yield checkd, Gamma, Rplus, {'alpha' : Rplusbig, 'beta' : Rplusbig}
31+
def test_normal():
32+
checkd(Normal, R, {'mu' : R, 'tau' : Rplus})
3533

34+
def test_beta():
35+
checkd(Beta, Unit, {'alpha' : Rplus*5, 'beta' : Rplus*5})
3636

37-
yield checkd, Binomial, Nat, {'n' : Natbig, 'p' : Unit}
38-
yield checkd, BetaBin, Nat, {'alpha' : Rplus, 'beta' : Rplus, 'n' : Natbig}
39-
yield checkd, Bernoulli, Bool, {'p' : Unit}
40-
yield checkd, Poisson, Nat, {'mu' : Rplus}
41-
yield checkd, ConstantDist, I, {'c' : I}
37+
def test_exponential():
38+
checkd(Exponential, Rplus, {'lam' : Rplus})
4239

40+
def test_laplace():
41+
checkd(Laplace, R, {'mu' : R, 'b' : Rplus})
4342

43+
def test_t():
44+
checkd(T, R, {'nu' : Rplus, 'mu' : R, 'lam' : Rplus})
4445

46+
def test_cauchy():
47+
checkd(Cauchy, R, {'alpha' : R, 'beta' : Rplusbig})
4548

46-
def checkd(distfam, valuedomain, vardomains):
49+
def test_gamma():
50+
checkd(Gamma, Rplus, {'alpha' : Rplusbig, 'beta' : Rplusbig})
51+
52+
def test_tpos():
53+
checkd(Tpos, Rplus, {'nu' : Rplus, 'mu' : R, 'lam' : Rplus}, False)
54+
55+
56+
def test_binomial():
57+
checkd(Binomial, Nat, {'n' : Natbig, 'p' : Unit})
58+
59+
def test_betabin():
60+
checkd(BetaBin, Nat, {'alpha' : Rplus, 'beta' : Rplus, 'n' : Natbig})
61+
62+
def test_bernoulli():
63+
checkd(Bernoulli, Bool, {'p' : Unit})
64+
65+
def test_poisson():
66+
checkd(Poisson, Nat, {'mu' : Rplus})
67+
68+
def test_constantdist():
69+
checkd(ConstantDist, I, {'c' : I})
70+
71+
72+
def checkd(distfam, valuedomain, vardomains, check_int = True, check_der = True):
4773

4874
m = Model()
4975

@@ -55,8 +81,10 @@ def checkd(distfam, valuedomain, vardomains):
5581

5682
domains = [np.array(vardomains[str(v)]) for v in m.vars]
5783

58-
check_int_to_1(m, value, domains)
59-
check_dlogp(m, value, domains)
84+
if check_int:
85+
check_int_to_1(m, value, domains)
86+
if check_der:
87+
check_dlogp(m, value, domains)
6088

6189

6290
def check_int_to_1(model, value, domains):

0 commit comments

Comments
 (0)