Running MathicsSession inside Sage

87 views
Skip to first unread message

seb....@gmail.com

unread,
Mar 25, 2021, 10:24:43 AM3/25/21
to sage-devel
Hi,

Did anyone try this before? At the moment this stucks at the following issue:

sage: import mpmath
sage: mpmath.ctx_mp_python.mpf
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-8e8eed115623> in <module>
----> 1 mpmath.ctx_mp_python.mpf

AttributeError: module 'mpmath.ctx_mp_python' has no attribute 'mpf'


whereas

~/devel/sage$ ./local/bin/python3
Python 3.9.2 (default, Mar 19 2021, 22:23:28)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mpmath
>>> mpmath.ctx_mp_python.mpf
<class 'mpmath.ctx_mp_python.mpf'>


Any ideas what is the reason for this?

For the background of this question see Mathics issue 1169  especially this comment.

Matthias Koeppe

unread,
Mar 25, 2021, 12:19:59 PM3/25/21
to sage-devel

Rocky Bernstein

unread,
Mar 25, 2021, 12:50:07 PM3/25/21
to sage-devel
I spent some time looking over the links in the ticket cited. 

I am trying to understand why mpmath decided to do something special for sage and whether that is relevant still. I will ask on mpmath...

Dima Pasechnik

unread,
Mar 26, 2021, 6:47:32 PM3/26/21
to sage-devel
On Thursday, March 25, 2021 at 2:24:43 PM UTC seb....@gmail.com wrote:
Hi,

Did anyone try this before? At the moment this stucks at the following issue:

sage: import mpmath
sage: mpmath.ctx_mp_python.mpf
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-8e8eed115623> in <module>
----> 1 mpmath.ctx_mp_python.mpf

AttributeError: module 'mpmath.ctx_mp_python' has no attribute 'mpf'

this is apparently easy to fix, as this is due to
which makes the import of mpf conditional on BACKEND not being 'sage'

Making it unconditional does not seem to break anything in Sage.

Rocky Bernstein

unread,
Mar 26, 2021, 6:52:54 PM3/26/21
to sage-devel
I asked about this in the mpmath group and the solution there I think is good and only requires a change (or rather simplification) to the Mathics code.

So as far as I am concerned no changes are needed to sage or mpmath. See https://groups.google.com/g/mpmath/c/qzA5gs57Qm8/m/_eg4GHisAAAJ

seb....@gmail.com

unread,
Mar 27, 2021, 2:04:13 PM3/27/21
to sage-devel
Thanks to everyone who helped here somewhere along the way!
Reply all
Reply to author
Forward
0 new messages