[SciPy-User] Bug in interpolate.polyint.py and fix

Anne Archibald peridot.faceted@gmail....
Thu Oct 15 15:45:42 CDT 2009


Hi,

Pauli Virtanen beat me to a fix:
http://projects.scipy.org/scipy/changeset/5966

I took a more general approach, allowing polyint objects to be applied
to arrays of any dimension:
http://projects.scipy.org/scipy/ticket/1021

Anne

2009/10/15 Marco Nicoletti <nicoletti@consorzio-innova.it>:
> Dear all,
>
> I guess I found a bug in the module scipy.interpolate.polyint.py.
>
> If you run the following lines:
>
> #-----------krogh.py---------------#
> from scipy import interpolate
> import numpy
> # Krogh example
> xi = [0,3,4,10]
> yi = [10,3,4,20]
> krogh = interpolate.KroghInterpolator(xi, yi)
> # Evaluate in one single point
> tmp = 0.5
> tmp = numpy.asarray(tmp)
> val = krogh(tmp)
> #---------------------------------------#
>
> you obtain the following error:
>
> #---------------------------------------#
>>python -u "krogh.py"
> Traceback (most recent call last):
>   File "krogh.py", line 10, in <module>
>     val = krogh(tmp)
>   File "C:\Python25\lib\site-packages\scipy\interpolate\polyint.py", line
> 109, in __call__
>     m = len(x)
> TypeError: len() of unsized object
> #---------------------------------------#
>
> I have tried to fix it adding the following check in the file polyint.py at
> line 100 in function __call__(self, x):
>
> #-------------------------------------------#
>         if np.size(x)==1:
>             x = np.asarray(x)
>             x = x.tolist()
> #-------------------------------------------#
>
> I have tested it running test_polyint.py and it worked.
> Your opinions?
>
> Marco Nicoletti
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>


More information about the SciPy-User mailing list