Hello.

It should be fairly easy to transform the sympy output into a Graphviz file.


*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French teacher of **math** in a high school **and **amateur **Python *
*developer*

2016-04-06 23:32 GMT+02:00 Nathan Goldbaum <[email protected]>:

>
>
> On Wed, Apr 6, 2016 at 4:09 PM, Nathan Hayden <[email protected]>
> wrote:
>
>> Hi, I'm new to SymPy, but I'm using it to do some simple things already.
>>
>> I'm wondering, can I feed SymPy an expression and get a tree
>> representation back showing me the order of operations used to evaluate the
>> expression?  I know this is all handled under the hood, but I don't know if
>> it's exposed.
>>
>>
>> For example, for the expression:   4 * 5 + 6 * (1 + 2)
>>
>> I'd like to get something like:
>>
>>                        +
>>                     /      \
>>                   *         *
>>                /    \     /    \
>>              4     5   6      +
>>                                 /  \
>>                               1    2
>>
>> Is this a thing?
>>
>
> from sympy.printing.tree import print_tree
> from sympy import S
>
> print_tree(S(' 4 * 5 + 6 * (1 + 2)', evaluate=False))
>
> I'm not sure there's a way to make it print like you want, but you should
> be able to whip something up following this:
>
> http://docs.sympy.org/latest/tutorial/manipulation.html
>
> (particularly the bits toward the bottom).
>
> -Nathan
>
>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/sympy.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/90597353-0ff0-42c8-a554-59f4b069cba2%40googlegroups.com
>> <https://groups.google.com/d/msgid/sympy/90597353-0ff0-42c8-a554-59f4b069cba2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/CAJXewOnEcLhWZqJWEzAq78Y4hHhmfFfkD%3DHpU_w0BKmZgWi8MA%40mail.gmail.com
> <https://groups.google.com/d/msgid/sympy/CAJXewOnEcLhWZqJWEzAq78Y4hHhmfFfkD%3DHpU_w0BKmZgWi8MA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAAb4jGnTidRnOFb%3DB9_WbMM551Cuo9NwwefqF0Ky4kr9aTaVTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to