Skip to content

Commit 4d1e15b

Browse files
authored
Merge pull request #124 from ReactionMechanismGenerator/siblingTest
Make polycyclic pass sibling parent testing
2 parents 8d45eca + a75c106 commit 4d1e15b

2 files changed

Lines changed: 39 additions & 31 deletions

File tree

input/thermo/groups/polycyclic.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8480,6 +8480,20 @@
84808480
tree(
84818481
"""
84828482
L1: PolycyclicRing
8483+
L2: s2-3_5_5_5_ane
8484+
L2: s2-3_5d1_5_5_ene
8485+
L2: s2-3f0_5_5_5_ane
8486+
L2: s2-3f1_6_5_5_ane
8487+
L2: s2-3_5_5_5d1_ene
8488+
L2: s3-3_5_6_5_ane
8489+
L2: s2-4f1_5_6_7_ane
8490+
L2: s2-4f2_5_6_8_ane
8491+
L2: s2-2f1_5_5_2_ane
8492+
L2: s2-3f1_5_5_6_ane
8493+
L2: s2-4f0_5_5_6_ane
8494+
L2: s2-4f1_5_5_7_ane
8495+
L2: s4-3f1_6_6_6_ane
8496+
L2: s3-3f1_6_5_6_ane
84838497
L2: s1_3_3
84848498
L3: s1_3_3_ane
84858499
L3: s1_3_3_ene
@@ -8581,9 +8595,9 @@
85818595
L2: s2_3_5
85828596
L3: s2_3_5_ane
85838597
L3: s2_3_5_ene
8584-
L4: s2_3_5_ene_1
8585-
L4: s2_3_5_ene_side
85868598
L4: s2_3_5_ene_1_side
8599+
L4: s2_3_5_ene_1
8600+
L4: s2_3_5_ene_side
85878601
L2: s2_3_6
85888602
L3: s2_3_6_ane
85898603
L3: s2_3_6_ene
@@ -8811,20 +8825,6 @@
88118825
L4: s4_6_8_ene_7
88128826
L3: s4_6_8_diene
88138827
L4: s4_6_8_diene_7_9
8814-
L2: s2-3_5_5_5_ane
8815-
L2: s2-3_5d1_5_5_ene
8816-
L2: s2-3f0_5_5_5_ane
8817-
L2: s2-3f1_6_5_5_ane
8818-
L2: s2-3_5_5_5d1_ene
8819-
L2: s3-3_5_6_5_ane
8820-
L2: s2-4f1_5_6_7_ane
8821-
L2: s2-4f2_5_6_8_ane
8822-
L2: s2-2f1_5_5_2_ane
8823-
L2: s2-3f1_5_5_6_ane
8824-
L2: s2-4f0_5_5_6_ane
8825-
L2: s2-4f1_5_5_7_ane
8826-
L2: s4-3f1_6_6_6_ane
8827-
L2: s3-3f1_6_5_6_ane
88288828
"""
88298829
)
88308830

testing/databaseTest.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,11 @@ def test_thermo(self):
116116
self.compat_func_name = test_name
117117
yield test, group_name
118118

119-
if group_name != 'polycyclic':
120-
test = lambda x: self.general_checkSiblingsForParents(group_name, group)
121-
test_name = "Thermo groups {0}: sibling relationships are correct?".format(group_name)
122-
test.description = test_name
123-
self.compat_func_name = test_name
124-
yield test, group_name
119+
test = lambda x: self.general_checkSiblingsForParents(group_name, group)
120+
test_name = "Thermo groups {0}: sibling relationships are correct?".format(group_name)
121+
test.description = test_name
122+
self.compat_func_name = test_name
123+
yield test, group_name
125124

126125
test = lambda x: self.general_checkCdAtomType(group_name, group)
127126
test_name = "Thermo groups {0}: Cd atomtype used correctly?".format(group_name)
@@ -323,6 +322,9 @@ def kinetics_checkChildParentRelationships(self, family_name):
323322
def kinetics_checkSiblingsForParents(self, family_name):
324323
"""
325324
This test checks that siblings in a tree are not actually parent/child
325+
326+
See general_checkSiblingsForParents comments for more detailed description
327+
of the test.
326328
"""
327329
from rmgpy.data.base import Database
328330
originalFamily = self.database.kinetics.families[family_name]
@@ -335,12 +337,8 @@ def kinetics_checkSiblingsForParents(self, family_name):
335337
if node in originalFamily.forwardTemplate.products: continue
336338
for index, child1 in enumerate(node.children):
337339
for child2 in node.children[index+1:]:
338-
#Don't check a node against itself
339-
if child1 is child2: continue
340340
nose.tools.assert_false(family.matchNodeToChild(child1, child2),
341341
"In family {0}, node {1} is a parent of {2}, but they are written as siblings.".format(family_name, child1, child2))
342-
nose.tools.assert_false(family.matchNodeToChild(child2, child1),
343-
"In family {0}, node {1} is a parent of {2}, but they are written as siblings.".format(family_name, child2, child1))
344342

345343
def kinetics_checkAdjlistsNonidentical(self, database):
346344
"""
@@ -495,17 +493,27 @@ def general_checkChildParentRelationships(self, group_name, group):
495493

496494
def general_checkSiblingsForParents(self, group_name, group):
497495
"""
498-
This test checks that siblings in a tree are not actually parent/child
496+
This test checks that siblings in a tree are not actually parent/child.
497+
498+
For example in a tree:
499+
500+
L1. A
501+
L2. B
502+
L2. C
503+
504+
This tests that C is not a child of B, which would make C inaccessible because
505+
we always match B first.
506+
507+
We do not check that B is not a child of C becausethat does not cause accessibility
508+
problems and may actually be necessary in some trees. For example, in the polycyclic
509+
thermo groups B might be a tricyclic and C a bicyclic parent. Currently there is no
510+
way to writes a bicyclic group that excludes an analogous tricyclic.
499511
"""
500512
for nodeName, node in group.entries.iteritems():
501513
for index, child1 in enumerate(node.children):
502514
for child2 in node.children[index+1:]:
503-
#Don't check a node against itself
504-
if child1 is child2: continue
505515
nose.tools.assert_false(group.matchNodeToChild(child1, child2),
506516
"In {0} group, node {1} is a parent of {2}, but they are written as siblings.".format(group_name, child1, child2))
507-
nose.tools.assert_false(group.matchNodeToChild(child2, child1),
508-
"In {0} group, node {1} is a parent of {2}, but they are written as siblings.".format(group_name, child2, child1))
509517

510518
def general_checkCdAtomType(self, group_name, group):
511519
"""

0 commit comments

Comments
 (0)