On Tue, Jun 19, 2012 at 11:51 AM, Tom Bachmann <
e_m...@web.de> 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