Skip to content

Commit c9616d0

Browse files
committed
Modified sibling/parent check to only test for children in one direction
It is not a problem if siblings have a children/parent relationship as long as the child is placed before the parent. The previous test was too restrictive causing problems for the trees in the polycyclic thermo groups.
1 parent c4de9ce commit c9616d0

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

testing/databaseTest.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ def kinetics_checkChildParentRelationships(self, family_name):
323323
def kinetics_checkSiblingsForParents(self, family_name):
324324
"""
325325
This test checks that siblings in a tree are not actually parent/child
326+
327+
See general_checkSiblingsForParents comments for more detailed description
328+
of the test.
326329
"""
327330
from rmgpy.data.base import Database
328331
originalFamily = self.database.kinetics.families[family_name]
@@ -335,12 +338,8 @@ def kinetics_checkSiblingsForParents(self, family_name):
335338
if node in originalFamily.forwardTemplate.products: continue
336339
for index, child1 in enumerate(node.children):
337340
for child2 in node.children[index+1:]:
338-
#Don't check a node against itself
339-
if child1 is child2: continue
340341
nose.tools.assert_false(family.matchNodeToChild(child1, child2),
341342
"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))
344343

345344
def kinetics_checkAdjlistsNonidentical(self, database):
346345
"""
@@ -495,17 +494,27 @@ def general_checkChildParentRelationships(self, group_name, group):
495494

496495
def general_checkSiblingsForParents(self, group_name, group):
497496
"""
498-
This test checks that siblings in a tree are not actually parent/child
497+
This test checks that siblings in a tree are not actually parent/child.
498+
499+
For example in a tree:
500+
501+
L1. A
502+
L2. B
503+
L2. C
504+
505+
This tests that C is not a child of B, which would make C inaccessible because
506+
we always match B first.
507+
508+
We do not check that B is not a child of C becausethat does not cause accessibility
509+
problems and may actually be necessary in some trees. For example, in the polycyclic
510+
thermo groups B might be a tricyclic and C a bicyclic parent. Currently there is no
511+
way to writes a bicyclic group that excludes an analogous tricyclic.
499512
"""
500513
for nodeName, node in group.entries.iteritems():
501514
for index, child1 in enumerate(node.children):
502515
for child2 in node.children[index+1:]:
503-
#Don't check a node against itself
504-
if child1 is child2: continue
505516
nose.tools.assert_false(group.matchNodeToChild(child1, child2),
506517
"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))
509518

510519
def general_checkCdAtomType(self, group_name, group):
511520
"""

0 commit comments

Comments
 (0)