Improve error message when calling `AtmGroup.unwrap()` without bonds
When calling the unwrap() method of an AtomGroup the method correctly checks for existing bonds and raises an error if this is not the case.
https://github.com/MDAnalysis/mdanalysis/blob/24abb160788ef87a48ed6eb196c1704d68fbc2da/package/MDAnalysis/core/groups.py#L1827-L1829
Even though the error message is clear I recently experienced issues that users do not know what to do in this case. It might worse improve this error message giving a hint what users can do. Maybe something along the lines:
if not hasattr(atoms, 'bonds'):
raise NoDataError(
f"{self.__class__.__name__}.unwrap() not available; this AtomGroup lacks defined bonds."
"To resolve this, you can either (1) guess the bonds at universe creation using `guess_bonds=True`"
" or (2) create a universe using a topology format where bonds are pre-defined."
)
The new error message sounds very sensible to me, and definitely more helpful that the current "no can do!".
Sounds like a very good idea. And easy to implement for new contributors!
May I work on this issue with a little bit of your guidance?
@laksh-krishna-sharma you're generally welcome to work on any issue and contribute. The first step is to create a pull request (PR) with your proposed changes and then developers will comment on the PR. Our User Guide has a section on Contributing to the code base that you should read if you haven't done so already.
Thanks for the reply and guidance, @orbeckst. I will check and understand the issue thoroughly and then create a PR.
@orbeckst. I created a PR . Please let me know if there are any issues. I will try my best to resolve them with your guidance. Thanks for giving me a chance, as this is my first time contributing to open source.