-
-
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
Errors in checks and test_checks #6684
Comments
|
pymc/tests/logprob/test_checks.py Lines 79 to 98 in a59c9cd
Here, an obvious error is in the On running the pytest test with the rectified code as the following, the test fails to raise an assertion error. def test_assert_logprob():
rv = pt.random.normal()
assert_op = Assert("Test assert")
# Example: Add assert that rv must be positive
assert_rv = assert_op(rv, rv>0)
assert_rv.name = "assert_rv"
assert_vv = assert_rv.clone()
assert_logp = factorized_joint_logprob({assert_rv: assert_vv})[assert_vv]
# Check valid value is correct and doesn't raise
# Since here the value to the rv satisfies the condition, no error is raised.
valid_value = 3.0
assert_logp.eval({assert_vv: valid_value})
# Check invalid value
# Since here the value to the rv is negative, an exception is raised as the condition is not met
with pytest.raises(AssertionError, match="Test assert"):
assert_logp.eval({assert_vv: -5.0})
|
If I understand correctly there's a bug in the Is there something you couldn't quite figure out about the solution yet? The Exception type should be the same as the one in the original |
Yes you are correct. #6599 does not rectify the import for |
There are some changes I would like to suggest in the
But even these changes does not produces the expected pymc/tests/logprob/test_checks.py Lines 97 to 98 in 9f01be2
My guess is there is a problem with the assert_op itself but I am unable to figure out exactly what it is.
|
You don't need the custom exception, the Measurable Op should use the same exception already present in the original |
Yeah the call to |
That's strange. Do you want to open a PR with the relevant tests / changes so that I can have a look? |
yeah sure 👍 |
Description
In the PR 6599, logprob/joint_logp was renamed to logprob/basic for most of the tests that used
factorized_joint_logprob
. This seems like a simple one line pr but there's more to it. There are some errors inpymc/logprob/checks.py
andtests/logprob/test_checks.py
.pymc/pymc/logprob/checks.py
Lines 105 to 150 in a59c9cd
Here , instead of a class, an instance of the class ExceptionType is passed as parameter exc_type in a call to MeasurableCheckAndRaise in line 144.
This can be easily solved by using a class
CustomException
which is inspired from the way pytensor tests handle it.This is something which I can handle and link a PR for the same. However, the issue in the
test/logprob/test_checks.py
is where I need help.
The text was updated successfully, but these errors were encountered: