MCPcopy Create free account
hub / github.com/Cantera/cantera / check_dot

Method check_dot

test/python/test_kinetics.py:744–784  ·  view source on GitHub ↗
(self, gas, diagram, element)

Source from the content-addressed store, hash-verified

742 return gas
743
744 def check_dot(self, gas, diagram, element):
745 diagram.label_threshold = 0
746 diagram.threshold = 0
747 dot = diagram.get_dot()
748 dot = dot.replace('\n', '')
749 nodes1 = set()
750 nodes2 = set()
751 species = set()
752 for line in dot.split(';'):
753 m = re.match(r'(.*)\[(.*)\]', line)
754 if not m:
755 continue
756 A, B = m.groups()
757 if '->' in A:
758 # edges
759 nodes1.update(s.strip() for s in A.split('->'))
760 else:
761 # nodes
762 nodes2.add(A.strip())
763 spec = re.search('label="(.*?)"', B).group(1)
764 assert spec not in species
765 species.add(spec)
766
767 # Make sure that the output was actually parsable and that we
768 # found some nodes
769 assert nodes1
770 assert species
771
772 # All nodes should be connected to some edge (this does not
773 # require the graph to be connected)
774 assert nodes1 == nodes2
775
776 # All of the species in the graph should contain the element whose
777 # flux we're looking at
778 for spec in species:
779 assert gas.n_atoms(spec, element) > 0
780
781 # return fluxes from the dot file for further tests
782 return [float(re.search('label *= *"(.*?)"', line).group(1))
783 for line in dot.split(';')
784 if line.startswith('s') and 'arrowsize' in line]
785
786 def get_fluxes(self, diagram):
787 directional = {}

Callers 4

test_dot_net_unscaledMethod · 0.95

Calls 4

replaceMethod · 0.80
splitMethod · 0.80
updateMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected