-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
introduced tests for pymc.distributions.logprob._get_scaling_ #5544
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5544 +/- ##
==========================================
- Coverage 89.21% 86.66% -2.56%
==========================================
Files 75 75
Lines 13846 13846
==========================================
- Hits 12353 11999 -354
- Misses 1493 1847 +354
|
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.
Looking quite good.
I'm not familiar with _get_scaling
so I can't tell if the numbers are correct, but I assume that they are.
Can you add match="part of the message"
to the pytest.raises(...)
? That'll make sure that it's testing the right errors.
@ricardoV94 @chritter can you check/fix/apply the suggestions I commented? Let's get this over the finish line |
pymc/tests/test_logprob.py
Outdated
|
||
# list or tuple tests | ||
# total_size contains other than Ellipsis, None and Int | ||
with pytest.raises(TypeError): |
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.
with pytest.raises(TypeError): | |
with pytest.raises(TypeError, match="expected int or list of ints"): |
pymc/tests/test_logprob.py
Outdated
with pytest.raises(ValueError): | ||
_get_scaling([1, 2, 5, Ellipsis, Ellipsis], (2, 3), 2) | ||
with pytest.raises(ValueError): | ||
_get_scaling([1, 2, 5, Ellipsis], (2, 3), 2) |
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.
with pytest.raises(ValueError): | |
_get_scaling([1, 2, 5, Ellipsis, Ellipsis], (2, 3), 2) | |
with pytest.raises(ValueError): | |
_get_scaling([1, 2, 5, Ellipsis], (2, 3), 2) | |
with pytest.raises(ValueError, match="Double Ellipsis"): | |
_get_scaling([1, 2, 5, Ellipsis, Ellipsis], (2, 3), 2) | |
with pytest.raises(ValueError, match="scalings is bigger that ndim"): | |
_get_scaling([1, 2, 5, Ellipsis], (2, 3), 2) |
pymc/tests/test_logprob.py
Outdated
assert _get_scaling([4, 5, 9, Ellipsis, 32, 12], (2, 3, 2), 5).eval() == 960 | ||
assert _get_scaling([4, 5, 9, Ellipsis], (2, 3, 2), 5).eval() == 15 | ||
# total_size with no Ellipsis (end = [ ]) | ||
with pytest.raises(ValueError): |
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.
with pytest.raises(ValueError): | |
with pytest.raises(ValueError, match="scalings is bigger that ndim"): |
pymc/tests/test_logprob.py
Outdated
assert _get_scaling([], (2, 3), 2).eval() == 1 | ||
assert _get_scaling((), (2, 3), 2).eval() == 1 | ||
# total_size invalid type | ||
with pytest.raises(TypeError): |
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.
with pytest.raises(TypeError): | |
with pytest.raises(TypeError, match="expected int or list of ints"): |
Co-authored-by: Icyshaman <[email protected]>
6660dd3
to
af2e5f9
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.
I rebased it to fix git conflicts.
Will merge once the tests pass.
Fixes #5515. We have implemented tests for pymc.distributions.logprob.get_scaling which include edge cases and a test with a model graph random variable. Please let us know if the test coverage is sufficient or if further tests are required.
Co-authored-by: @Icyshaman.
Depending on what your PR does, here are a few things you might want to address in the description:
#DataUmbrella Sprint
@reshamas