[SciPy-User] leastsq and cython
Sat Sep 25 22:04:57 CDT 2010
On 9/25/10 4:45 PM, 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
>> <firstname.lastname@example.org <mailto:email@example.com>> 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.
> Any suggestions for incorporating a cython or ctypes function into a
> test, so I can include tests of the change?
I fixed the code so that it only uses the 'func_name' attribute if it
exists. A callable class also does not have a 'func_name' attribute, so
I used that to create tests without having to actually have a cython or
Till, the problem only arises if the function that leastsq is calling
returns the wrong shape, so if you update to the trunk of scipy, you
will still get an exception, but now it should be a bit more appropriate
to the problem.
For the record, I created a ticket here:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User