[Scipy-tickets] [SciPy] #1764: ascending order in interpolation routines

SciPy Trac scipy-tickets@scipy....
Sat Nov 3 15:19:15 CDT 2012


#1764: ascending order in interpolation routines
-------------------------+--------------------------------------------------
 Reporter:  theyoud      |       Owner:  somebody   
     Type:  enhancement  |      Status:  new        
 Priority:  normal       |   Milestone:  Unscheduled
Component:  Other        |     Version:  0.11.0     
 Keywords:               |  
-------------------------+--------------------------------------------------
 Interpolation (and spline) functions, such as interpolation.interp1d,
 currently require the array of independent variables (x values) be given
 in ascending order.  These functions could be enhanced to also accept
 descending order.  Such a modification would avoid unnecessary reversing
 of arrays.  Also it would make the routines harder to break.

 Currently if an array in descending order is specified for x, the behavior
 is problematic.  The interpolation function is created without error, but
 when you try to evaluate the interpolation function (at an x value that is
 in range) you get an error message that the x value is out of range.

 The following code illustrates the problem I describe above:

 {{{
 import numpy as np
 from scipy.interpolate import interp1d

 xa = np.arange(10)[::-1]
 ya = xa**2
 f = interp1d(xa , ya)
 f(5.5)
 }}}

 While the interpolation fn. f is created, there is an error on the
 attempted evaluation.
 {{{
 ValueError: A value in x_new is below the interpolation range.
 }}}

 It's probably a "bug" to create a non-functioning interpolation fn.  The
 better "enhancement" is probably to accept both ascending and descending
 order.

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


More information about the Scipy-tickets mailing list