#8924: Comparison between Sage and mpmath numbers is broken
---------------------------------+------------------------------------------
Reporter: fredrik.johansson | Owner: AlexGhitza
Type: defect | Status: new
Priority: major | Milestone:
Component: basic arithmetic | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
---------------------------------+------------------------------------------
Comparison between Sage and mpmath numbers works with mpmath numbers on
the left, but not on the right:
{{{
sage: mpmath.mpf(1) < 3
True
sage: 1 < mpmath.mpf(3)
False
sage: 4 == mpmath.mpf(4)
False
}}}
Found by Harald Schilly (see #8791).
This appears to be a bug in Sage (or Cython). Sage's numbers do the pure-
Python equivalent of not returning !NotImplemented when compared to
unrecognized types. For a minimal example:
{{{
sage: class X(object):
....: def __init__(self, v): self.v = v
....: def __lt__(self, other): return self.v < int(other)
....: def __gt__(self, other): return self.v > int(other)
....:
sage: X(1) < 3
True
sage: 1 < X(3)
False
sage: X(1) < int(3)
True
sage: int(1) < X(3)
True
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8924>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" 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/sage-trac?hl=en.