Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 update test framework for distributions random method 2nd attempt #4608

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5132c92
Update tests following distributions refactoring
matteo-pallini Mar 28, 2021
45180b1
Change tests for more refactored distributions.
matteo-pallini Apr 1, 2021
7fed128
Change tests for refactored distributions
matteo-pallini Apr 1, 2021
6cb7a6b
Remove tests for random variable samples shape and size
matteo-pallini Apr 1, 2021
fe5d7d9
Fix test for half cauchy, renmae mv normal tests and add test for
matteo-pallini Apr 3, 2021
6b576c4
Add test checking PyMC samples match the aesara ones
matteo-pallini Apr 4, 2021
b50e92f
Move Aesara to 2.0.5 to include Gumbel distribution
matteo-pallini Apr 4, 2021
78ac5ac
Enamble exponential and gamma tests following bug-fix
matteo-pallini Apr 4, 2021
b7afa5d
Enable categorical test following aesara version bump to 2.0.5 and re…
matteo-pallini Apr 4, 2021
d6c3847
Few small cosmetic changes:
matteo-pallini Apr 5, 2021
7b5899c
Remove redundant tests
matteo-pallini Apr 5, 2021
b1c40ef
Further refactoring
matteo-pallini Apr 8, 2021
a817a7e
Add size tests to new rv testing framework
matteo-pallini Apr 17, 2021
1c88e55
Add tests for multivariate and for univariate multi-parameters
matteo-pallini Apr 18, 2021
bf68a3a
remove test already covered in aesara
matteo-pallini Apr 18, 2021
55b4a0f
fix few names
matteo-pallini Apr 18, 2021
706308e
Remove "distribution" from test class names
ricardoV94 Apr 22, 2021
3d28087
Add discrete Weibull, improve Beta and some minor refactoring
matteo-pallini Apr 22, 2021
9b52e1b
Fix typos in checks naming and add sanity check
matteo-pallini Apr 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pymc3/distributions/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,24 +713,23 @@ def NegBinom(a, m, x):

@classmethod
def dist(cls, mu=None, alpha=None, p=None, n=None, *args, **kwargs):
n, p = cls.get_mu_alpha(mu, alpha, p, n)
n, p = cls.get_n_p(mu, alpha, p, n)
n = at.as_tensor_variable(floatX(n))
p = at.as_tensor_variable(floatX(p))
return super().dist([n, p], *args, **kwargs)

@classmethod
def get_mu_alpha(cls, mu=None, alpha=None, p=None, n=None):
def get_n_p(cls, mu=None, alpha=None, p=None, n=None):
if n is None:
if alpha is not None:
n = at.as_tensor_variable(floatX(alpha))
n = alpha
else:
raise ValueError("Incompatible parametrization. Must specify either alpha or n.")
elif alpha is not None:
raise ValueError("Incompatible parametrization. Can't specify both alpha and n.")

if p is None:
if mu is not None:
mu = at.as_tensor_variable(floatX(mu))
p = n / (mu + n)
else:
raise ValueError("Incompatible parametrization. Must specify either mu or p.")
Expand Down
6 changes: 6 additions & 0 deletions pymc3/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

class SeededTest:
random_seed = 20160911
random_state = None

@classmethod
def setup_class(cls):
Expand All @@ -40,6 +41,11 @@ def setup_method(self):
def teardown_method(self):
set_at_rng(self.old_at_rng)

def get_random_state(self, reset=False):
if self.random_state is None or reset:
self.random_state = nr.RandomState(self.random_seed)
return self.random_state


class LoggingHandler(BufferingHandler):
def __init__(self, matcher):
Expand Down
Loading