-
Notifications
You must be signed in to change notification settings - Fork 824
Closed
Labels
Milestone
Description
Expected behavior
Related to #2977 (comment)
The documentation implies that atomgroup.unique will return a sorted atomgroup, so I expect it to. However, there is a confusing contradiction in the documentation.
def unique(self):
"""An :class:`AtomGroup` containing sorted and unique
:class:`Atoms<Atom>` only.
If the :class:`AtomGroup` is unique, this is the group itself.Actual behavior
If the atomgroup is already unique, as per docs, the original unsorted atomgroup is returned. @coredevs is this the desired behaviour? Should we change it or add a new sorted attribute?
The .unique attribute is primarily used in select_atoms and wrapping-related methods, i.e. bsphere, wrap, unwrap, translate, and rotate. I don't think being ordered is important in any of those -- but being sorted is probably important to select_atoms? Are any users relying on unique being sorted, or conversely not being sorted?
Code to reproduce the behavior
>>> import MDAnalysis as mda
>>> from MDAnalysis.tests.datafiles import PDB
>>> u = mda.Universe(PDB)
>>> ag = u.atoms[[2, 1, 0]]
>>> ag.unique.ix
array([2, 1, 0])Current version of MDAnalysis
- Which version are you using? (run
python -c "import MDAnalysis as mda; print(mda.__version__)") 2.0.0-dev0 - Which version of Python (
python -V)? - Which operating system?
Reactions are currently unavailable