mpmath 0.19 trouble with polyroots

198 views
Skip to first unread message

Jerry James

unread,
Aug 7, 2014, 11:05:45 AM8/7/14
to mpm...@googlegroups.com
Greetings,

I help maintain the sympy package for the Fedora Linux distribution.  The sympy package is distributed upstream with a bundled version of mpmath.  The bundling runs afoul of Fedora policies, so we are required to rip it out and substitute the system mpmath package instead.  The mpmath maintainer recently updated that package to version 0.19, and now the sympy test suite is failing like so:

________________________________________________________________________________
_________ sympy/polys/tests/test_polyroots.py:test_roots_preprocessed __________
  File "/builddir/build/BUILD/sympy-0.7.5/sympy/polys/tests/test_polyroots.py", line 440, in test_roots_preprocessed
    R1 = roots(f.evalf(), x, multiple=True)
  File "sympy/polys/polyroots.py", line 858, in roots
    for r in f.nroots():
  File "sympy/polys/polytools.py", line 3384, in nroots
    coeffs, maxsteps=maxsteps, cleanup=cleanup, error=error)
  File "/usr/lib/python2.7/site-packages/mpmath/calculus/polynomials.py", line 188, in polyroots
    % maxsteps)
NoConvergence: Didn't converge in maxsteps=50 steps.
________________________________________________________________________________
_______________ sympy/polys/tests/test_polytools.py:test_nroots ________________
  File "/builddir/build/BUILD/sympy-0.7.5/sympy/polys/tests/test_polytools.py", line 2657, in test_nroots
    roots, error = Poly(x**2 - 1, x).nroots(error=True)
  File "sympy/polys/polytools.py", line 3384, in nroots
    coeffs, maxsteps=maxsteps, cleanup=cleanup, error=error)
  File "/usr/lib/python2.7/site-packages/mpmath/calculus/polynomials.py", line 201, in polyroots
    err = max(err, ctx.ldexp(1, -orig+1))
NameError: global name 'orig' is not defined


The second test failure appears to be due to a missing "orig = ctx.prec" in polyroots().  I don't know what is causing the first test failure.  Any help figuring it out would be much appreciated.  Thank you,
-- 
Jerry James

Ondřej Čertík

unread,
Aug 7, 2014, 3:22:44 PM8/7/14
to mpm...@googlegroups.com
Hi Jerry,
Related to this, we have an open issue in sympy about stopping bundling mpmath:

https://github.com/sympy/sympy/issues/5581
https://github.com/sympy/sympy/pull/2192

Ondrej

Fredrik Johansson

unread,
Aug 7, 2014, 3:25:34 PM8/7/14
to mpm...@googlegroups.com
On Thu, Aug 7, 2014 at 5:05 PM, Jerry James <logan...@gmail.com> wrote:
> Greetings,
>
> I help maintain the sympy package for the Fedora Linux distribution. The
> sympy package is distributed upstream with a bundled version of mpmath. The
> bundling runs afoul of Fedora policies, so we are required to rip it out and
> substitute the system mpmath package instead. The mpmath maintainer
> recently updated that package to version 0.19, and now the sympy test suite
> is failing like so:

> The second test failure appears to be due to a missing "orig = ctx.prec" in
> polyroots(). I don't know what is causing the first test failure. Any help
> figuring it out would be much appreciated. Thank you,

Hi Jerry,

Thanks for the bug report. I've just fixed it in the git version.

Fredrik

Fredrik Johansson

unread,
Aug 7, 2014, 3:27:03 PM8/7/14
to mpm...@googlegroups.com
To clarify, I fixed the second problem. I don't know what's going on
in the first one.

Fredrik

Aaron Meurer

unread,
Aug 7, 2014, 3:37:42 PM8/7/14
to mpm...@googlegroups.com
We should update to mpmath 0.19 before the next release, and then discuss unbundling it for the release after that (which should maybe be SymPy 1.0).

Aaron Meurer



--
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 post to this group, send email to mpm...@googlegroups.com.
Visit this group at http://groups.google.com/group/mpmath.
For more options, visit https://groups.google.com/d/optout.

Ondřej Čertík

unread,
Aug 7, 2014, 3:39:58 PM8/7/14
to mpm...@googlegroups.com
On Thu, Aug 7, 2014 at 1:37 PM, Aaron Meurer <asme...@gmail.com> wrote:
> We should update to mpmath 0.19 before the next release, and then discuss
> unbundling it for the release after that (which should maybe be SymPy 1.0).

Agreed.

Ondrej

Jerry James

unread,
Aug 12, 2014, 4:24:02 PM8/12/14
to mpm...@googlegroups.com
On Thursday, August 7, 2014 1:27:03 PM UTC-6, Fredrik Johansson wrote:
To clarify, I fixed the second problem. I don't know what's going on
in the first one.

Thanks, Fredrik.  I have looked at this a little more.  Here is the invocation sympy is actually making in that test.

In Fedora 20, wih mpmath 0.18:

$ python
Python 2.7.5 (default, Jun 25 2014, 10:19:55) 
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mpmath import *
>>> polyroots([0.00395625, -14.4125, 10958.8, 14840215, -27633173750, 16194716250000, -4269543750000000, 5.082328125e+17, -2.1601054687499997e+19], maxsteps=50)
[mpf('-1304.8837560636628'), mpf('97.116881680064708'), mpf('186.94643017187687'), mpf('245.52679294706513'), mpf('503.44100417477347'), mpf('791.5493438300972'), mpf('1273.1667812934825'), mpf('1850.1065061685147')]


In Fedora Rawhide, with mpmath 0.19:
$ python
Python 2.7.8 (default, Jul 31 2014, 13:56:18) 
[GCC 4.9.1 20140717 (Red Hat 4.9.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mpmath import *
>>> polyroots([0.00395625, -14.4125, 10958.8, 14840215, -27633173750, 16194716250000, -4269543750000000, 5.082328125e+17, -2.1601054687499997e+19], maxsteps=50)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/mpmath/calculus/polynomials.py", line 188, in polyroots
    % maxsteps)
mpmath.libmp.libhyper.NoConvergence: Didn't converge in maxsteps=50 steps.


Of course, the versions of python are different (2.7.5 vs. 2.7.8), as well as the gcc versions used to compile python.  Do other mpmath 0.19 users see the same results?  Regards,
-- 
Jerry James

Fredrik Johansson

unread,
Aug 12, 2014, 5:55:27 PM8/12/14
to mpm...@googlegroups.com
I get the same failure. It can be fixed e.g. by passing extraprec=30.

Fredrik
Reply all
Reply to author
Forward
0 new messages