Skip to content

Commit

Permalink
Improve error message when calling AtmGroup.unwrap() without bonds
Browse files Browse the repository at this point in the history
  • Loading branch information
laksh-krishna-sharma committed Jul 23, 2024
1 parent 1bf58cc commit 27fc780
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions package/MDAnalysis/core/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1874,9 +1874,13 @@ def unwrap(self, compound='fragments', reference='com', inplace=True):
"""
atoms = self.atoms
# bail out early if no bonds in topology:
if not hasattr(atoms, 'bonds'):
raise NoDataError("{}.unwrap() not available; this requires Bonds"
"".format(self.__class__.__name__))
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:\n"
"1. Guess the bonds at universe creation using `guess_bonds = True`, or\n"
"2. Create a universe using a topology format where bonds are pre-defined."
)
unique_atoms = atoms.unsorted_unique

# Parameter sanity checking
Expand Down

0 comments on commit 27fc780

Please sign in to comment.