Skip to content
Snippets Groups Projects
Commit 52f23554 authored by James Graham's avatar James Graham
Browse files

Add proper error message if atom is defined multiple times in a single bond

Add test file required for previous commit
parent e41e36b1
No related branches found
No related tags found
No related merge requests found
......@@ -147,6 +147,10 @@ class BondSet:
func_form = functional_forms[atomlist[-1]]
except AttributeError:
func_form = self._functional_forms[len(atomlist)]
if {x for x in atomlist if atomlist.count(x) > 1}:
raise ValueError("Defined bond '{0}' contains duplicate atoms".format(atomlist))
mol_bonds.append(Bond(atoms=atomlist, func_form=func_form))
if len(atomlist) > 2:
angles_defined = True
......
[test]
A1 A2
A2 A2
hello
I have no sections
This is wrong
......@@ -195,3 +195,7 @@ class BondSetTest(unittest.TestCase):
logging.disable(logging.NOTSET)
self.assertTrue(cmp_whitespace_float("sugar_out.itp", "test/data/sugar_out.itp", float_rel_error=0.001))
def test_duplicate_atoms_in_bond(self):
with self.assertRaises(ValueError):
bondset = BondSet("test/data/duplicate_atoms.bnd", DummyOptions)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment