Skip to content

Commit 99b119a

Browse files
committed
Small renaming and reordering
1 parent 48c061f commit 99b119a

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

pymc3/tests/test_distributions.py

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -889,15 +889,14 @@ def test_half_flat(self):
889889
assert 0.0 == HalfFlat.dist().logcdf(np.inf).tag.test_value
890890
assert -np.inf == HalfFlat.dist().logcdf(-np.inf).tag.test_value
891891

892-
def test_normal_logp(self):
892+
def test_normal(self):
893893
self.check_logp(
894894
Normal,
895895
R,
896896
{"mu": R, "sigma": Rplus},
897897
lambda value, mu, sigma: sp.norm.logpdf(value, mu, sigma),
898898
decimal=select_by_precision(float64=6, float32=1),
899899
)
900-
901900
self.check_logcdf(
902901
Normal,
903902
R,
@@ -943,27 +942,6 @@ def test_chi_squared(self):
943942
lambda value, nu: sp.chi2.logpdf(value, df=nu),
944943
)
945944

946-
def test_wald_scipy_logp(self):
947-
self.check_logp(
948-
Wald,
949-
Rplus,
950-
{"mu": Rplus, "alpha": Rplus},
951-
lambda value, mu, alpha: sp.invgauss.logpdf(value, mu=mu, loc=alpha),
952-
decimal=select_by_precision(float64=6, float32=1),
953-
)
954-
955-
@pytest.mark.xfail(
956-
condition=(aesara.config.floatX == "float32"),
957-
reason="Poor CDF in SciPy. See scipy/scipy#869 for details.",
958-
)
959-
def test_wald_scipy_logcdf(self):
960-
self.check_logcdf(
961-
Wald,
962-
Rplus,
963-
{"mu": Rplus, "alpha": Rplus},
964-
lambda value, mu, alpha: sp.invgauss.logcdf(value, mu=mu, loc=alpha),
965-
)
966-
967945
@pytest.mark.parametrize(
968946
"value,mu,lam,phi,alpha,logp",
969947
[
@@ -983,7 +961,7 @@ def test_wald_scipy_logcdf(self):
983961
(50.0, 15.0, None, 0.666666, 10.0, -5.6481874),
984962
],
985963
)
986-
def test_wald(self, value, mu, lam, phi, alpha, logp):
964+
def test_wald_logp_custom_points(self, value, mu, lam, phi, alpha, logp):
987965
# Log probabilities calculated using the dIG function from the R package gamlss.
988966
# See e.g., doi: 10.1111/j.1467-9876.2005.00510.x, or
989967
# http://www.gamlss.org/.
@@ -993,6 +971,27 @@ def test_wald(self, value, mu, lam, phi, alpha, logp):
993971
decimals = select_by_precision(float64=6, float32=1)
994972
assert_almost_equal(model.fastlogp(pt), logp, decimal=decimals, err_msg=str(pt))
995973

974+
def test_wald_logp(self):
975+
self.check_logp(
976+
Wald,
977+
Rplus,
978+
{"mu": Rplus, "alpha": Rplus},
979+
lambda value, mu, alpha: sp.invgauss.logpdf(value, mu=mu, loc=alpha),
980+
decimal=select_by_precision(float64=6, float32=1),
981+
)
982+
983+
@pytest.mark.xfail(
984+
condition=(aesara.config.floatX == "float32"),
985+
reason="Poor CDF in SciPy. See scipy/scipy#869 for details.",
986+
)
987+
def test_wald_logcdf(self):
988+
self.check_logcdf(
989+
Wald,
990+
Rplus,
991+
{"mu": Rplus, "alpha": Rplus},
992+
lambda value, mu, alpha: sp.invgauss.logcdf(value, mu=mu, loc=alpha),
993+
)
994+
996995
def test_beta(self):
997996
self.check_logp(
998997
Beta,
@@ -1381,23 +1380,34 @@ def test_binomial(self):
13811380

13821381
# Too lazy to propagate decimal parameter through the whole chain of deps
13831382
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
1383+
def test_beta_binomial_distribution(self):
1384+
self.checkd(
1385+
BetaBinomial,
1386+
Nat,
1387+
{"alpha": Rplus, "beta": Rplus, "n": NatSmall},
1388+
)
1389+
13841390
@pytest.mark.skipif(
13851391
condition=(SCIPY_VERSION < parse("1.4.0")), reason="betabinom is new in Scipy 1.4.0"
13861392
)
1387-
def test_beta_binomial_logcdf(self):
1388-
self.check_logcdf(
1393+
def test_beta_binomial_logp(self):
1394+
self.check_logp(
13891395
BetaBinomial,
13901396
Nat,
13911397
{"alpha": Rplus, "beta": Rplus, "n": NatSmall},
1392-
lambda value, alpha, beta, n: sp.betabinom.logcdf(value, a=alpha, b=beta, n=n),
1398+
lambda value, alpha, beta, n: sp.betabinom.logpmf(value, a=alpha, b=beta, n=n),
13931399
)
13941400

13951401
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
1396-
def test_beta_binomial_distribution(self):
1397-
self.checkd(
1402+
@pytest.mark.skipif(
1403+
condition=(SCIPY_VERSION < parse("1.4.0")), reason="betabinom is new in Scipy 1.4.0"
1404+
)
1405+
def test_beta_binomial_logcdf(self):
1406+
self.check_logcdf(
13981407
BetaBinomial,
13991408
Nat,
14001409
{"alpha": Rplus, "beta": Rplus, "n": NatSmall},
1410+
lambda value, alpha, beta, n: sp.betabinom.logcdf(value, a=alpha, b=beta, n=n),
14011411
)
14021412

14031413
def test_beta_binomial_selfconsistency(self):
@@ -1407,17 +1417,6 @@ def test_beta_binomial_selfconsistency(self):
14071417
{"alpha": Rplus, "beta": Rplus, "n": NatSmall},
14081418
)
14091419

1410-
@pytest.mark.skipif(
1411-
condition=(SCIPY_VERSION < parse("1.4.0")), reason="betabinom is new in Scipy 1.4.0"
1412-
)
1413-
def test_beta_binomial_logp(self):
1414-
self.check_logp(
1415-
BetaBinomial,
1416-
Nat,
1417-
{"alpha": Rplus, "beta": Rplus, "n": NatSmall},
1418-
lambda value, alpha, beta, n: sp.betabinom.logpmf(value, a=alpha, b=beta, n=n),
1419-
)
1420-
14211420
def test_bernoulli(self):
14221421
self.check_logp(
14231422
Bernoulli,

0 commit comments

Comments
 (0)