On Sat, Feb 17, 2018 at 8:22 AM, Ralf Stephan <[email protected]> wrote: > I'm afraid the issue is more complicated. > > On Friday, February 16, 2018 at 5:04:30 PM UTC+1, Erik Bray wrote: >> >> On Python 2 this works: >> >> sage: bool(pi <= pi) >> True >> >> This works fine because the Constant class implements __eq__, and so >> if asking if pi <= pi that's good enough for it. > > > Actually Constants.__eq__ is never called here. Pi is an expression not a > constant. With expression relations ultimately Expression.__nonzero__ does > all the work. It calls OP(pi.pyobject(), pi.pyobject()) with OP = > operator.le. This calls Expression._richcmp_(pi, pi, Py_LT) (why?) which > consults Pynac. Pynac checks if LHS-RHS is trivially zero which it is and > returns True. No floating point involved, just symbolics.
Right, but pi.pyobject() is sage.symbolic.constants.Pi, a subclass of Constant, so this invokes Constant.__le__ (when we call __nonzero__) which isn't defined on Python 3 (on Python 2 it has a default implementation that first checks equality at least, and then falls back on a nonsensical < implementation). -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
