[SciPy-dev] patch for minpack.py Newton

Ryan Krauss ryanlists at gmail.com
Fri Oct 28 16:04:59 EDT 2005


Thanks David.  I didn't realize %s would work for complex or float. 
That definitely seems like the right solution.

Ryan

On 10/28/05, David M. Cooke <cookedm at physics.mcmaster.ca> wrote:
> 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
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev
>




More information about the SciPy-Dev mailing list