diff --git a/package/MDAnalysis/analysis/contacts.py b/package/MDAnalysis/analysis/contacts.py index a39ad96138d..a1aecb276a0 100644 --- a/package/MDAnalysis/analysis/contacts.py +++ b/package/MDAnalysis/analysis/contacts.py @@ -172,6 +172,7 @@ import MDAnalysis.lib.distances from MDAnalysis.lib.util import openany from MDAnalysis.analysis.distances import distance_array +from MDAnalysis.core.AtomGroup import AtomGroup from .base import AnalysisBase logger = logging.getLogger("MDAnalysis.analysis.contacts") @@ -342,14 +343,14 @@ def __init__(self, u, selection, refgroup, method="cutoff", radius=4.5, self.r0 = [] self.initial_contacts = [] - if isinstance(refgroup[0], mda.AtomGroup.AtomGroup): + if isinstance(refgroup[0], AtomGroup): refA, refB = refgroup self.r0.append(distance_array(refA.positions, refB.positions)) - self.initial_contacts.append(contact_matrix(self.r0, radius)) + self.initial_contacts.append(contact_matrix(self.r0[-1], radius)) else: for refA, refB in refgroup: self.r0.append(distance_array(refA.positions, refB.positions)) - self.initial_contacts.append(contact_matrix(self.r0, radius)) + self.initial_contacts.append(contact_matrix(self.r0[-1], radius)) self.fraction_kwargs = kwargs self.timeseries = [] @@ -366,6 +367,8 @@ def _single_frame(self): r0 = r0[initial_contacts] y[i] = self.fraction_contacts(r, r0, **self.fraction_kwargs) + if len(y) == 1: + y = y[0] self.timeseries.append((self._ts.frame, y)) def save(self, outfile): diff --git a/testsuite/MDAnalysisTests/analysis/test_contacts.py b/testsuite/MDAnalysisTests/analysis/test_contacts.py index 6a78949e98b..0468c2d1f41 100644 --- a/testsuite/MDAnalysisTests/analysis/test_contacts.py +++ b/testsuite/MDAnalysisTests/analysis/test_contacts.py @@ -199,5 +199,5 @@ def test_villin_unfolded(): method="soft_cut") q.run() - results = zip(*soft_cut(f, u, sel, sel)) [1] + results = zip(*soft_cut(f, u, sel, sel))[1] assert_almost_equal(zip(*q.timeseries)[1], results)