ascending order in interpolation routines (Trac #1764) #2283
Labels
enhancement
A new feature or improvement
good first issue
Good topic for first contributor pull requests, with a relatively straightforward solution
Migrated from Trac
scipy.interpolate
Milestone
Original ticket http://projects.scipy.org/scipy/ticket/1764 on 2012-11-03 by trac user theyoud, assigned to @pv.
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:
While the interpolation fn. f is created, there is an error on the attempted evaluation.
It's probably a "bug" to create a non-functioning interpolation fn. The better "enhancement" is probably to accept both ascending and descending order.
The text was updated successfully, but these errors were encountered: