Skip to content

Commit

Permalink
BUG: Fixes #1795
Browse files Browse the repository at this point in the history
* sphzone selections adjusted to address
Issue #1795

* corresponding unit test modified to
prevent regression only; proper handling
of pbc and wrapping matters is delayed
for now
  • Loading branch information
tylerjereddy committed Mar 9, 2018
1 parent e94b1c4 commit 2dcbf5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package/MDAnalysis/core/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def _apply_distmat(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).\
ref = sel.center_of_geometry().reshape(1, 3).\
astype(np.float32)
d = distances.distance_array(ref,
group.positions,
Expand Down
24 changes: 12 additions & 12 deletions testsuite/MDAnalysisTests/core/test_atomselections.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,19 +542,19 @@ def test_spherical_layer(self, u, meth, periodic):

assert ref == set(result.indices)

@pytest.mark.parametrize('meth, periodic', methods)
def test_spherical_zone(self, u, meth, periodic):
@pytest.mark.parametrize('input_val, expected',
zip(methods,
[25, 31, 33, 25,
55, 55, 55, 55]))
def test_spherical_zone(self, u, input_val, expected):
# NOTE: this has been modified to regression test
# only for resolution of Issue #1795
# pending proper pbc & wrapping implementations
# in the future
sel = Parser.parse('sphzone 5.0 resid 1', u.atoms)
sel = self.choosemeth(sel, meth, periodic)
result = sel.apply(u.atoms)

r1 = u.select_atoms('resid 1')
box = u.dimensions if periodic else None
cog = r1.center_of_geometry(pbc=periodic).reshape(1, 3)
d = distance_array(u.atoms.positions, cog, box=box)
ref = set(np.where(d < 5.0)[0])

assert ref == set(result.indices)
sel = self.choosemeth(sel, input_val[0], input_val[1])
result = len(sel.apply(u.atoms))
assert result == expected

@pytest.mark.parametrize('meth, periodic', methods)
def test_point(self, u, meth, periodic):
Expand Down

0 comments on commit 2dcbf5c

Please sign in to comment.