Skip to content

Commit 08bc181

Browse files
committed
Add test_deterministic_bicyclic_decomposition
Test that the decomposition of a polyring into bicyclics and then into single rings is deterministic. This is important because the thermo estimation depends on the order of the rings. Currently this is not guaranteed, so if this test fails, we just skip it. See #2562
1 parent 37ca456 commit 08bc181

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/rmgpy/data/thermoTest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,32 @@ def test_bicyclic_decomposition_for_polyring_using_alkane_tricyclic(self):
22722272
expected_aromatic_bond_num_in_bicyclics = [0, 0, 0]
22732273
assert aromatic_bond_num_in_bicyclics == expected_aromatic_bond_num_in_bicyclics
22742274

2275+
def test_deterministic_bicyclic_decomposition(self):
2276+
"""
2277+
Test that the decomposition of a polyring into bicyclics and then into single rings
2278+
is deterministic. This is important because the thermo estimation depends on the
2279+
order of the rings. Currently this is not guaranteed, so if this test fails, we
2280+
just skip it.
2281+
2282+
See https://github.com/ReactionMechanismGenerator/RMG-Py/issues/2562
2283+
"""
2284+
mol = Molecule(smiles="C1=CC2C=CC=1C=C2")
2285+
polyrings = mol.get_disparate_cycles()[1]
2286+
assert len(polyrings) == 1
2287+
assert rmgpy.data.thermo.is_bicyclic(polyrings[0])
2288+
polyring = polyrings[0]
2289+
submol = rmgpy.data.thermo.convert_ring_to_sub_molecule(polyring)[0]
2290+
rings = rmgpy.data.thermo.split_bicyclic_into_single_rings(submol)
2291+
assert len(rings) == 2
2292+
ring_smiles = [ring.to_smiles() for ring in rings]
2293+
for smiles in ring_smiles:
2294+
assert smiles in ["C1C=CC=C=C1", "C1C=CCC=C1"]
2295+
# Ensure that the order is the same every time
2296+
try:
2297+
assert ring_smiles == ["C1C=CC=C=C1", "C1C=CCC=C1"]
2298+
except AssertionError as e:
2299+
pytest.skip(f"Skipping because not yet deterministic (#2562): {e}")
2300+
22752301
def test_combine_cycles(self):
22762302
"""
22772303
This method tests the combine_cycles method, which simply joins two lists

0 commit comments

Comments
 (0)