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

Rational(numpy.int64(1), 2)) fails on Python 3: TypeError: invalid input: 1 #13618

Closed
nschloe opened this issue Nov 17, 2017 · 4 comments
Closed
Labels

Comments

@nschloe
Copy link
Contributor

nschloe commented Nov 17, 2017

MWE:

import numpy
import sympy

sympy.Rational(numpy.int64(1), 2)

This fails with

[...]
/usr/lib/python3/dist-packages/sympy/core/numbers.py in __new__(cls, p, q, gcd)
   1483 
   1484             if not isinstance(p, SYMPY_INTS + (Rational,)):
-> 1485                 raise TypeError('invalid input: %s' % p)
   1486             q = q or S.One
   1487             gcd = 1

TypeError: invalid input: 1

on Python 3, SymPy 1.1.1.

Also failing:

  • numpy.int32

Working:

  • Anything on Python 2.
  • numpy.int
nschloe added a commit to sigma-py/quadpy that referenced this issue Nov 17, 2017
nschloe added a commit to sigma-py/orthopy that referenced this issue Nov 24, 2017
@abhigyank
Copy link
Contributor

There seems to be no update on this issue since 1 month, so I am taking this up. No update on PR #13670 from 1 month as well.

@nschloe
Copy link
Contributor Author

nschloe commented Jan 12, 2018

Not sure if this is the same issue:

from mpmath import mp
import numpy

mp.sqrt(numpy.int64(1))

fails with

TypeError: cannot create mpf from 1

under Python 3. Should I file a new bug for this?

@normalhuman
Copy link
Contributor

I think you should file an issue at https://github.com/fredrik-johansson/mpmath/issues since it does not involve SymPy. mpmath is not a part of SymPy, it's just a dependency.

@oscarbenjamin
Copy link
Collaborator

This seems to be fixed now. I'll close - feel free to open if it doesn't seem fixed to you:

In [1]: import numpy 
   ...: import sympy 
   ...:  
   ...: sympy.Rational(numpy.int64(1), 2)                                                                                         
Out[1]: 1/2

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

Successfully merging a pull request may close this issue.

4 participants