Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions package/MDAnalysis/core/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions testsuite/MDAnalysisTests/core/test_atomselections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand All @@ -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])

Expand Down Expand Up @@ -603,6 +603,12 @@ def test_cyzone(self, u, meth, periodic):

assert ref == set(result.indices)

@pytest.mark.parametrize('periodic,expected', ([True, 33], [False, 25]))
def test_sphzone(self, u, periodic, expected):
sel = u.select_atoms('sphzone 5.0 resid 1', periodic=periodic)

assert len(sel) == expected


class TestTriclinicDistanceSelections(BaseDistanceSelection):
@pytest.fixture()
Expand Down