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

Aegean Exception class #168

Merged
merged 6 commits into from Jul 15, 2022
Merged

Aegean Exception class #168

merged 6 commits into from Jul 15, 2022

Conversation

tjgalvin
Copy link
Contributor

I had an instance recently where lmfit was raising exceptions to highlight NaNs in either the data or model output when performing optimisation. It turned out that sometimes during optimisation that parameters were set to NaN as they were passed to the residual function, which in turn generates a model made up of all NaNs. This was a little bit of a pain to track down as aegean correctly masks all NaNs in the data to begin with.

Although one could capture the ValueError raised by lmfit, a ValueError is an awfully broad exception and might be a little painful to test against during the exception handling, I thought the better approach would be to have a class AgeanError class that we can subclass to better handle these strange errors.

In this example request I have made an AegeanNaNModelError that is raised in the residual function if there are any NaNs, and is capture in the non-priorised fitting routine in sourcefinder.py. This, I think, lets us better handle the cases where there are errors we do not care about, and still correctly raise new ones we don't currently know about.

@tjgalvin tjgalvin mentioned this pull request Jan 19, 2022
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 83.474% when pulling 654fb20 on tjgalvin:exceptions into 60bf55a on PaulHancock:main.

@PaulHancock PaulHancock changed the base branch from main to dev July 15, 2022 06:05
@PaulHancock PaulHancock merged commit e343064 into PaulHancock:dev Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants