Inconsistency between display and comparison on unevaluated operators

40 views
Skip to first unread message

Duane Nykamp

unread,
Apr 30, 2014, 2:53:50 AM4/30/14
to sy...@googlegroups.com
I really like how unevaluated operators are working.  However, one confusing aspect is that, on display, the operands are reordered to some standard order, but on comparison, the operator order matters.

n [3]: Add(3,2,evaluate=False)
Out[3]: 2 + 3

In [4]: Add(2,3,evaluate=False)
Out[4]: 2 + 3

In [5]: Add(3,2,evaluate=False) == Add(2,3,evaluate=False)
Out[5]: False


Is it possible to make the comparison use the same scheme as the display?  It is confusing to get results that 2+3 is not the same as 2+3.

Duane

F. B.

unread,
Apr 30, 2014, 3:40:16 AM4/30/14
to sy...@googlegroups.com
I think it's a problem with the printer:

In [1]: a = Add(3, 2, evaluate=False)

In [2]: a.args
Out[2]: (3, 2)

In [3]: a
Out[3]: 2 + 3

The args are created in the correct order, it's the printer that apparently reorders the values. The structural equality is False because (2, 3) is not the same as (3, 2), and that sounds correct. Use Eq( , ) for mathematical equalities.

Aaron Meurer

unread,
Apr 30, 2014, 12:34:03 PM4/30/14
to sy...@googlegroups.com
Eq is a mathematical equality, but it's also unevaluated, so that
doesn't really help.

This is just a bug in the printer. It should not sort the args on
unevaluated Add. Is there a way to detect that an Add was created with
evaluate=False?

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 http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/5b68d3eb-3432-4b53-8288-2a892dba49b5%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages