Suggestion in Issue #12052 (Better input validation for nsolve)

26 views
Skip to first unread message

Mohit Raj

unread,
Jan 25, 2017, 1:15:58 PM1/25/17
to sympy
Hey all,
I would like to have any valuable suggestions on this code below.
It is maintaining order of variables. I think preorder_traversal would also work.
Kindly do give suggestions on this.

if fargs is None:
            fargs = [ ]
            seen = [ ]
            out = [ ]   
            for i in f:
                temp = i.as_ordered_terms()
                for j in temp:
                    if(isinstance(j,Symbol)):
                        out.append(j)
        for m in out:
            if m not in seen:
                fargs.append(m)
                seen.append(m)

Aaron Meurer

unread,
Jan 25, 2017, 2:03:38 PM1/25/17
to sy...@googlegroups.com
It is possible to canonically order Symbols, but that order is
completely arbitrary, and might not be what the user expects. It's
best to require the user to specify the symbol order, so there is no
ambiguity.

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> 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/aebf0986-021b-4774-8c8a-a946d3d4f11a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages