[SciPy-Dev] usage of inspect.getargspec ?

josef.pktd@gmai... josef.pktd@gmai...
Fri Jan 6 17:12:28 CST 2012


On Fri, Jan 6, 2012 at 3:48 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
>
>
> On Fri, Jan 6, 2012 at 1:04 PM, Ralf Gommers <ralf.gommers@googlemail.com>
> wrote:
>>
>>
>>
>> On Fri, Jan 6, 2012 at 7:48 PM, <josef.pktd@gmail.com> wrote:
>>>
>>> On Fri, Jan 6, 2012 at 10:42 AM,  <josef.pktd@gmail.com> wrote:
>>> > On Fri, Jan 6, 2012 at 10:37 AM, Gael Varoquaux
>>> > <gael.varoquaux@normalesup.org> wrote:
>>> >> On Fri, Jan 06, 2012 at 03:11:26PM +0000, Robert Kern wrote:
>>> >>> > My view is that simple things should be simple --- especially for
>>> >>> > the occasional user.
>>> >>
>>> >>> My main problem with this view is that I don't think that whether you
>>> >>> need a Hessian or not is the reasonable line to draw between "simple
>>> >>> things" and "not so simple things". The problem with using
>>> >>> getargspec() is that it is unreliable. It doesn't work for many
>>> >>> reasonable inputs (like say a wrapper function that wraps the real
>>> >>> function with one that takes *args,**kwds or extension functions or
>>> >>> bound methods or objects with __call__). Knowing that you have one of
>>> >>> these cases requires some rather deep experience with Python.
>>> >
>>> > Just to illustrate the problem: a question with inspect by a
>>> > stackoverflow user
>>> >
>>> >
>>> > http://stackoverflow.com/questions/7615733/too-many-arguments-used-by-python-scipy-optimize-curve-fit
>>>
>>> and, I'm sorry if I sound grumpy at times.
>>>
>>> I'm spending a large amount of time on code maintenance, and this
>>> change promises several days of bug hunting, finding work-arounds and
>>> answering questions on stack overflow for no clear benefits that I can
>>> see, so I'd rather announce my opinion in advance.
>>
>>
>> The issue is clear I think. How about we undo this change, agree not to
>> use things like the inspect module unless absolutely necessary, and catch
>> this in review next time?

I think for functions like curve_fit that are clearly oriented towards
final users, and where there are non-magical alternatives, the
increased convenience to users can be worth it.

It covers 90% (?) of cases for 99% (?) of users, and for the rest and
for libraries there is leastsq as alternative. Given the popularity of
curve_fit, it clearly has been a very good addition to scipy.
I don't see any other way than using inspect to infer the number of
parameters for the starting values. (In my similar code users always
have to specify the number of parameters if no starting value is
given.)

Josef

>>
>
> I'll add that I removed one use of the inspect module in numpy because is
> stopped working in Python 3.
>
>>
>> It would be good though if some people could still look at the minimize()
>> API. Right now it hasn't been released yet, so we can make any change that
>> would make it simpler/cleaner.
>>
>
> Chuck
>
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>


More information about the SciPy-Dev mailing list