Opened 12 years ago
Closed 5 years ago
#8924 closed defect (wontfix)
Comparison between Sage and mpmath numbers is broken
Reported by: | fredrik.johansson | Owned by: | AlexGhitza |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | basic arithmetic | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | Jeroen Demeyer | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
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
Change History (3)
comment:1 Changed 5 years ago by
- Milestone set to sage-duplicate/invalid/wontfix
- Status changed from new to needs_review
comment:2 Changed 5 years ago by
- Reviewers set to Jeroen Demeyer
- Status changed from needs_review to positive_review
I think this is fixed by #21163.
comment:3 Changed 5 years ago by
- Resolution set to wontfix
- Status changed from positive_review to closed
Determined to be invalid/duplicate/wontfix (closing as "wontfix" as a catch-all resolution).
Note: See
TracTickets for help on using
tickets.
The tests from the description work as of 7.4.beta0.