Skip to content

Commit 1414e97

Browse files
Apply recent xfail updates from master branch
1 parent 05c40b7 commit 1414e97

File tree

1 file changed

+82
-24
lines changed

1 file changed

+82
-24
lines changed

pymc3/tests/test_distributions.py

Lines changed: 82 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,18 +1021,21 @@ def test_chi_squared(self):
10211021
)
10221022

10231023
@pytest.mark.xfail(reason="Distribution not refactored yet")
1024-
@pytest.mark.xfail(
1025-
condition=(aesara.config.floatX == "float32"),
1026-
reason="Poor CDF in SciPy. See scipy/scipy#869 for details.",
1027-
)
1028-
def test_wald_scipy(self):
1024+
def test_wald_logp(self):
10291025
self.check_logp(
10301026
Wald,
10311027
Rplus,
10321028
{"mu": Rplus, "alpha": Rplus},
10331029
lambda value, mu, alpha: sp.invgauss.logpdf(value, mu=mu, loc=alpha),
10341030
decimal=select_by_precision(float64=6, float32=1),
10351031
)
1032+
1033+
@pytest.mark.xfail(reason="Distribution not refactored yet")
1034+
@pytest.mark.xfail(
1035+
condition=(aesara.config.floatX == "float32"),
1036+
reason="Poor CDF in SciPy. See scipy/scipy#869 for details.",
1037+
)
1038+
def test_wald_logcdf(self):
10361039
self.check_logcdf(
10371040
Wald,
10381041
Rplus,
@@ -1347,7 +1350,7 @@ def test_gamma_logcdf(self):
13471350
skip_paramdomain_outside_edge_test=True,
13481351
)
13491352

1350-
def test_inverse_gamma(self):
1353+
def test_inverse_gamma_logp(self):
13511354
self.check_logp(
13521355
InverseGamma,
13531356
Rplus,
@@ -1356,6 +1359,14 @@ def test_inverse_gamma(self):
13561359
)
13571360
# pymc-devs/aesara#224: skip_paramdomain_outside_edge_test has to be set
13581361
# True to avoid triggering a C-level assertion in the Aesara GammaQ function
1362+
1363+
@pytest.mark.xfail(
1364+
condition=(aesara.config.floatX == "float32"),
1365+
reason="Fails on float32 due to numerical issues",
1366+
)
1367+
def test_inverse_gamma_logcdf(self):
1368+
# pymc-devs/aesara#224: skip_paramdomain_outside_edge_test has to be set
1369+
# True to avoid triggering a C-level assertion in the Aesara GammaQ function
13591370
# in gamma.c file. Can be set back to False (default) once that issue is solved
13601371
self.check_logcdf(
13611372
InverseGamma,
@@ -1397,18 +1408,21 @@ def test_pareto(self):
13971408
lambda value, alpha, m: sp.pareto.logcdf(value, alpha, scale=m),
13981409
)
13991410

1400-
@pytest.mark.xfail(
1401-
condition=(aesara.config.floatX == "float32"),
1402-
reason="Fails on float32 due to inf issues",
1403-
)
14041411
@pytest.mark.xfail(reason="Distribution not refactored yet")
1405-
def test_weibull(self):
1412+
def test_weibull_logp(self):
14061413
self.check_logp(
14071414
Weibull,
14081415
Rplus,
14091416
{"alpha": Rplusbig, "beta": Rplusbig},
14101417
lambda value, alpha, beta: sp.exponweib.logpdf(value, 1, alpha, scale=beta),
14111418
)
1419+
1420+
@pytest.mark.xfail(reason="Distribution not refactored yet")
1421+
@pytest.mark.xfail(
1422+
condition=(aesara.config.floatX == "float32"),
1423+
reason="Fails on float32 due to inf issues",
1424+
)
1425+
def test_weibull_logcdf(self):
14121426
self.check_logcdf(
14131427
Weibull,
14141428
Rplus,
@@ -1458,23 +1472,33 @@ def test_binomial(self):
14581472
)
14591473

14601474
# Too lazy to propagate decimal parameter through the whole chain of deps
1461-
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
1462-
@pytest.mark.xfail(
1463-
condition=(SCIPY_VERSION < parse("1.4.0")), reason="betabinom is new in Scipy 1.4.0"
1464-
)
14651475
@pytest.mark.xfail(reason="Distribution not refactored yet")
1466-
def test_beta_binomial(self):
1476+
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
1477+
def test_beta_binomial_distribution(self):
14671478
self.checkd(
14681479
BetaBinomial,
14691480
Nat,
14701481
{"alpha": Rplus, "beta": Rplus, "n": NatSmall},
14711482
)
1483+
1484+
@pytest.mark.xfail(reason="Distribution not refactored yet")
1485+
@pytest.mark.skipif(
1486+
condition=(SCIPY_VERSION < parse("1.4.0")), reason="betabinom is new in Scipy 1.4.0"
1487+
)
1488+
def test_beta_binomial_logp(self):
14721489
self.check_logp(
14731490
BetaBinomial,
14741491
Nat,
14751492
{"alpha": Rplus, "beta": Rplus, "n": NatSmall},
14761493
lambda value, alpha, beta, n: sp.betabinom.logpmf(value, a=alpha, b=beta, n=n),
14771494
)
1495+
1496+
@pytest.mark.xfail(reason="Distribution not refactored yet")
1497+
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
1498+
@pytest.mark.skipif(
1499+
condition=(SCIPY_VERSION < parse("1.4.0")), reason="betabinom is new in Scipy 1.4.0"
1500+
)
1501+
def test_beta_binomial_logcdf(self):
14781502
self.check_logcdf(
14791503
BetaBinomial,
14801504
Nat,
@@ -1576,29 +1600,41 @@ def test_constantdist(self):
15761600
self.check_logp(Constant, I, {"c": I}, lambda value, c: np.log(c == value))
15771601

15781602
# Too lazy to propagate decimal parameter through the whole chain of deps
1579-
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
15801603
@pytest.mark.xfail(reason="Distribution not refactored yet")
1581-
def test_zeroinflatedpoisson(self):
1604+
@pytest.mark.xfail(
1605+
condition=(aesara.config.floatX == "float32"),
1606+
reason="Fails on float32 due to inf issues",
1607+
)
1608+
def test_zeroinflatedpoisson_distribution(self):
15821609
self.checkd(
15831610
ZeroInflatedPoisson,
15841611
Nat,
15851612
{"theta": Rplus, "psi": Unit},
15861613
)
1614+
1615+
@pytest.mark.xfail(reason="Distribution not refactored yet")
1616+
def test_zeroinflatedpoisson_logcdf(self):
15871617
self.check_selfconsistency_discrete_logcdf(
15881618
ZeroInflatedPoisson,
15891619
Nat,
15901620
{"theta": Rplus, "psi": Unit},
15911621
)
15921622

15931623
# Too lazy to propagate decimal parameter through the whole chain of deps
1594-
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
15951624
@pytest.mark.xfail(reason="Distribution not refactored yet")
1596-
def test_zeroinflatednegativebinomial(self):
1625+
@pytest.mark.xfail(
1626+
condition=(aesara.config.floatX == "float32"),
1627+
reason="Fails on float32 due to inf issues",
1628+
)
1629+
def test_zeroinflatednegativebinomial_distribution(self):
15971630
self.checkd(
15981631
ZeroInflatedNegativeBinomial,
15991632
Nat,
16001633
{"mu": Rplusbig, "alpha": Rplusbig, "psi": Unit},
16011634
)
1635+
1636+
@pytest.mark.xfail(reason="Distribution not refactored yet")
1637+
def test_zeroinflatednegativebinomial_logcdf(self):
16021638
self.check_selfconsistency_discrete_logcdf(
16031639
ZeroInflatedNegativeBinomial,
16041640
Nat,
@@ -1607,14 +1643,16 @@ def test_zeroinflatednegativebinomial(self):
16071643
)
16081644

16091645
# Too lazy to propagate decimal parameter through the whole chain of deps
1610-
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
16111646
@pytest.mark.xfail(reason="Distribution not refactored yet")
16121647
def test_zeroinflatedbinomial(self):
16131648
self.checkd(
16141649
ZeroInflatedBinomial,
16151650
Nat,
16161651
{"n": NatSmall, "p": Unit, "psi": Unit},
16171652
)
1653+
1654+
@pytest.mark.xfail(reason="Distribution not refactored yet")
1655+
def test_zeroinflatedbinomial_logcdf(self):
16181656
self.check_selfconsistency_discrete_logcdf(
16191657
ZeroInflatedBinomial,
16201658
Nat,
@@ -2424,15 +2462,23 @@ def test_rice(self):
24242462
lambda value, b, sigma: sp.rice.logpdf(value, b=b, loc=0, scale=sigma),
24252463
)
24262464

2427-
@pytest.mark.xfail(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
24282465
@pytest.mark.xfail(reason="Distribution not refactored yet")
2429-
def test_moyal(self):
2466+
def test_moyal_logp(self):
2467+
# Using a custom domain, because the standard `R` domain undeflows with scipy in float64
2468+
value_domain = Domain([-inf, -1.5, -1, -0.01, 0.0, 0.01, 1, 1.5, inf])
24302469
self.check_logp(
24312470
Moyal,
2432-
R,
2471+
value_domain,
24332472
{"mu": R, "sigma": Rplusbig},
24342473
lambda value, mu, sigma: floatX(sp.moyal.logpdf(value, mu, sigma)),
24352474
)
2475+
2476+
@pytest.mark.xfail(reason="Distribution not refactored yet")
2477+
@pytest.mark.xfail(
2478+
condition=(aesara.config.floatX == "float32"),
2479+
reason="Pymc3 underflows earlier than scipy on float32",
2480+
)
2481+
def test_moyal_logcdf(self):
24362482
self.check_logcdf(
24372483
Moyal,
24382484
R,
@@ -2736,6 +2782,18 @@ def test_issue_3051(self, dims, dist_cls, kwargs):
27362782
assert isinstance(actual_a, np.ndarray)
27372783
assert actual_a.shape == (X.shape[0],)
27382784

2785+
@pytest.mark.xfail(reason="Distribution not refactored yet")
2786+
def test_issue_4499(self):
2787+
# Test for bug in Uniform and DiscreteUniform logp when setting check_bounds = False
2788+
# https://github.com/pymc-devs/pymc3/issues/4499
2789+
with pm.Model(check_bounds=False) as m:
2790+
x = pm.Uniform("x", 0, 2, shape=10, transform=None)
2791+
assert_almost_equal(m.logp_array(np.ones(10)), -np.log(2) * 10)
2792+
2793+
with pm.Model(check_bounds=False) as m:
2794+
x = pm.DiscreteUniform("x", 0, 1, shape=10)
2795+
assert_almost_equal(m.logp_array(np.ones(10)), -np.log(2) * 10)
2796+
27392797

27402798
@pytest.mark.xfail(reason="DensityDist no longer supported")
27412799
def test_serialize_density_dist():

0 commit comments

Comments
 (0)