-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
V4 update test framework for distributions random method 2nd attempt #4608
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good start. We should also check that .eval()
actually works even if just for a single sample.
I think @brandonwillard had some code in the original issue asserting that the numbers generated by our distribution and the scipy one were the same when given the same random seeds. That feels like a stronger test.
PS: Checking that a dozen or so samples match should be enough as we already asserted the right parameters are being used.
What do you think?
The exponential and gamma should now pass after #4576 |
Lovely, thanks for flagging |
Sounds good. It's definitely a more robust test. Let me know if what added is in line with what you had in mind |
53dfb75
to
ef7584e
Compare
I left some small comments. Overall I think it looks fine and should definitely cover the pymc <- -> aesara parametrizations. After this PR we might still need something extra for the random ops that are implemented on our side, but that might be better done separately. |
Also, we can remove these lines from the previous PR: https://github.com/pymc-devs/pymc3/blob/7a7179276f8f60470dacc496d3c2add4b636e4a2/pymc3/tests/test_distributions_random.py#L1773-L1803 |
I think we are pretty much ready after you complete those final refactorings. Thanks for your work and patience. Is there anything else you think should be changed? |
Happy to cover I should have addressed all the refactoring comments you left |
1ca93bc
to
598d0db
Compare
The refactoring should make it possible testing both the distribution parametrization and sampled values according to need, as well as any other future test. More details on PR pymc-devs#4608
598d0db
to
5e67189
Compare
The refactoring should make it possible testing both the distribution parametrization and sampled values according to need, as well as any other future test. More details on PR pymc-devs#4608
5e67189
to
e4901ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. I left some general comments, let me know what you think :)
"expected_rv_op_params": {"mu": 1.5, "beta": 3.0}, | ||
"expected_dist": self._get_scipy_distribution("gumbel_r"), | ||
"expected_dist_params": {"loc": 1.5, "scale": 3.0}, | ||
"size": 15, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why this needed size explicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I can remove it, given that the default value is 15 anyway. it's not needed, but it shows very explicitly how to define the size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to leave it out. Specially since the BaseTests parametrize size separately.
Sounds like you are on the right track. I would focus on integrating the After this it's perhaps time to get a second review, merge, and start using it with the newly refactored distributions. It will be more obvious whether more types of tests are needed or if these suffice. |
The refactoring should make it possible testing both the distribution parametrization and sampled values according to need, as well as any other future test. More details on PR pymc-devs#4608
e4901ee
to
69592c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor comments. The way the discrete_weibul_rng_fn
is implemented looks a bit complicated. Do you think it might read better if we unpack that lambda to an explicit function?
Otherwise things LGTM!
The distributions refactoring moves the random variable sampling to aesara. This relies on numpy and scipy random variables implementation. So, now the only thing we care about testing is that the parametrization on the PyMC side is sendible given the one on the Aesara side (effectively the numpy/scipy one) More details can be found on issue pymc-devs#4554 pymc-devs#4554
More details can be found on issue pymc-devs#4554 pymc-devs#4554
More details can be found on issue pymc-devs#4554 pymc-devs#4554
Most of the random variable logic has been moved to aesara, as well as most of the relative tests. More details can be found on issue pymc-devs#4554
Also mark test_categorical as expected to fail due to bug on aesara side. The bug is going to be fixed with 2.0.5 release, so we need to bump the version for categorical and the test to pass.
- replace list of tuples with dict - rename 1 method - move pymc_dist as first argument in function call - replace list(params) with params.copy()
The refactoring should make it possible testing both the distribution parametrization and sampled values according to need, as well as any other future test. More details on PR pymc-devs#4608
56253dc
to
c5661ba
Compare
c5661ba
to
9b52e1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, much more readable and obvious how to apply to new distributions going into the future!
Thanks a lot @DRabbit17. Looking forward to your next PR! |
Thanks for reviewing and helping in making the final version much better |
* Update tests following distributions refactoring The distributions refactoring moves the random variable sampling to aesara. This relies on numpy and scipy random variables implementation. So, now the only thing we care about testing is that the parametrization on the PyMC side is sendible given the one on the Aesara side (effectively the numpy/scipy one) More details can be found on issue #4554 #4554 * Change tests for more refactored distributions. More details can be found on issue #4554 #4554 * Change tests for refactored distributions More details can be found on issue #4554 #4554 * Remove tests for random variable samples shape and size Most of the random variable logic has been moved to aesara, as well as most of the relative tests. More details can be found on issue #4554 * Fix test for half cauchy, renmae mv normal tests and add test for Bernoulli * Add test checking PyMC samples match the aesara ones Also mark test_categorical as expected to fail due to bug on aesara side. The bug is going to be fixed with 2.0.5 release, so we need to bump the version for categorical and the test to pass. * Move Aesara to 2.0.5 to include Gumbel distribution * Enamble exponential and gamma tests following bug-fix * Enable categorical test following aesara version bump to 2.0.5 and relative bug-fix * Few small cosmetic changes: - replace list of tuples with dict - rename 1 method - move pymc_dist as first argument in function call - replace list(params) with params.copy() * Remove redundant tests * Further refactoring The refactoring should make it possible testing both the distribution parametrization and sampled values according to need, as well as any other future test. More details on PR #4608 * Add size tests to new rv testing framework * Add tests for multivariate and for univariate multi-parameters * remove test already covered in aesara * fix few names * Remove "distribution" from test class names * Add discrete Weibull, improve Beta and some minor refactoring * Fix typos in checks naming and add sanity check Co-authored-by: Ricardo <[email protected]>
The recent distributions refactoring (#4508 and #4548) moves the logic to
get a random variable from a distribution to aesara.
This relies on numpy and scipy random variables implementation.
Given this change the main thing worth testing on the PyMC side is that
the PyMC parametrization is sensible given the one on the Aesara side
(effectively the numpy/scipy one)
More details can be found on issue #4554
WIP: V4 update test framework for distributions random method #4580