Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison between Sage and mpmath numbers is broken #8924

Closed
fredrik-johansson opened this issue May 7, 2010 · 4 comments
Closed

Comparison between Sage and mpmath numbers is broken #8924

fredrik-johansson opened this issue May 7, 2010 · 4 comments

Comments

@fredrik-johansson
Copy link

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

Component: basic arithmetic

Reviewer: Jeroen Demeyer

Issue created by migration from https://trac.sagemath.org/ticket/8924

@mkoeppe
Copy link
Member

mkoeppe commented Aug 15, 2016

comment:1

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

@jdemeyer
Copy link

Reviewer: Jeroen Demeyer

@jdemeyer
Copy link

comment:2

I think this is fixed by #21163.

@embray
Copy link
Contributor

embray commented Aug 30, 2016

comment:3

Determined to be invalid/duplicate/wontfix (closing as "wontfix" as a catch-all resolution).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants