[SciPy-dev] New coding style (docstrings) : question

Anne Archibald peridot.faceted at gmail.com
Mon Aug 6 13:23:14 EDT 2007


On 06/08/07, dmitrey <openopt at ukr.net> wrote:

> Especially I'm interested in func handlers - are they need any type
> describer?

I don't know if there's any formal standard for how they're written,
but it definitely helps to be as specific as possible about what
callback functions get passed and must return.

>       func -- the Python function or method to be minimized.
>       x0 : ndarray -- the initial guess.
>       args -- extra arguments for func.
>       callback -- an optional user-supplied function to call after each
>                   iteration.  It is called as callback(xk), where xk is the
>                   current parameter vector.

Specifically, what does fopt get passed? the x value, as a
one-dimensional array, and args? Is it called as f(x,args) or
f(x,*args)? It's also worth mentioning that it should return a scalar,
the function value there. Similarly for the callback, which should
presumably return None. I take it that callback can throw exceptions
to abort the optimization if necessary (that is, this won't leave the
optimizer's internal state in a mess)?

Anne



More information about the SciPy-Dev mailing list