| Issue 154: | mpmathify should work for complex sympy numbers | |
| 1 person starred this issue and may be notified of changes. | Back to list |
>>> from sympy import *
>>> mpmath.mpmathify(S(1))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sympy/mpmath/mptypes.py", line 363, in convert
raise TypeError("cannot create mpf from " + repr(x))
TypeError: cannot create mpf from 1
Let's also make sure that sympy matrices are supported.
|
|
,
Jul 31, 2009
Are you working on this? |
|
,
Aug 05, 2009
I was not, but I probably will do it soon, as this is imho important and easy to fix. |
|
,
Aug 06, 2009
Should this be fixed in sympy (adding an _mpmath_ attribute, for which mpmathify is already checking) or in mpmath? |
|
,
Aug 06, 2009
Adding _mpmath_ to sympy is certainly preferrable, as otherwise mpmath will need to worry about sympy internals. |
|
,
Aug 06, 2009
There is already Number._as_mpf_val(prec), which should do the job. Which precision should be used when converting to mpf? Should mpmathify convert sympy integers to Python integers? |
|
,
Aug 06, 2009
> which should do the job. Which precision should be used when converting to mpf? What do you mean? mpmathify calls x._mpmath_ with the appropriate precision. > Should mpmathify convert sympy integers to Python integers? The easiest solution might be to add an _mpf_ property to sympy integers (not sure if that will break anything). |
|
,
Aug 06, 2009
So why not rename _as_mpf_val to _mpmath_? (Should work for Rational.) I'd add just add an _mpmath_ property to Integer. |
|
,
Aug 13, 2009
I sent a patch to the sympy list. What about complex numbers? This has to be implemented in mpmath, unless Add grows an _mpmath_ method. |
|
,
Aug 14, 2009
It fixed it in sympy HEAD, and added support in mpmathify for matrices. I'm not sure how to support complex numbers.
Summary: mpmathify should work for complex sympy numbers
Labels: -Priority-High Priority-Medium |
|
,
Aug 22, 2009
Easiest way to enable conversion for any SymPy object is to add _mpmath_ to Basic and have it call evalf. |
|
|
|