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 error message when calling AtmGroup.unwrap() without bonds #4642

Conversation

laksh-krishna-sharma
Copy link
Contributor

@laksh-krishna-sharma laksh-krishna-sharma commented Jul 23, 2024

Fixes #4436: Improve error message when calling AtomGroup.unwrap() without bonds

This PR improves the error message that is raised when calling AtomGroup.unwrap() without defined bonds. The new message provides clearer guidance on how users can resolve the issue.

PR Checklist

  • Tests?
  • Issue raised/referenced?

Developers certificate of origin


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

@pep8speaks
Copy link

pep8speaks commented Jul 23, 2024

Hello @laksh-krishna-sharma! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 1877:40: W291 trailing whitespace
Line 1879:80: E501 line too long (105 > 79 characters)
Line 1881:80: E501 line too long (90 > 79 characters)
Line 1882:80: E501 line too long (91 > 79 characters)

Line 1492:80: E501 line too long (84 > 79 characters)
Line 1494:80: E501 line too long (86 > 79 characters)
Line 1495:80: E501 line too long (87 > 79 characters)
Line 1499:36: W291 trailing whitespace

Line 341:80: E501 line too long (102 > 79 characters)
Line 343:80: E501 line too long (86 > 79 characters)
Line 344:80: E501 line too long (87 > 79 characters)

Comment last updated at 2024-07-28 09:21:18 UTC

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello there first time contributor! Welcome to the MDAnalysis community! We ask that all contributors abide by our Code of Conduct and that first time contributors introduce themselves on GitHub Discussions so we can get to know you. You can learn more about participating here. Please also add yourself to package/AUTHORS as part of this PR.

Copy link

github-actions bot commented Jul 23, 2024

Linter Bot Results:

Hi @laksh-krishna-sharma! Thanks for making this PR. We linted your code and found the following:

Some issues were found with the formatting of your code.

Code Location Outcome
main package ⚠️ Possible failure
testsuite ⚠️ Possible failure

Please have a look at the darker-main-code and darker-test-code steps here for more details: https://github.com/MDAnalysis/mdanalysis/actions/runs/10130585219/job/28012143836


Please note: The black linter is purely informational, you can safely ignore these outcomes if there are no flake8 failures!

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.

@laksh-krishna-sharma looks good.

Could you please follow @tylerjereddy 's suggestion and find the place where we test for the exception being raised and then add a match for part of the message.

@orbeckst orbeckst self-assigned this Jul 24, 2024
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.

The tests are failing now, please fix. Perhaps you need to treat the match string more carefully. It would also be ok to just match the first line.

@tylerjereddy
Copy link
Member

ya, just using a regex-style match on a sub-section of the message is usually what I see done

@laksh-krishna-sharma
Copy link
Contributor Author

Thank you for your feedback, @orbeckst and @tylerjereddy. I have resolved the issue by carefully revising the match string. Please review the updated.

@orbeckst
Copy link
Member

Tests are failing with something that looks related to your code

=================================== FAILURES ===================================
________________ TestAttributeGetting.test_unwrap_without_bonds ________________
[gw1] linux -- Python 3.10.14 /home/runner/micromamba/envs/mda/bin/python3.10

universe = <MDAnalysisTests.core.test_groups.TestAttributeGetting object at 0x7f6b8005f2e0>

    def test_unwrap_without_bonds(universe):
        with pytest.raises(NoDataError) as exc:
>           universe.atoms.unwrap()
E           AttributeError: 'TestAttributeGetting' object has no attribute 'atoms'

/home/runner/work/mdanalysis/mdanalysis/testsuite/MDAnalysisTests/core/test_groups.py:1485: AttributeError

Can you please check?

@laksh-krishna-sharma
Copy link
Contributor Author

Thank you for letting me know, @orbeckst. I will investigate the issue and address the failing tests as soon as possible. I'll update once the problem is resolved.

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.59%. Comparing base (1bf58cc) to head (1898256).
Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4642      +/-   ##
===========================================
- Coverage    93.61%   93.59%   -0.03%     
===========================================
  Files          171      183      +12     
  Lines        21250    22320    +1070     
  Branches      3936     3937       +1     
===========================================
+ Hits         19893    20890     +997     
- Misses         898      971      +73     
  Partials       459      459              

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

@laksh-krishna-sharma
Copy link
Contributor Author

laksh-krishna-sharma commented Jul 26, 2024

Thank you for your feedback, @orbeckst and @tylerjereddy. I have resolved the issue carefully . Please review the updated.

@laksh-krishna-sharma
Copy link
Contributor Author

Please review the updated.

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.

This looks functionality very good. I have one request for you to improve our existing code (see comment) and also

  • add yourself to the end of the file AUTHORS
  • update CHANGELOG: add an entry for the change in the CHANGELOG file to the top of Enhancements
    Enhancements
    * Add `analysis.DSSP` module for protein secondary structure assignment, based on [pydssp](https://github.com/ShintaroMinami/PyDSSP)
    and don't forget to add your GitHub handle at the end of the line of authors who contributed to the release
    yuxuanzhuang, PythonFZ

That's all I see and then I can merge it.

testsuite/MDAnalysisTests/core/test_groups.py Outdated Show resolved Hide resolved
@laksh-krishna-sharma
Copy link
Contributor Author

Thank you for your review, @orbeckst. I'll complete all the tasks mentioned.

@laksh-krishna-sharma
Copy link
Contributor Author

Thank you for your feedback, @orbeckst. I have made all the requested improvements, including updating the AUTHORS file, adding an entry to the CHANGELOG under Enhancements, and ensuring my GitHub handle is included with the contributors. I also revised the test using pytest.raises with the match parameter for message checking. Please review the updated.

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.

Thanks, please see inline comments!

"2. Create a universe using a topology format where bonds are pre-defined."
)
expected_message_pattern = re.escape(expected_message)
assert re.fullmatch(expected_message_pattern, str(exc.value))
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, my previous comment wasn't clear enough. What I would like you to do is to

  1. add to the pytest.raises(NoDataError) above a match=expected_message_pattern)
  2. remove the assert that checks for the message.

In this way we have all checks inside the pytest.raises.

package/CHANGELOG Show resolved Hide resolved
@laksh-krishna-sharma
Copy link
Contributor Author

@orbeckst thank you for clearly mentioning the issue again. I have resolved it carefully. Please review the updated.

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.

All looking good, thanking you for patiently and promptly and addressing my comments.

I'll merge — thank you for your first contribution! I hope we see more from you!

@orbeckst orbeckst merged commit d16b8d4 into MDAnalysis:develop Jul 28, 2024
22 of 23 checks passed
@orbeckst
Copy link
Member

Congratulations, @laksh-krishna-sharma , first merged contribution! 🎉

@laksh-krishna-sharma
Copy link
Contributor Author

Thank you, @orbeckst! I am grateful for the opportunity to contribute and for your patient guidance. I would like to work more under your guidance in this repository. It would be great if you could help me with the environment setup, as I am looking to contribute more and learn from you. This being my first contribution, it has been an amazing experience, and I have learned a lot. I am excited to continue contributing and learning.

@orbeckst
Copy link
Member

Thank you for your contribution, it was a pleasure working with you.

We only assign specific mentors for something like Google Summer of Code. When you're part of the MDAnalysis community you'll interact with many people — users, developers, documentation writers, instructors, ... I suggest you engage through the public forums (discussions, discord) if you have specific questions — typically there's someone there who can point you in the right direction.

@laksh-krishna-sharma
Copy link
Contributor Author

Thank you @orbeckst . I understand the mentorship structure within the MDAnalysis community. I look forward to interacting with the community and continuing to contribute to the project.

@laksh-krishna-sharma laksh-krishna-sharma deleted the fix/improve-error-message-when-calling-AtmGroup-unwrap-without-bonds branch July 29, 2024 07:36
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.

Improve error message when calling AtmGroup.unwrap() without bonds
4 participants