I'm using jupyter notebook with anaconda on windows (reinstalled to the current version after several attempts). Somehow the mpmath library stopped working. Consider the following code
import mpmath as mp
mp.dps=530
mp.mpf(1) / mp.mpf(6)
But the result I got was
mpf('0.16666666666666666')
I also tried
mp.mpf("1") / mp.mpf("6")
which returned the same thing, and
mp.nprint(mp.mpf(1) / mp.mpf(6),50)
returned
0.16666666666666665741480812812369549646973609924316
which indicated the module malfunctioned.
What went wrong with the code?
You're not changing the context - you're adding a (useless)
dpsattribute to thempmathmodule itself.Let's do it without renaming gimmicks to make it clearer:
What you wanted instead is to set
dpson thempcontext attribute of thempmathmodule:For this reason, you should never do
import mpmath as mp- it's just begging to confuse (as happened to you) the module with the module's context object.