On Tue, Jun 19, 2012 at 11:51 AM, Tom Bachmann <[email protected]> wrote:
> The problem seems to rather be that FiniteSet does not print canonically.

Indeed, those failures are related to how FiniteSet orders its
elements.

> On 19.06.2012 09:44, Aaron Meurer wrote:
>>
>> We used to have this problem a lot, but then we made all printing
>> ordering canonical with sort_key. I suppose you should make sure that
>> the new category theory class printers use this.

>From what I can see in FiniteSet.__new__, FiniteSet always sorts its
elements with element_sort_fn which is defined just above the
definition of FiniteSet:

def element_sort_fn(x):
    try:
        if x.is_comparable is True:
            return x
    except:
        pass
    return 1e9+abs(hash(x))

>From what I can see in StrPrinter._print_FiniteSet, no sort_key
function is involved when printing the elements of a FiniteSet.

Apparently, since is_comparable is not set for the objects of the
classes in sympy.categories.baseclasses, element_sort_fn(x) falls back
to the last line, which, I guess, is somewhat architecture and
a-lot-of-stuff dependent (at least because of the large float 1e9).

Sergiu

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to