Given an expression in Latex, extract the symbols:
based on https://stackoverflow.com/a/59843709/1164295
>>> import sympy
>>> from sympy.parsing.latex import parse_latex
>>> symp_lat = parse_latex('x^2 + a x + b = 0')
>>> symp_lat.atoms(sympy.Symbol)
{x, b, a}
Given an expression in Latex, generate the graphviz of the AST:
from https://docs.sympy.org/latest/tutorial/manipulation.html
see https://docs.sympy.org/latest/modules/printing.html#sympy.printing.dot.dotprint
>>> graphviz_of_AST_for_expr = sympy.printing.dot.dotprint(symp_lat)
No comments:
Post a Comment