[Scipy-tickets] [SciPy] #1072: scipy.interpolate.interp2d ignores fill_value keyword

SciPy Trac scipy-tickets@scipy....
Mon Nov 29 23:52:25 CST 2010


#1072: scipy.interpolate.interp2d ignores fill_value keyword
-------------------------------+--------------------------------------------
 Reporter:  cems               |       Owner:  somebody
     Type:  defect             |      Status:  new     
 Priority:  normal             |   Milestone:  0.9.0   
Component:  scipy.interpolate  |     Version:  0.7.0   
 Keywords:                     |  
-------------------------------+--------------------------------------------

Old description:

> Scipy   version = '0.8.0.dev5698'
>

> I am reporting 2 different errors.
> 1) the bounds checking does not work and thus it ignores the fill_value
> keyword
> 2) there is a bizarre error for a specific size matrix
>
> bound checking failure:
>

> from numpy import *
> from scipy import interpolate
>
> x = arange(4.)
> y = arange(5.)
>
> z = arange( len(x)*len(y) )
> z = cos( x[z % len(x) ])  + sin( y[z % len(y) ] )**2
>
> z = z.reshape(len(y),len(x))  # now a 4 x 5 matrix
>
> g = interpolate.interp2d(x,y,z,kind="linear",fill_value=-1)
>
> print g(13,13)
>
> # should report -1 since it's outside the bounds (3,4) but does not.
>
> it also does not raise an exception of the bounds checking flag is set to
> True.
>

> Strange behavior for  specific size matrix:
>
> from numpy import *
> from scipy import interpolate
>
> x = arange(8.)
> y = arange(12.)
>
> z = arange( len(x)*len(y) )
> z = cos( x[z % len(x) ])  + sin( y[z % len(y) ] )**2
>
> z = z.reshape(len(y),len(x))  # now a 4 x 5 matrix
>
> g = interpolate.interp2d(x,y,z,kind="linear",fill_value=-1)
>

> this produces the following error message:
>
> Warning:     No more knots can be added because the number of B-spline
> coefficients already exceeds the number of data points m. Probably
> causes: either
>     s or m too small. (fp>s)
>         kx,ky=1,1 nx,ny=13,11 m=96 fp=3.204842 s=0.000000
>

>
> However if you increase the size of the matrix so  say len(x)=9 , len(y)
> = 13
> then warning message does not occur.

New description:

 Scipy   version = '0.8.0.dev5698'


 I am reporting 2 different errors.
 1) the bounds checking does not work and thus it ignores the fill_value
 keyword
 2) there is a bizarre error for a specific size matrix

 bound checking failure:

 {{{
 from numpy import *
 from scipy import interpolate

 x = arange(4.)
 y = arange(5.)

 z = arange( len(x)*len(y) )
 z = cos( x[z % len(x) ])  + sin( y[z % len(y) ] )**2

 z = z.reshape(len(y),len(x))  # now a 4 x 5 matrix

 g = interpolate.interp2d(x,y,z,kind="linear",fill_value=-1)

 print g(13,13)

 # should report -1 since it's outside the bounds (3,4) but does not.
 }}}
 it also does not raise an exception of the bounds checking flag is set to
 True.


 Strange behavior for  specific size matrix:
 {{{
 from numpy import *
 from scipy import interpolate

 x = arange(8.)
 y = arange(12.)

 z = arange( len(x)*len(y) )
 z = cos( x[z % len(x) ])  + sin( y[z % len(y) ] )**2

 z = z.reshape(len(y),len(x))  # now a 4 x 5 matrix

 g = interpolate.interp2d(x,y,z,kind="linear",fill_value=-1)
 }}}

 this produces the following error message:

 Warning:     No more knots can be added because the number of B-spline
 coefficients already exceeds the number of data points m. Probably causes:
 either
     s or m too small. (fp>s)
         kx,ky=1,1 nx,ny=13,11 m=96 fp=3.204842 s=0.000000



 However if you increase the size of the matrix so  say len(x)=9 , len(y) =
 13
 then warning message does not occur.

--

Comment(by warren.weckesser):

 Added markup around the python code in the description.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1072#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list