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

Improve prior build error message #889

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

bouthilx
Copy link
Member

If there is an error during the attempt of building a builtin prior
(methods implemented in SpaceBuilder), the builder assumes the
expression is not a builtin prior and then tries to create a scipy.stat
prior which also fails. The error message is then that the name of the
expression is not a valid prior. We should instead explicitly verify if
the name of the prior is one that is builtin and then try to build it
without silencing error messages. This way we get the correct error
message for the prior.

If there is an error during the attempt of building a builtin prior
(methods implemented in SpaceBuilder), the builder assumes the
expression is not a builtin prior and then tries to create a scipy.stat
prior which also fails. The error message is then that the name of the
expression is not a valid prior. We should instead explicitly verify if
the name of the prior is one that is builtin and then try to build it
without silencing error messages. This way we get the correct error
message for the prior.
@bouthilx bouthilx added the enhancement Improves a feature or non-functional aspects (e.g., optimization, prettify, technical debt) label Apr 19, 2022
@bouthilx bouthilx added this to the v0.2.4 milestone Apr 19, 2022
@bouthilx bouthilx requested a review from lebrice April 19, 2022 20:10
self, dimbuilder
):
"""Build fails because ValueError happens on init of builtin prior."""
with pytest.raises(ValueError) as exc:
Copy link
Collaborator

@lebrice lebrice May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use the match argument of raises instead of checking if the value is in the exception message, I think.
(That might be only true for pytest.warns though, not 100% sure).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. This test is looking at two different parts of exc.value however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves a feature or non-functional aspects (e.g., optimization, prettify, technical debt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants