Skip to content

Commit

Permalink
DEP: remove deprecated functions from scipy.interpolate
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed Sep 16, 2017
1 parent 7fdad53 commit 9677914
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
1 change: 0 additions & 1 deletion scipy/interpolate/__init__.py
Expand Up @@ -163,7 +163,6 @@
.. autosummary::
:toctree: generated/
ppform
spleval
spline
splmake
Expand Down
9 changes: 1 addition & 8 deletions scipy/interpolate/fitpack2.py
Expand Up @@ -795,7 +795,7 @@ def get_coeffs(self):
""" Return spline coefficients."""
return self.tck[2]

def __call__(self, x, y, mth=None, dx=0, dy=0, grid=True):
def __call__(self, x, y, dx=0, dy=0, grid=True):
"""
Evaluate the spline or its derivatives at given positions.
Expand Down Expand Up @@ -825,17 +825,10 @@ def __call__(self, x, y, mth=None, dx=0, dy=0, grid=True):
.. versionadded:: 0.14.0
mth : str
Deprecated argument. Has no effect.
"""
x = np.asarray(x)
y = np.asarray(y)

if mth is not None:
warnings.warn("The `mth` argument is deprecated and will be removed",
FutureWarning)

tx, ty, c = self.tck[:3]
kx, ky = self.degrees
if grid:
Expand Down
17 changes: 9 additions & 8 deletions scipy/interpolate/interpolate.py
Expand Up @@ -4,7 +4,7 @@


__all__ = ['interp1d', 'interp2d', 'spline', 'spleval', 'splmake', 'spltopp',
'ppform', 'lagrange', 'PPoly', 'BPoly', 'NdPPoly',
'lagrange', 'PPoly', 'BPoly', 'NdPPoly',
'RegularGridInterpolator', 'interpn']


Expand Down Expand Up @@ -61,7 +61,7 @@ def lagrange(x, w):
-------
lagrange : `numpy.poly1d` instance
The Lagrange interpolating polynomial.
Examples
--------
Interpolate :math:`f(x) = x^3` by 3 points.
Expand All @@ -70,7 +70,7 @@ def lagrange(x, w):
>>> x = np.array([0, 1, 2])
>>> y = x**3
>>> poly = lagrange(x, y)
Since there are only 3 points, Lagrange polynomial has degree 2. Explicitly,
it is given by
Expand Down Expand Up @@ -2315,8 +2315,8 @@ class RegularGridInterpolator(object):
avoids expensive triangulation of the input data by taking advantage of the
regular grid structure.
If any of `points` have a dimension of size 1, linear interpolation will
return an array of `nan` values. Nearest-neighbor interpolation will work
If any of `points` have a dimension of size 1, linear interpolation will
return an array of `nan` values. Nearest-neighbor interpolation will work
as usual in this case.
.. versionadded:: 0.14
Expand Down Expand Up @@ -2640,7 +2640,7 @@ def interpn(points, values, xi, method="linear", bounds_error=True,


# backward compatibility wrapper
class ppform(PPoly):
class _ppform(PPoly):
"""
Deprecated piecewise polynomial class.
Expand All @@ -2649,7 +2649,7 @@ class ppform(PPoly):
"""

def __init__(self, coeffs, breaks, fill=0.0, sort=False):
warnings.warn("ppform is deprecated -- use PPoly instead",
warnings.warn("_ppform is deprecated -- use PPoly instead",
category=DeprecationWarning)

if sort:
Expand Down Expand Up @@ -2853,11 +2853,12 @@ def spleval(xck, xnew, deriv=0):
return res


# When `spltopp` gets removed, also remove the _ppform class.
@np.deprecate(message="spltopp is deprecated in scipy 0.19.0, "
"use PPoly.from_spline instead.")
def spltopp(xk, cvals, k):
"""Return a piece-wise polynomial object from a fixed-spline tuple."""
return ppform.fromspline(xk, cvals, k)
return _ppform.fromspline(xk, cvals, k)


@np.deprecate(message="spline is deprecated in scipy 0.19.0, "
Expand Down
22 changes: 5 additions & 17 deletions scipy/interpolate/tests/test_interpolate.py
Expand Up @@ -4,7 +4,7 @@

from numpy.testing import (assert_, assert_equal, assert_almost_equal,
assert_array_almost_equal, assert_array_equal,
dec, assert_allclose)
assert_allclose)
from pytest import raises as assert_raises

from numpy import mgrid, pi, sin, ogrid, poly1d, linspace
Expand All @@ -14,7 +14,7 @@
from scipy._lib._numpy_compat import _assert_warns, suppress_warnings

from scipy.interpolate import (interp1d, interp2d, lagrange, PPoly, BPoly,
ppform, splrep, splev, splantider, splint, sproot, Akima1DInterpolator,
splrep, splev, splantider, splint, sproot, Akima1DInterpolator,
RegularGridInterpolator, LinearNDInterpolator, NearestNDInterpolator,
RectBivariateSpline, interpn, NdPPoly, BSpline)

Expand Down Expand Up @@ -1575,15 +1575,15 @@ def test_antiderivative_simple(self):
# (x-1)/2 for x \in [1, 3]
#
# antiderivative is then
# F(x) = x**2 / 2 for x \in [0, 1),
# F(x) = x**2 / 2 for x \in [0, 1),
# 0.5*x*(x/2 - 1) + A for x \in [1, 3]
# where A = 3/4 for continuity at x = 1.
x = [0, 1, 3]
c = [[0, 0], [1, 1]]

bp = BPoly(c, x)
bi = bp.antiderivative()

xx = np.linspace(0, 3, 11)
assert_allclose(bi(xx),
np.where(xx < 1, xx**2 / 2.,
Expand Down Expand Up @@ -1675,7 +1675,7 @@ def test_antider_neg(self):
b = BPoly(c, x)

xx = np.linspace(0, 1, 21)

assert_allclose(b.derivative(-1)(xx), b.antiderivative()(xx),
atol=1e-12, rtol=1e-12)
assert_allclose(b.derivative(1)(xx), b.antiderivative(-1)(xx),
Expand Down Expand Up @@ -1882,18 +1882,6 @@ def test_gh_5430(self):
orders = 1


class TestPpform(object):
def test_shape(self):
np.random.seed(1234)
c = np.random.rand(3, 12, 5, 6, 7)
x = np.sort(np.random.rand(13))
with suppress_warnings() as sup:
sup.filter(DeprecationWarning, "ppform is deprecated")
p = ppform(c, x)
xp = np.random.rand(3, 4)
assert_equal(p(xp).shape, (3, 4, 5, 6, 7))


class TestNdPPoly(object):
def test_simple_1d(self):
np.random.seed(1234)
Expand Down

0 comments on commit 9677914

Please sign in to comment.