Skip to content

Commit 9096566

Browse files
authored
Merge pull request #1659 from scipy/1.18/interpolate/deprecate
🗑️ `interpolate`: deprecate `pade`, `lagrange`, `approximate_taylor_polynomial`
2 parents 08329f0 + 447ab2b commit 9096566

6 files changed

Lines changed: 14 additions & 7 deletions

File tree

scipy-stubs/interpolate/_interpolate.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type _Extrapolate = Literal["periodic"] | bool
2020
type _Interp1dKind = Literal["linear", "nearest", "nearest-up", "zero", "slinear", "quadratic", "cubic", "previous", "next"]
2121
type _Interp1dFillValue = onp.ToFloat | onp.ToFloatND | tuple[onp.ToFloat | onp.ToFloatND, onp.ToFloat | onp.ToFloatND]
2222

23-
type _Array2ND[_NumberT: npc.number] = onp.Array[tuple[int, int, *tuple[Any, ...]], _NumberT]
23+
type _Array2ND[NumberT: npc.number] = onp.Array[tuple[int, int, *tuple[Any, ...]], NumberT]
2424

2525
###
2626

@@ -249,4 +249,7 @@ class NdPPoly(Generic[_CT_co]):
249249
) -> onp.ArrayND[_CT_co]: ...
250250

251251
#
252+
@deprecated(
253+
"This function is deprecated and will be removed in SciPy 1.20.0. Use `scipy.interpolate.BarycentricInterpolator` instead."
254+
)
252255
def lagrange(x: onp.ToComplex1D, w: onp.ToComplex1D) -> np.poly1d: ...

scipy-stubs/interpolate/_pade.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from typing_extensions import deprecated
2+
13
import numpy as np
24
import optype.numpy as onp
35

46
__all__ = ["pade"]
57

8+
@deprecated("This function is deprecated and will be removed in SciPy 1.20.0. Use `mpmath.pade` instead.")
69
def pade(an: onp.ToComplex1D, m: onp.ToJustInt, n: onp.ToJustInt | None = None) -> tuple[np.poly1d, np.poly1d]: ...

scipy-stubs/interpolate/_polyint.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import types
22
from _typeshed import Incomplete
33
from collections.abc import Callable, Sequence
44
from typing import Any, ClassVar, Final, Generic, Protocol, Self, SupportsIndex, final, overload, override, type_check_only
5-
from typing_extensions import TypeIs, TypeVar
5+
from typing_extensions import TypeIs, TypeVar, deprecated
66

77
import numpy as np
88
import optype.numpy as onp
@@ -235,6 +235,7 @@ def krogh_interpolate(
235235
) -> onp.ArrayND[np.float64 | np.complex128]: ...
236236

237237
#
238+
@deprecated("This function is deprecated and will be removed in SciPy 1.20.0.")
238239
def approximate_taylor_polynomial(
239240
f: Callable[[onp.Array1D[np.float64]], onp.ToComplexND] | np.ufunc,
240241
x: onp.ToFloat,

tests/interpolate/test_interpolate.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ _interp2d_type: type[interp2d] # pyright: ignore[reportDeprecated]
4646
###
4747
# lagrange
4848

49-
assert_type(lagrange(_f64_1d, _f64_1d), np.poly1d)
49+
assert_type(lagrange(_f64_1d, _f64_1d), np.poly1d) # pyright:ignore[reportDeprecated] # pyrefly:ignore[deprecated]

tests/interpolate/test_pade.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ from scipy.interpolate import pade
77
coeffs: list[float]
88
coeffs_c: list[complex]
99

10-
assert_type(pade(coeffs, 3), tuple[np.poly1d, np.poly1d])
11-
assert_type(pade(coeffs, 3, n=2), tuple[np.poly1d, np.poly1d])
12-
assert_type(pade(coeffs_c, 3), tuple[np.poly1d, np.poly1d])
10+
assert_type(pade(coeffs, 3), tuple[np.poly1d, np.poly1d]) # pyright:ignore[reportDeprecated] # pyrefly:ignore[deprecated]
11+
assert_type(pade(coeffs, 3, n=2), tuple[np.poly1d, np.poly1d]) # pyright:ignore[reportDeprecated] # pyrefly:ignore[deprecated]
12+
assert_type(pade(coeffs_c, 3), tuple[np.poly1d, np.poly1d]) # pyright:ignore[reportDeprecated] # pyrefly:ignore[deprecated]

tests/interpolate/test_polyint.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ assert_type(bary_c_f32.derivatives(0), np.ndarray[tuple[Any, ...], np.dtype[np.c
7878
###
7979
# approximate_taylor_polynomial
8080

81-
assert_type(approximate_taylor_polynomial(np.sin, 0.0, 3, 1.0), np.poly1d)
81+
assert_type(approximate_taylor_polynomial(np.sin, 0.0, 3, 1.0), np.poly1d) # pyright:ignore[reportDeprecated] # pyrefly:ignore[deprecated]

0 commit comments

Comments
 (0)