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

34 ogledov
Preskoči na prvo neprebrano sporočilo

Rocky Bernstein

neprebran,
26. mar. 2021, 17:38:2726. 3. 21
do 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

neprebran,
26. mar. 2021, 17:49:1626. 3. 21
do 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

neprebran,
26. mar. 2021, 18:45:3126. 3. 21
do mpmath
I think this fixes the problem we see. Thanks!

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

Isuru Fernando

neprebran,
26. mar. 2021, 20:18:1826. 3. 21
do 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

Odgovori vsem
Odgovori avtorju
Posreduj
0 novih sporočil