Skip to content

Commit

Permalink
BUG: interpolate: allow list inputs for make_interp_spline(..., k=2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ev-br committed Apr 12, 2018
1 parent b21e246 commit 3fd28b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scipy/interpolate/_bsplines.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@ def make_interp_spline(x, y, k=3, t=None, bc_type=None, axis=0,
c = np.ascontiguousarray(c, dtype=_get_dtype(c.dtype))
return BSpline.construct_fast(t, c, k, axis=axis)

x = _as_float_array(x, check_finite)
y = _as_float_array(y, check_finite)
k = int(k)

# come up with a sensible knot vector, if needed
if t is None:
if deriv_l is None and deriv_r is None:
Expand All @@ -764,10 +768,7 @@ def make_interp_spline(x, y, k=3, t=None, bc_type=None, axis=0,
else:
t = _augknt(x, k)

x = _as_float_array(x, check_finite)
y = _as_float_array(y, check_finite)
t = _as_float_array(t, check_finite)
k = int(k)

axis = axis % y.ndim
y = np.rollaxis(y, axis) # now internally interp axis is zero
Expand Down
7 changes: 7 additions & 0 deletions scipy/interpolate/tests/test_bsplines.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,13 @@ def test_check_finite(self):
y[-1] = z
assert_raises(ValueError, make_interp_spline, x, y)

@pytest.mark.parametrize('k', [1, 2, 3, 5])
def test_list_input(self, k):
# regression test for gh-8714: TypeError for x, y being lists and k=2
x = list(range(10))
y = [a**2 for a in x]
make_interp_spline(x, y, k=k)

def test_multiple_rhs(self):
yy = np.c_[np.sin(self.xx), np.cos(self.xx)]
der_l = [(1, [1., 2.])]
Expand Down

0 comments on commit 3fd28b5

Please sign in to comment.