Comment #18 on issue 1467 by asmeurer: sorting values with imaginary numbers in radical http://code.google.com/p/sympy/issues/detail?id=1467
I tried a bunch of commits all the way back to the first one in the repository, and they all give: In [1]: sorted([3,I]) Out[1]: [3, I] So I think that the problem was probably intermittent, or else it was machine/python version dependent. As for what we should do, I think it should be similar to what Python does: >>> sorted([3, 1j]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: no ordering relation is defined for complex numbers I don't know how sorted works, but would it be possible to not allow non-real objects to be compared but still allow lists of SymPy objects to be sorted in some kind of canonical way? This touches on another problem in SymPy that I have often noticed. Inequalities are used both as relationals and for some kind of canonical sorting (based on hashes for non-numbers I think). This means that if an algorithm wants to know which of two numbers are larger, it might try to compare them, even though one or both of the "numbers" could be a Symbol or a complex number or something else for which that doesn't make any sense. For example: In [6]: type(x<y) Out[6]: <class 'sympy.core.relational.StrictInequality'> In [7]: bool(x<y) Out[7]: True If we are going to make < a shortcut for the StrictInequality class, then it needs to not allow boolean conversion for things that can't be converted to booleans. Otherwise, we should make it like Equality and == where one is a class to hold equalities and the other does strict Python object comparison. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-issues" 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-issues?hl=en -~----------~----~----~----~------~----~------~--~---
