@@ -2102,11 +2102,11 @@ def test_is_bicyclic1(self):
21022102 The test molecule is bicyclic, we expect is_bicyclic()
21032103 returns True.
21042104 """
2105- smiles = "C1=CCC2C1=C2"
2106- mol = Molecule ().from_smiles (smiles )
2107- polyring = mol .get_disparate_cycles ()[1 ][ 0 ]
2108-
2109- assert is_bicyclic (polyring )
2105+ for smiles in [ "C1=CCC2C1=C2" , "C1=CC2C=CC1=CC2" , "C1=CC2C=CC=1C=C2" ]:
2106+ mol = Molecule ().from_smiles (smiles )
2107+ polyrings = mol .get_disparate_cycles ()[1 ]
2108+ assert len ( polyrings ) == 1
2109+ assert is_bicyclic (polyrings [ 0 ] )
21102110
21112111 def test_is_bicyclic2 (self ):
21122112 """
@@ -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