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:

Status badges


Comparison between Sage and mpmath numbers works with mpmath numbers on the left, but not on the right:

sage: mpmath.mpf(1) < 3
sage: 1 < mpmath.mpf(3)
sage: 4 == mpmath.mpf(4)

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
sage: 1 < X(3)
sage: X(1) < int(3)
sage: int(1) < X(3)

Change History (3)

comment:1 Changed 5 years ago by mkoeppe

  • Milestone set to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

The tests from the description work as of 7.4.beta0.

comment:2 Changed 5 years ago by jdemeyer

  • 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 embray

  • 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.