mpath special cases for the sage backend and the mpf class is missing. Why?

34 views
Skip to first unread message

Rocky Bernstein

unread,
Mar 26, 2021, 5:38:27 PM3/26/21
to mpmath
Even using mpmath 1.2.1 when inside sage. The mpf class is not defined. 

For example: 

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'

And if you look at mpmath/libmp/libmpf.py you will see lines like: 

 if BACKEND == 'sage': 

Some of this I guess has to do with differences in Python pickle between Pythoin 2 and Python3. But if that is so, then wouldn't a test on the Python version be more direct? 

And why is the mpf class missing in this case? 

Isuru Fernando

unread,
Mar 26, 2021, 5:49:16 PM3/26/21
to mpm...@googlegroups.com
You shouldn't be using `mpmath.ctx_mp_python.mpf`. Just use `mpmath.mpf`.

Isuru

--
You received this message because you are subscribed to the Google Groups "mpmath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpmath+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpmath/cbe52241-7cf9-4583-94e5-1da25b1983d7n%40googlegroups.com.

Rocky Bernstein

unread,
Mar 26, 2021, 6:45:31 PM3/26/21
to mpmath
I think this fixes the problem we see. Thanks!

Aside from asking from my asking here, was this noted somewhere else?

Isuru Fernando

unread,
Mar 26, 2021, 8:18:18 PM3/26/21
to mpm...@googlegroups.com
> Aside from asking from my asking here, was this noted somewhere else?

A good rule is not to use any function/class/module that is not documented. While `mpmath.mpf` is documented, `mpmath.ctx_mp_python` module is not.

Isuru

Reply all
Reply to author
Forward
0 new messages