The order of .args and the printing order are completely different
things. They happen to be the same in this case because there are only
two possibilities.

Getting that you are only interested in the printer, you should just
sort there. A canonical sort is sort(key=default_sort_key).

I hope this helps. If not please give more details on what tests are failing.

Aaron Meurer


On Fri, Jan 17, 2014 at 7:47 AM, Björn Dahlgren <bjo...@gmail.com> wrote:
> As I am working on getting tests to pass for a workaround
> (https://github.com/sympy/sympy/pull/2780#issuecomment-32575929)
>
> I have run into the following problem:
>
>     In [10]: a=sympy.Idx('a')
>
>     In [11]: b=sympy.Symbol('b')
>
>     In [12]: a*b
>     Out[12]: b*a
>
> How would you go about to make args of the mul object be alphabetical?
>
>     In [13]: m=a*b
>
>     In [14]: m.args
>     Out[14]: (b, a)
>
> i.e. how do we get Out[14]: (a, b)
> ?
>
> I tried adding this to the Idx class in tensor/indexed.py
>
>     @cacheit
>     def sort_key(self, order=None):
>         return self.class_key(), (1, (str(self.label),)), S.One.sort_key(),
> S.One
>
> But it didn't help. Any suggestions?
>
> Best regards,
> /Björn
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to