Issue 1170: problem with printing in 2.6
http://code.google.com/p/sympy/issues/detail?id=1170
Comment #2 by ondrej.certik:
Uff, I found the bug. What an ugly piece of code. :(
See for yourself. Apply this patch:
diff --git a/sympy/core/basic.py b/sympy/core/basic.py
index 75d7561..96de00d 100644
--- a/sympy/core/basic.py
+++ b/sympy/core/basic.py
@@ -460,6 +460,7 @@ class Basic(AssumeMeths):
# all redefinitions of __cmp__ method should start with the
# following three lines:
if self is other: return 0
+ print self.__class__, other.__class__
c = cmp(self.__class__, other.__class__)
if c: return c
#
and run this:
from sympy import *
print Basic.compare(S(1), S(3))
you'll get:
$ python2.5 r.py
<class 'sympy.core.numbers.One'> <class 'sympy.core.numbers.Integer'>
-1
$ python2.6 r.py
<class 'sympy.core.numbers.One'> <class 'sympy.core.numbers.Integer'>
1
So comparing integers 1 and 3 using Basic.compare is equal to the result of
cmp(One,
Integer), which is the same as "One < Integer"...
Which is ok, the docstring of Basic.compare says:
Return -1,0,1 if the object is smaller, equal, or greater than other
(not always in mathematical sense).
Anyways, the attached patch fixes it. It fails couple tests, but the tests
were
wrong, so they should be fixed.
Attachments:
0001-Fixes-a-Basic.compare_pretty-bug-1170.patch 1.3 KB
Issue attribute updates:
Status: Started
Labels: Milestone-Release0.6.3
--
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
-~----------~----~----~----~------~----~------~--~---