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

Switch guessers to catching and raising NoDataErrors #4755

Merged

Conversation

lilyminium
Copy link
Member

@lilyminium lilyminium commented Oct 20, 2024

Fixes #4749 (maybe?)

Changes made in this Pull Request:

  • Switches errors to NoDataErrors

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

Developers certificate of origin


📚 Documentation preview 📚: https://mdanalysis--4755.org.readthedocs.build/en/4755/

Copy link

codecov bot commented Oct 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.57%. Comparing base (d7153b9) to head (7c9e176).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4755      +/-   ##
===========================================
- Coverage    93.59%   93.57%   -0.03%     
===========================================
  Files          177      189      +12     
  Lines        21708    22775    +1067     
  Branches      3052     3052              
===========================================
+ Hits         20318    21312     +994     
- Misses         943     1016      +73     
  Partials       447      447              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

From reading the issue and glancing at the code, changing the raised ValueError to NoDataError makes sense and seems more consistent.

I am not really familiar with the new guesser code so this is just a surface-level review. Other reviews would be great.

@lilyminium I'll leave it to you to gather more opinions if you need them.

@IAlibay IAlibay added this to the Release 2.8.0 milestone Oct 24, 2024
@lilyminium
Copy link
Member Author

@IAlibay could you please have a look to see if this resolves issue #4749?

@yuxuanzhuang
Copy link
Contributor

I think what @IAlibay means is that there is a nested exception error message:

a = np.array([
    [0., 0., 150.], [0., 0., 150.], [200., 0., 150.],
    [0., 0., 150.], [100., 100., 150.], [200., 100., 150.],
    [0., 200., 150.], [100., 200., 150.], [200., 200., 150.]
])
u = mda.Universe(a, n_atoms=9, to_guess=['elements'])

> ...
> NoDataError: This Universe does not contain name information
> During handling of the above exception, another exception occurred:
> ...
> NoDataError: there is no reference attributes in this universeto guess types from

which is kinda ugly. you can explicitly suppress the chaining of exceptions using the from None syntax (see suggestions)

package/MDAnalysis/guesser/default_guesser.py Outdated Show resolved Hide resolved
package/MDAnalysis/guesser/default_guesser.py Outdated Show resolved Hide resolved
@IAlibay
Copy link
Member

IAlibay commented Oct 25, 2024

I think what @IAlibay means is that there is a nested exception error message:

which is kinda ugly. you can explicitly suppress the chaining of exceptions using the from None syntax (see suggestions)

Yes, thanks so much @yuxuanzhuang, that's exactly what I was looking at! Sorry I conflated that with the error type for some reason.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

LGTM with @yuxuanzhuang's suggestions.

@IAlibay IAlibay merged commit 961cbd5 into MDAnalysis:develop Oct 26, 2024
23 of 24 checks passed
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.

Guesser checks should wrap NoDataError
4 participants