From f810507e1e79f444c2b60c3098af04bfa6110473 Mon Sep 17 00:00:00 2001 From: richardjgowers Date: Fri, 14 Sep 2018 11:42:18 -0500 Subject: [PATCH] fixes #1795 SphericalZone and SphericalLayer no longer shift atoms to inside primary unit cell when calculating center of reference group --- package/CHANGELOG | 3 +++ package/MDAnalysis/core/selection.py | 6 ++---- testsuite/MDAnalysisTests/core/test_atomselections.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package/CHANGELOG b/package/CHANGELOG index 96122d3e129..078aea20630 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -106,6 +106,9 @@ Fixes * Modifying coordinates by assignation is consistently persistent when using the memory reader (Issue #2018) * Allow import of WaterBridgeAnalysis from analysis.hbonds (#2064) + * Fixed SphericalLayer and SphericalZone selections with pbc=True. Previously + these shifted all atoms to inside the primary unit cell when calculating the + center of the reference group (Issue #1795) Changes * TopologyAttrs are now statically typed (Issue #1876) diff --git a/package/MDAnalysis/core/selection.py b/package/MDAnalysis/core/selection.py index 828cfbb594f..4c471419957 100644 --- a/package/MDAnalysis/core/selection.py +++ b/package/MDAnalysis/core/selection.py @@ -288,8 +288,7 @@ def apply(self, group): sel = self.sel.apply(group) box = self.validate_dimensions(group.dimensions) periodic = box is not None - ref = sel.center_of_geometry(pbc=periodic).reshape(1, 3).astype( - np.float32) + ref = sel.center_of_geometry().reshape(1, 3).astype(np.float32) pairs = distances.capped_distance(ref, group.positions, self.exRadius, min_cutoff=self.inRadius, box=box, @@ -314,8 +313,7 @@ def apply(self, group): sel = self.sel.apply(group) box = self.validate_dimensions(group.dimensions) periodic = box is not None - ref = sel.center_of_geometry(pbc=periodic).reshape(1, 3).astype( - np.float32) + ref = sel.center_of_geometry().reshape(1, 3).astype(np.float32) pairs = distances.capped_distance(ref, group.positions, self.cutoff, box=box, return_distances=False) diff --git a/testsuite/MDAnalysisTests/core/test_atomselections.py b/testsuite/MDAnalysisTests/core/test_atomselections.py index c60e094aee5..93f28d12984 100644 --- a/testsuite/MDAnalysisTests/core/test_atomselections.py +++ b/testsuite/MDAnalysisTests/core/test_atomselections.py @@ -530,7 +530,7 @@ def test_spherical_layer(self, u, periodic): r1 = u.select_atoms('resid 1') box = u.dimensions if periodic else None - cog = r1.center_of_geometry(pbc=periodic).reshape(1, 3) + cog = r1.center_of_geometry().reshape(1, 3) d = distance_array(u.atoms.positions, cog, box=box) ref = set(np.where((d > 2.4) & (d < 6.0))[0]) @@ -548,7 +548,7 @@ def test_spherical_zone(self, u, periodic): r1 = u.select_atoms('resid 1') box = u.dimensions if periodic else None - cog = r1.center_of_geometry(pbc=periodic).reshape(1, 3) + cog = r1.center_of_geometry().reshape(1, 3) d = distance_array(u.atoms.positions, cog, box=box) ref = set(np.where(d < 5.0)[0])