@@ -1021,18 +1021,21 @@ def test_chi_squared(self):
1021
1021
)
1022
1022
1023
1023
@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 ):
1029
1025
self .check_logp (
1030
1026
Wald ,
1031
1027
Rplus ,
1032
1028
{"mu" : Rplus , "alpha" : Rplus },
1033
1029
lambda value , mu , alpha : sp .invgauss .logpdf (value , mu = mu , loc = alpha ),
1034
1030
decimal = select_by_precision (float64 = 6 , float32 = 1 ),
1035
1031
)
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 ):
1036
1039
self .check_logcdf (
1037
1040
Wald ,
1038
1041
Rplus ,
@@ -1347,7 +1350,7 @@ def test_gamma_logcdf(self):
1347
1350
skip_paramdomain_outside_edge_test = True ,
1348
1351
)
1349
1352
1350
- def test_inverse_gamma (self ):
1353
+ def test_inverse_gamma_logp (self ):
1351
1354
self .check_logp (
1352
1355
InverseGamma ,
1353
1356
Rplus ,
@@ -1356,6 +1359,14 @@ def test_inverse_gamma(self):
1356
1359
)
1357
1360
# pymc-devs/aesara#224: skip_paramdomain_outside_edge_test has to be set
1358
1361
# 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
1359
1370
# in gamma.c file. Can be set back to False (default) once that issue is solved
1360
1371
self .check_logcdf (
1361
1372
InverseGamma ,
@@ -1397,18 +1408,21 @@ def test_pareto(self):
1397
1408
lambda value , alpha , m : sp .pareto .logcdf (value , alpha , scale = m ),
1398
1409
)
1399
1410
1400
- @pytest .mark .xfail (
1401
- condition = (aesara .config .floatX == "float32" ),
1402
- reason = "Fails on float32 due to inf issues" ,
1403
- )
1404
1411
@pytest .mark .xfail (reason = "Distribution not refactored yet" )
1405
- def test_weibull (self ):
1412
+ def test_weibull_logp (self ):
1406
1413
self .check_logp (
1407
1414
Weibull ,
1408
1415
Rplus ,
1409
1416
{"alpha" : Rplusbig , "beta" : Rplusbig },
1410
1417
lambda value , alpha , beta : sp .exponweib .logpdf (value , 1 , alpha , scale = beta ),
1411
1418
)
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 ):
1412
1426
self .check_logcdf (
1413
1427
Weibull ,
1414
1428
Rplus ,
@@ -1458,23 +1472,33 @@ def test_binomial(self):
1458
1472
)
1459
1473
1460
1474
# 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
- )
1465
1475
@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 ):
1467
1478
self .checkd (
1468
1479
BetaBinomial ,
1469
1480
Nat ,
1470
1481
{"alpha" : Rplus , "beta" : Rplus , "n" : NatSmall },
1471
1482
)
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 ):
1472
1489
self .check_logp (
1473
1490
BetaBinomial ,
1474
1491
Nat ,
1475
1492
{"alpha" : Rplus , "beta" : Rplus , "n" : NatSmall },
1476
1493
lambda value , alpha , beta , n : sp .betabinom .logpmf (value , a = alpha , b = beta , n = n ),
1477
1494
)
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 ):
1478
1502
self .check_logcdf (
1479
1503
BetaBinomial ,
1480
1504
Nat ,
@@ -1576,29 +1600,41 @@ def test_constantdist(self):
1576
1600
self .check_logp (Constant , I , {"c" : I }, lambda value , c : np .log (c == value ))
1577
1601
1578
1602
# 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" )
1580
1603
@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 ):
1582
1609
self .checkd (
1583
1610
ZeroInflatedPoisson ,
1584
1611
Nat ,
1585
1612
{"theta" : Rplus , "psi" : Unit },
1586
1613
)
1614
+
1615
+ @pytest .mark .xfail (reason = "Distribution not refactored yet" )
1616
+ def test_zeroinflatedpoisson_logcdf (self ):
1587
1617
self .check_selfconsistency_discrete_logcdf (
1588
1618
ZeroInflatedPoisson ,
1589
1619
Nat ,
1590
1620
{"theta" : Rplus , "psi" : Unit },
1591
1621
)
1592
1622
1593
1623
# 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" )
1595
1624
@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 ):
1597
1630
self .checkd (
1598
1631
ZeroInflatedNegativeBinomial ,
1599
1632
Nat ,
1600
1633
{"mu" : Rplusbig , "alpha" : Rplusbig , "psi" : Unit },
1601
1634
)
1635
+
1636
+ @pytest .mark .xfail (reason = "Distribution not refactored yet" )
1637
+ def test_zeroinflatednegativebinomial_logcdf (self ):
1602
1638
self .check_selfconsistency_discrete_logcdf (
1603
1639
ZeroInflatedNegativeBinomial ,
1604
1640
Nat ,
@@ -1607,14 +1643,16 @@ def test_zeroinflatednegativebinomial(self):
1607
1643
)
1608
1644
1609
1645
# 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" )
1611
1646
@pytest .mark .xfail (reason = "Distribution not refactored yet" )
1612
1647
def test_zeroinflatedbinomial (self ):
1613
1648
self .checkd (
1614
1649
ZeroInflatedBinomial ,
1615
1650
Nat ,
1616
1651
{"n" : NatSmall , "p" : Unit , "psi" : Unit },
1617
1652
)
1653
+
1654
+ @pytest .mark .xfail (reason = "Distribution not refactored yet" )
1655
+ def test_zeroinflatedbinomial_logcdf (self ):
1618
1656
self .check_selfconsistency_discrete_logcdf (
1619
1657
ZeroInflatedBinomial ,
1620
1658
Nat ,
@@ -2424,15 +2462,23 @@ def test_rice(self):
2424
2462
lambda value , b , sigma : sp .rice .logpdf (value , b = b , loc = 0 , scale = sigma ),
2425
2463
)
2426
2464
2427
- @pytest .mark .xfail (condition = (aesara .config .floatX == "float32" ), reason = "Fails on float32" )
2428
2465
@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 ])
2430
2469
self .check_logp (
2431
2470
Moyal ,
2432
- R ,
2471
+ value_domain ,
2433
2472
{"mu" : R , "sigma" : Rplusbig },
2434
2473
lambda value , mu , sigma : floatX (sp .moyal .logpdf (value , mu , sigma )),
2435
2474
)
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 ):
2436
2482
self .check_logcdf (
2437
2483
Moyal ,
2438
2484
R ,
@@ -2736,6 +2782,18 @@ def test_issue_3051(self, dims, dist_cls, kwargs):
2736
2782
assert isinstance (actual_a , np .ndarray )
2737
2783
assert actual_a .shape == (X .shape [0 ],)
2738
2784
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
+
2739
2797
2740
2798
@pytest .mark .xfail (reason = "DensityDist no longer supported" )
2741
2799
def test_serialize_density_dist ():
0 commit comments