Skip to content

Commit

Permalink
Remove unused checkd tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoV94 committed Jan 13, 2022
1 parent 192e83d commit b50442e
Showing 1 changed file with 1 addition and 69 deletions.
70 changes: 1 addition & 69 deletions pymc/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def polyagamma_cdf(*args, **kwargs):
from aesara.graph.basic import ancestors
from aesara.tensor.random.op import RandomVariable
from aesara.tensor.var import TensorVariable
from numpy import array, inf, log
from numpy import array, inf
from numpy.testing import assert_almost_equal, assert_equal
from scipy import integrate
from scipy.special import erf, gammaln, logit
Expand All @@ -71,7 +71,6 @@ def polyagamma_cdf(*args, **kwargs):
Cauchy,
ChiSquared,
Constant,
DensityDist,
Dirichlet,
DirichletMultinomial,
DiscreteUniform,
Expand Down Expand Up @@ -963,25 +962,6 @@ def check_selfconsistency_discrete_logcdf(
err_msg=str(pt),
)

def check_int_to_1(self, model, value, domain, paramdomains, n_samples=10):
pdf = model.fastfn(exp(model.logpt))
for pt in product(paramdomains, n_samples=n_samples):
pt = Point(pt, value=value.tag.test_value, model=model)
bij = DictToVarBijection(value, (), pt)
pdfx = bij.mapf(pdf)
area = integrate_nd(pdfx, domain, value.dshape, value.dtype)
assert_almost_equal(area, 1, err_msg=str(pt))

def checkd(self, distfam, valuedomain, vardomains, checks=None, extra_args=None):
if checks is None:
checks = (self.check_int_to_1,)

if extra_args is None:
extra_args = {}
m = build_model(distfam, valuedomain, vardomains, extra_args=extra_args)
for check in checks:
check(m, m.named_vars["value"], valuedomain, vardomains)

def test_uniform(self):
self.check_logp(
Uniform,
Expand Down Expand Up @@ -1664,15 +1644,6 @@ def test_binomial(self):
{"n": NatSmall, "p": Unit},
)

@pytest.mark.xfail(reason="checkd tests have not been refactored")
@pytest.mark.skipif(condition=(aesara.config.floatX == "float32"), reason="Fails on float32")
def test_beta_binomial_distribution(self):
self.checkd(
BetaBinomial,
Nat,
{"alpha": Rplus, "beta": Rplus, "n": NatSmall},
)

def test_beta_binomial(self):
self.check_logp(
BetaBinomial,
Expand Down Expand Up @@ -1771,18 +1742,6 @@ def test_poisson(self):
def test_constantdist(self):
self.check_logp(Constant, I, {"c": I}, lambda value, c: np.log(c == value))

@pytest.mark.xfail(reason="Test has not been refactored")
@pytest.mark.skipif(
condition=(aesara.config.floatX == "float32"),
reason="Fails on float32 due to inf issues",
)
def test_zeroinflatedpoisson_distribution(self):
self.checkd(
ZeroInflatedPoisson,
Nat,
{"theta": Rplus, "psi": Unit},
)

def test_zeroinflatedpoisson(self):
def logp_fn(value, psi, theta):
if value == 0:
Expand Down Expand Up @@ -1813,18 +1772,6 @@ def logcdf_fn(value, psi, theta):
{"theta": Rplus, "psi": Unit},
)

@pytest.mark.xfail(reason="Test not refactored yet")
@pytest.mark.skipif(
condition=(aesara.config.floatX == "float32"),
reason="Fails on float32 due to inf issues",
)
def test_zeroinflatednegativebinomial_distribution(self):
self.checkd(
ZeroInflatedNegativeBinomial,
Nat,
{"mu": Rplusbig, "alpha": Rplusbig, "psi": Unit},
)

def test_zeroinflatednegativebinomial(self):
def logp_fn(value, psi, mu, alpha):
n, p = NegativeBinomial.get_n_p(mu=mu, alpha=alpha)
Expand Down Expand Up @@ -1873,14 +1820,6 @@ def logcdf_fn(value, psi, mu, alpha):
{"psi": Unit, "mu": Rplusbig, "alpha": Rplusbig},
)

@pytest.mark.xfail(reason="Test not refactored yet")
def test_zeroinflatedbinomial_distribution(self):
self.checkd(
ZeroInflatedBinomial,
Nat,
{"n": NatSmall, "p": Unit, "psi": Unit},
)

def test_zeroinflatedbinomial(self):
def logp_fn(value, psi, n, p):
if value == 0:
Expand Down Expand Up @@ -2377,13 +2316,6 @@ def test_orderedprobit(self, n):
lambda value, eta, cutpoints: orderedprobit_logpdf(value, eta, cutpoints),
)

@pytest.mark.xfail(reason="checkd tests have not been refactored")
def test_densitydist(self):
def logp(x):
return -log(2 * 0.5) - abs(x - 0.5) / 0.5

self.checkd(DensityDist, R, {}, extra_args={"logp": logp})

def test_get_tau_sigma(self):
sigma = np.array(2)
assert_almost_equal(get_tau_sigma(sigma=sigma), [1.0 / sigma ** 2, sigma])
Expand Down

0 comments on commit b50442e

Please sign in to comment.