Skip to content

Commit

Permalink
Merge pull request #124 from ReactionMechanismGenerator/siblingTest
Browse files Browse the repository at this point in the history
Make polycyclic pass sibling parent testing
  • Loading branch information
nyee authored Aug 23, 2016
2 parents 8d45eca + a75c106 commit 4d1e15b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
32 changes: 16 additions & 16 deletions input/thermo/groups/polycyclic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8480,6 +8480,20 @@
tree(
"""
L1: PolycyclicRing
L2: s2-3_5_5_5_ane
L2: s2-3_5d1_5_5_ene
L2: s2-3f0_5_5_5_ane
L2: s2-3f1_6_5_5_ane
L2: s2-3_5_5_5d1_ene
L2: s3-3_5_6_5_ane
L2: s2-4f1_5_6_7_ane
L2: s2-4f2_5_6_8_ane
L2: s2-2f1_5_5_2_ane
L2: s2-3f1_5_5_6_ane
L2: s2-4f0_5_5_6_ane
L2: s2-4f1_5_5_7_ane
L2: s4-3f1_6_6_6_ane
L2: s3-3f1_6_5_6_ane
L2: s1_3_3
L3: s1_3_3_ane
L3: s1_3_3_ene
Expand Down Expand Up @@ -8581,9 +8595,9 @@
L2: s2_3_5
L3: s2_3_5_ane
L3: s2_3_5_ene
L4: s2_3_5_ene_1
L4: s2_3_5_ene_side
L4: s2_3_5_ene_1_side
L4: s2_3_5_ene_1
L4: s2_3_5_ene_side
L2: s2_3_6
L3: s2_3_6_ane
L3: s2_3_6_ene
Expand Down Expand Up @@ -8811,20 +8825,6 @@
L4: s4_6_8_ene_7
L3: s4_6_8_diene
L4: s4_6_8_diene_7_9
L2: s2-3_5_5_5_ane
L2: s2-3_5d1_5_5_ene
L2: s2-3f0_5_5_5_ane
L2: s2-3f1_6_5_5_ane
L2: s2-3_5_5_5d1_ene
L2: s3-3_5_6_5_ane
L2: s2-4f1_5_6_7_ane
L2: s2-4f2_5_6_8_ane
L2: s2-2f1_5_5_2_ane
L2: s2-3f1_5_5_6_ane
L2: s2-4f0_5_5_6_ane
L2: s2-4f1_5_5_7_ane
L2: s4-3f1_6_6_6_ane
L2: s3-3f1_6_5_6_ane
"""
)

38 changes: 23 additions & 15 deletions testing/databaseTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ def test_thermo(self):
self.compat_func_name = test_name
yield test, group_name

if group_name != 'polycyclic':
test = lambda x: self.general_checkSiblingsForParents(group_name, group)
test_name = "Thermo groups {0}: sibling relationships are correct?".format(group_name)
test.description = test_name
self.compat_func_name = test_name
yield test, group_name
test = lambda x: self.general_checkSiblingsForParents(group_name, group)
test_name = "Thermo groups {0}: sibling relationships are correct?".format(group_name)
test.description = test_name
self.compat_func_name = test_name
yield test, group_name

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

def kinetics_checkAdjlistsNonidentical(self, database):
"""
Expand Down Expand Up @@ -495,17 +493,27 @@ def general_checkChildParentRelationships(self, group_name, group):

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

def general_checkCdAtomType(self, group_name, group):
"""
Expand Down

0 comments on commit 4d1e15b

Please sign in to comment.