class ElementalCompositionVisit: def __init__(self,comp): self.table = comp self.eltcomp = Composition() def visit(self,m): self.eltcomp.add(m.composition(self.table))
def visit(self,m): if self.comp: eltcomp = m.composition(self.comp) for c in m.children(): eltcomp.add(c._elemental_composition) m._elemental_composition = eltcomp if self.sym: symcomp = Composition() symcomp[self.sym.toStr(m)] = 1 for c in m.children(): symcomp.add(c._symbol_composition) m._symbol_composition = symcomp
def elemental_composition(self,comp_table): eltcomp = Composition() for m in self.all_nodes(undet_subst=True): ec = m.composition(comp_table) eltcomp.add(ec) return eltcomp