[SciPy-dev] patch for minpack.py Newton

David M. Cooke cookedm at physics.mcmaster.ca
Fri Oct 28 14:24:03 CDT 2005


Ryan Krauss <ryanlists at gmail.com> writes:

> I am using the Newton algorithm in minpack.py to find the roots of a
> complex expression.  This seems to work correctly, but the error
> raised if it doesn't convert wasn't written with the possiblity of
> complex expressions in mind.  I have changed the ending of the newton
> function (line 330) from
>
> raise RuntimeError, "Failed to converge after %d iterations, value is
> %f" % (maxiter,p)
>
> to
>
> if type(p) is complex:
>         raise RuntimeError, "Failed to converge after %d iterations,
> value is %f%+fj" % (maxiter,real(p),imag(p))
>     else:
>         raise RuntimeError, "Failed to converge after %d iterations,
> value is %f" % (maxiter,p)
>
> This just makes the function raise a more helpful error message. 
> Otherwise it reads, error float is required.
>
> I made this change on my machine.  Is it valuable and what is the
> procedure to make it part of scipy?  And is it worth doing if I am not
> in the newscipy yet?
>
> Thanks,
>
> Ryan

Hi Ryan,

I've added a fix to the newscipy branch. I use %s instead of pulling
real and imaginary parts out.

Reporting here is fine (for now :). I don't think people are keeping
an eye on the bug tracker, as we're busy with the -newcore and
-newscipy branches.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca




More information about the Scipy-dev mailing list