On Fri, May 1, 2009 at 7:45 AM, mabshoff <mabsh...@googlemail.com> wrote: > > > > On May 1, 7:38 am, kcrisman <kcris...@gmail.com> wrote: >> > > sage: P>x^2+x >> > > Expected: >> > > True >> > > Got: >> > > False >> >> Yes, I just added that test to show that Primes() has comparison. I >> was a little surprised to see the result, but it passed testing, so...
You should change the doctest to sage: P != x^2 + x True The comparison is completely arbitrary and will be machine specific. However equality or not is not arbitrary. William >> >> If someone posts a ticket with a suggested fix that makes Primes() >> greater than everything, I can try to implement it - I but for now I >> just wanted to make sure it was clear Primes() did compare to weird >> things and not throw an error. > > Well, what I wrote was nonsense. __cmp__ always returns -1 unless both > are Primes(), i.e what is greater depends on what is left and right > respectively. I don't care too much about that now, but if someone has > a better suggestion I am interested in hearing it. > >> Note in the docstring for comparing (current) symbolics that >> Some comparisons are fairly arbitrary but >> consistent:: sage: cmp(SR(3), x) #random due to >> architecture dependence -1 sage: cmp(x, SR(3)) >> #random due to architecture dependence 1 """ >> so perhaps it's not a Maxima thing but a symbolic comparison thing. > > Never write a doctest to be #random if you can trivially work around > it. In both cases the point is that cmp() should not return "0" since > x and SR(3) aren't equal. Should that ever be broken the doctest would > not catch it, so something like > > sage: cmp(SR(3), x) in [-1,1] > True > > is much better in that case. > >> - kcrisman > > Cheers, > > Michael > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---