[SciPy-User] leastsq and cython
Dag Sverre Seljebotn
Sun Sep 26 04:20:48 CDT 2010
Warren Weckesser wrote:
> On 9/25/10 4:27 PM, Charles R Harris wrote:
>> On Sat, Sep 25, 2010 at 3:03 PM, David Baddeley
>> <email@example.com <mailto:firstname.lastname@example.org>> wrote:
>> I've, run into a similar problem, it's due to the fact that
>> native methods (ie
>> ones loaded from c libraries) are not quite the same as pure
>> python function
>> objects & don't possess all the nice attributes. It's been a
>> while, but I seem
>> to remember that this error crops up when leastsq is trying to
>> print some form
>> of status message with the function name in it. I've circumvented
>> the problem by
>> making a thin python wrapper function which just calls my c
>> method. This works,
>> but is not ideal, as you introduce additional function call
>> overhead. If anyone
>> out there knows of a better solution I'd also be interested.
>> Maybe it shouldn't try to print the function name? The context of the
>> message might be enough.
> The function 'check_func' in minpack.py uses the attribute 'func_name'
> in an error message. I'm tweaking 'check_func' now so that it first
> checks for the 'func_name' attribute before trying to use it.
Both Cython and Python functions do have the __name__ attribute though,
can't you just use that?
More information about the SciPy-User