diff --git a/AUTHORS b/AUTHORS index 8c220340..0acf2990 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,3 +33,9 @@ their first commit. GitHub handle is optional. ---- - Alia Lescoulie (ALescoulie) + +2022 +---- + +- Cade Duckworth (cadeduckworth) + diff --git a/CHANGES b/CHANGES index 4c8b4dec..4be47269 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,14 @@ CHANGES for MDPOW Add summary of changes for each release. Use ISO dates. Reference GitHub issues numbers and PR numbers. +2022-??-?? 0.8.1 +cadeduckworth + +Fixes + +* fix ensemble.EnsembleAnalysis.check_groups_from_common_ensemble (#212) + + 2021-01-03 0.8.0 ALescoulie, orbeckst diff --git a/mdpow/analysis/ensemble.py b/mdpow/analysis/ensemble.py index 00dfbd27..bc75f012 100644 --- a/mdpow/analysis/ensemble.py +++ b/mdpow/analysis/ensemble.py @@ -542,11 +542,13 @@ def check_groups_from_common_ensemble(groups: List[EnsembleAtomGroup]): in memory. If two :class:`~mdpow.analysis.ensemble.EnsembleAtomGroup` object don't have a common :class:`~mdpow.analysis.ensemble.Ensemble` :class:`ValueError` is raised.""" - for i in range((len(groups) - 1) // 2): - # Checking if EnsembleAtomGroup.ensemble references same object in memory - if groups[i].ensemble is not groups[-1 - i]: - msg = '''Dihedral selections from different Ensembles, - ensure that all EnsembleAtomGroups are created - from the same Ensemble.''' - logger.error(msg) - raise ValueError(msg) + for i in range(len(groups) - 1): + for j in range(i + 1, len(groups)): + # Checking if EnsembleAtomGroup.ensemble references same object in memory + if groups[i].ensemble is not groups[j].ensemble: + msg = ('Dihedral selections from different Ensembles, ' + 'ensure that all EnsembleAtomGroups are created ' + 'from the same Ensemble. ' + f'mismatch: group[{i}].ensemble != group[{j}].ensemble') + logger.error(msg) + raise ValueError(msg) diff --git a/mdpow/tests/test_dihedral.py b/mdpow/tests/test_dihedral.py index 0b2c4aab..c54a110c 100644 --- a/mdpow/tests/test_dihedral.py +++ b/mdpow/tests/test_dihedral.py @@ -81,3 +81,12 @@ def test_results_recursive2(self): assert_almost_equal(self.DG48910_var, dh1_var, 6) assert_almost_equal(self.DG491011_mean, dh2_mean, 6) assert_almost_equal(self.DG491011_var, dh2_var, 6) + + def test_ValueError_different_ensemble(self): + other = Ensemble(dirname=self.tmpdir.name, solvents=['water']) + dh1 = self.Ens.select_atoms('name C11 or name C10 or name C9 or name C4') + dh2 = other.select_atoms('name C8 or name C4 or name C9 or name C10') + with pytest.raises(ValueError, + match='Dihedral selections from different Ensembles, '): + DihedralAnalysis([dh1, dh2]) +