[SciPy-dev] scipy.optimize.nonlin rewrite

Benny Malengier benny.malengier@gmail....
Mon Dec 1 06:07:24 CST 2008


2008/12/1 Pauli Virtanen <pav@iki.fi>

> Sun, 30 Nov 2008 21:59:32 -0500, Anne Archibald wrote:
>
> > 2008/11/30 Gideon Simpson <simpson@math.toronto.edu>:
> >> Still no args input for inputting arguments to the function F?
> >>
> >> Sorry to complain, but the absence of this has put me off using these
> >> routines as it would require a rewrite of much of my code.
> >
> > Why?
> >
> > Instead of
> > optimize.whatever(F, args=extra)
> > just use
> > optimize.whatever(lambda x: F(x,extra))
>
> Exactly; I was under the impression that this 'args' business was some
> legacy from times when Python didn't support nested scopes, cf. eg.
>
>        http://www.python.org/doc/2.1/ref/lambda.html
>        http://www.python.org/dev/peps/pep-0227/
>
> I don't see a need for the 'args' option except maybe for conformance
> with the other optimization functions in Scipy. But maybe there are also
> other reasons to include it?
>

I have noticed these args not even working well in some cases in integrate
ode method (due to the fortran wrapper code not handling them). Eg vode.pyf
has
     double precision intent(hide) :: rpar
While the ode class does contain:

    def set_f_params(self,*args):
        """Set extra parameters for user-supplied function f."""
        self.f_params = args
        return self

I tend to use class functions, which have access to other class
methods/attributes, so
optimize.whatever(problem.F)

Benny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20081201/6ac15b73/attachment.html 


More information about the Scipy-dev mailing list