[Scipy-tickets] [SciPy] #277: interpolate.interp2d does not work for x, y = 1D

SciPy scipy-tickets at scipy.net
Fri Oct 6 03:42:52 CDT 2006


#277: interpolate.interp2d does not work for x, y = 1D
-------------------------------+--------------------------------------------
 Reporter:  pv                 |       Owner:  somebody            
     Type:  defect             |      Status:  new                 
 Priority:  normal             |   Milestone:                      
Component:  scipy.interpolate  |     Version:                      
 Severity:  normal             |    Keywords:  interpolate interp2d
-------------------------------+--------------------------------------------
 scipy.interpolate.interp2d docstring states that
 {{{
 Input:
   x,y  - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays)
   z    - 2-d array of grid values
 }}}
 This leads to think that the following code would be OK, but it doesn't
 appear to work:
 {{{
 >>> x,y=[1,2,3], [0,1]; interpolate.interp2d(x, y, [[0,0,0],[0,0,0]])
 Traceback (most recent call last):
   File "<ipython console>", line 1, in ?
   File "/usr/lib/python2.4/site-
 packages/scipy/interpolate/interpolate.py", line 54, in __init__
   File "/usr/lib/python2.4/site-packages/scipy/interpolate/fitpack.py",
 line 595, in bisplrep
 TypeError: len(x)==len(y)==len(z) must hold.
 }}}

 However, the following works:
 {{{
 >>> x,y=meshgrid([1,2,3], [0,1]); interpolate.interp2d(x, y,
 [[0,0,0],[0,0,0]])
 <scipy.interpolate.interpolate.interp2d instance at 0x5b81dbac>
 }}}

 I guess this is not only a documentation bug, since also calling interp2d
 in bisplrep-style doesn't work:
 {{{
 >>> x,y=meshgrid([1,2,3], [0,1])
 >>> interpolate.interp2d(x.ravel(), y.ravel(),
 array([[0,0,0],[0,0,0]]).ravel())
 Traceback (most recent call last):
   File "<ipython console>", line 1, in ?
   File "/usr/lib/python2.4/site-
 packages/scipy/interpolate/interpolate.py", line 47, in __init__
 ValueError: Grid values is not a 2-d array.
 }}}

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


More information about the Scipy-tickets mailing list