[SciPy-User] Flaws in fmin_cobyla

Pauli Virtanen pav at iki.fi
Thu Sep 27 16:57:42 EDT 2012


27.09.2012 23:14, Moore, Eric (NIH/NIDDK) [F] kirjoitti:
>> -----Original Message-----
>> From: Robaula [mailto:helmrp at yahoo.com]
[clip]
>> I think so. I think you're missing line 165 of the fmin_cobyla routine.
[clip]
> The various data produced by fmin_cobyla routine are printed using
> a direct call to PRINT from within the fortran routine. This is less
> than optimal because if you are not running in a terminal (ie, at
> python, or ipython) you won't see any of the output.
> So try executing the example or changing the disp parameter
> while running from the console, and they will work as expected.
> 
> I'd say this is a big gotcha that should be noted in the docs at least.
> The better choice would really be to patch cobyla2.f so that this would
> work even in the ipython qtconsole or wherever Bob is running his code.
>
> If there really is something to line 165
> (https://github.com/scipy/scipy/blob/master/scipy/optimize/cobyla.py#L165)
> it's not obvious to me.  Could you elaborate? 

Both iprint and disp are passed correctly down to the Fortran routine.

Fixing the issue with converting output from stdout to Python's
sys.stdout can be done by passing a Python callback function down to the
fortran code, and replacing prints with it + some Fortran string
processing. There are also a couple of other cases of this, in Qhull and
some of the integrators in scipy.integrate.

Ideally, Ipython consoles et al. would redirect stdout/stderr file
handles so that also the output that comes outside from Python land
would be shown to the user. However, the correct behavior for Scipy
routines would be to print via Python's I/O.

-- 
Pauli Virtanen






More information about the SciPy-User mailing list