From e24628f912f36fbced1408448986e6cd3506b378 Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 9 Oct 2024 21:37:25 +0200 Subject: [PATCH] `scipy.interpolate` --- .github/workflows/ci.yml | 3 +- README.md | 4 +- scipy-stubs/interpolate/__init__.pyi | 79 +++++-- scipy-stubs/interpolate/_aaa.pyi | 8 - scipy-stubs/interpolate/_bsplines.pyi | 63 +++--- scipy-stubs/interpolate/_cubic.pyi | 45 ++-- scipy-stubs/interpolate/_fitpack2.pyi | 195 +++++++++++++----- scipy-stubs/interpolate/_fitpack_impl.pyi | 44 ++-- scipy-stubs/interpolate/_fitpack_py.pyi | 37 ++-- scipy-stubs/interpolate/_interpnd_info.pyi | 0 scipy-stubs/interpolate/_interpolate.pyi | 75 ++++--- scipy-stubs/interpolate/_ndbspline.pyi | 19 +- scipy-stubs/interpolate/_pade.pyi | 8 +- scipy-stubs/interpolate/_polyint.pyi | 56 +++-- scipy-stubs/interpolate/_rbf.pyi | 9 +- .../interpolate/_rbfinterp_pythran.pyi | 18 +- scipy-stubs/interpolate/interpnd.pyi | 5 + scipy-stubs/interpolate/interpolate.pyi | 130 +++--------- tests/stubtest/allowlist.txt | 3 - 19 files changed, 458 insertions(+), 343 deletions(-) delete mode 100644 scipy-stubs/interpolate/_aaa.pyi delete mode 100644 scipy-stubs/interpolate/_interpnd_info.pyi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eeef4426..8c354ee3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: "constants" "datasets" "integrate" + "interpolate" "io" "linalg" "misc" @@ -82,7 +83,7 @@ jobs: "scipy.fft", "scipy.fftpack", "scipy.integrate", - # "scipy.interpolate", + "scipy.interpolate", "scipy.io", "scipy.linalg", "scipy.misc", diff --git a/README.md b/README.md index 727f3b3b..e35fe31c 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ The exact version requirements are specified in the [`pyproject.toml`](pyproject | Package or module | Stubs status | |---------------------------------- |---------------- | -| `scipy.__init__` | 3: ready | +| `scipy.__init__` | **4: done** | | `scipy._lib` | 2: partial | | `scipy.cluster` | **4: done** | | `scipy.constants` | **4: done** | @@ -114,7 +114,7 @@ The exact version requirements are specified in the [`pyproject.toml`](pyproject | `scipy.fft` | 3: ready | | `scipy.fftpack` | 3: ready | | `scipy.integrate` | **4: done** | -| `scipy.interpolate` | 2: partial | +| `scipy.interpolate` | **4: done** | | `scipy.io` | **4: done** | | `scipy.linalg` | **4: done** | | ~`scipy.misc`~ | **4: done** | diff --git a/scipy-stubs/interpolate/__init__.pyi b/scipy-stubs/interpolate/__init__.pyi index c185a093..04050de3 100644 --- a/scipy-stubs/interpolate/__init__.pyi +++ b/scipy-stubs/interpolate/__init__.pyi @@ -1,23 +1,74 @@ -from . import ( - fitpack as fitpack, - fitpack2 as fitpack2, - interpolate as interpolate, - ndgriddata as ndgriddata, - polyint as polyint, - rbf as rbf, -) -from ._aaa import * +from . import fitpack, fitpack2, interpnd, interpolate, ndgriddata, polyint, rbf # deprecated from ._bsplines import * from ._cubic import * from ._fitpack2 import * from ._fitpack_py import * from ._interpolate import * -from ._ndbspline import NdBSpline as NdBSpline +from ._ndbspline import NdBSpline from ._ndgriddata import * from ._pade import * from ._polyint import * -from ._rbf import Rbf as Rbf -from ._rbfinterp import * -from ._rgi import * +from ._rbf import Rbf +from ._rbfinterp import RBFInterpolator +from ._rgi import RegularGridInterpolator, interpn -pchip = PchipInterpolator +__all__ = [ + "Akima1DInterpolator", + "BPoly", + "BSpline", + "BarycentricInterpolator", + "BivariateSpline", + "CloughTocher2DInterpolator", + "CubicHermiteSpline", + "CubicSpline", + "InterpolatedUnivariateSpline", + "KroghInterpolator", + "LSQBivariateSpline", + "LSQSphereBivariateSpline", + "LSQUnivariateSpline", + "LinearNDInterpolator", + "NdBSpline", + "NdPPoly", + "NearestNDInterpolator", + "PPoly", + "PchipInterpolator", + "RBFInterpolator", + "Rbf", + "RectBivariateSpline", + "RectSphereBivariateSpline", + "RegularGridInterpolator", + "SmoothBivariateSpline", + "SmoothSphereBivariateSpline", + "UnivariateSpline", + "approximate_taylor_polynomial", + "barycentric_interpolate", + "bisplev", + "bisplrep", + "fitpack", + "fitpack2", + "griddata", + "insert", + "interp1d", + "interp2d", + "interpn", + "interpnd", + "interpolate", + "krogh_interpolate", + "lagrange", + "make_interp_spline", + "make_lsq_spline", + "make_smoothing_spline", + "ndgriddata", + "pade", + "pchip_interpolate", + "polyint", + "rbf", + "spalde", + "splantider", + "splder", + "splev", + "splint", + "splprep", + "splrep", + "sproot", +] diff --git a/scipy-stubs/interpolate/_aaa.pyi b/scipy-stubs/interpolate/_aaa.pyi deleted file mode 100644 index 9aa0f627..00000000 --- a/scipy-stubs/interpolate/_aaa.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from scipy._typing import Untyped - -class AAA: - def __init__(self, points, values, *, rtol: Untyped | None = None, max_terms: int = 100): ... - def __call__(self, z) -> Untyped: ... - def poles(self) -> Untyped: ... - def residues(self) -> Untyped: ... - def roots(self) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_bsplines.pyi b/scipy-stubs/interpolate/_bsplines.pyi index ced25b28..62fd8e3a 100644 --- a/scipy-stubs/interpolate/_bsplines.pyi +++ b/scipy-stubs/interpolate/_bsplines.pyi @@ -1,16 +1,6 @@ -from scipy._lib._util import normalize_axis_index as normalize_axis_index from scipy._typing import Untyped -from scipy.linalg import ( - LinAlgError as LinAlgError, - cho_solve_banded as cho_solve_banded, - cholesky_banded as cholesky_banded, - get_lapack_funcs as get_lapack_funcs, - solve as solve, - solve_banded as solve_banded, -) -from scipy.optimize import minimize_scalar as minimize_scalar -from scipy.sparse import csr_array as csr_array -from scipy.special import poch as poch + +__all__ = ["BSpline", "make_interp_spline", "make_lsq_spline", "make_smoothing_spline"] class BSpline: k: Untyped @@ -18,26 +8,45 @@ class BSpline: t: Untyped extrapolate: Untyped axis: Untyped - def __init__(self, t, c, k, extrapolate: bool = True, axis: int = 0): ... - @classmethod - def construct_fast(cls, t, c, k, extrapolate: bool = True, axis: int = 0) -> Untyped: ... @property def tck(self) -> Untyped: ... - @classmethod - def basis_element(cls, t, extrapolate: bool = True) -> Untyped: ... - @classmethod - def design_matrix(cls, x, t, k, extrapolate: bool = False) -> Untyped: ... - def __call__(self, x, nu: int = 0, extrapolate: Untyped | None = None) -> Untyped: ... + def __init__(self, t: Untyped, c: Untyped, k: Untyped, extrapolate: bool = True, axis: int = 0) -> None: ... + def __call__(self, x: Untyped, nu: int = 0, extrapolate: Untyped | None = None) -> Untyped: ... def derivative(self, nu: int = 1) -> Untyped: ... def antiderivative(self, nu: int = 1) -> Untyped: ... - def integrate(self, a, b, extrapolate: Untyped | None = None) -> Untyped: ... + def integrate(self, a: Untyped, b: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... + def insert_knot(self, x: Untyped, m: int = 1) -> Untyped: ... + @classmethod + def basis_element(cls, t: Untyped, extrapolate: bool = True) -> Untyped: ... @classmethod - def from_power_basis(cls, pp, bc_type: str = "not-a-knot") -> Untyped: ... - def insert_knot(self, x, m: int = 1) -> Untyped: ... + def design_matrix(cls, x: Untyped, t: Untyped, k: Untyped, extrapolate: bool = False) -> Untyped: ... + @classmethod + def from_power_basis(cls, pp: Untyped, bc_type: str = "not-a-knot") -> Untyped: ... + @classmethod + def construct_fast(cls, t: Untyped, c: Untyped, k: Untyped, extrapolate: bool = True, axis: int = 0) -> Untyped: ... def make_interp_spline( - x, y, k: int = 3, t: Untyped | None = None, bc_type: Untyped | None = None, axis: int = 0, check_finite: bool = True + x: Untyped, + y: Untyped, + k: int = 3, + t: Untyped | None = None, + bc_type: Untyped | None = None, + axis: int = 0, + check_finite: bool = True, +) -> Untyped: ... +def make_lsq_spline( + x: Untyped, + y: Untyped, + t: Untyped, + k: int = 3, + w: Untyped | None = None, + axis: int = 0, + check_finite: bool = True, +) -> Untyped: ... +def make_smoothing_spline( + x: Untyped, + y: Untyped, + w: Untyped | None = None, + lam: Untyped | None = None, ) -> Untyped: ... -def make_lsq_spline(x, y, t, k: int = 3, w: Untyped | None = None, axis: int = 0, check_finite: bool = True) -> Untyped: ... -def make_smoothing_spline(x, y, w: Untyped | None = None, lam: Untyped | None = None) -> Untyped: ... -def fpcheck(x, t, k): ... +def fpcheck(x: Untyped, t: Untyped, k: Untyped) -> None: ... # undocumented diff --git a/scipy-stubs/interpolate/_cubic.pyi b/scipy-stubs/interpolate/_cubic.pyi index a2175738..d2b04bb1 100644 --- a/scipy-stubs/interpolate/_cubic.pyi +++ b/scipy-stubs/interpolate/_cubic.pyi @@ -1,30 +1,39 @@ from typing import Literal +from typing_extensions import override from scipy._typing import Untyped -from scipy.linalg import solve as solve, solve_banded as solve_banded -from . import PPoly as PPoly +from ._interpolate import PPoly -def prepare_input(x, y, axis, dydx: Untyped | None = None) -> Untyped: ... +__all__ = ["Akima1DInterpolator", "CubicHermiteSpline", "CubicSpline", "PchipInterpolator", "pchip_interpolate"] class CubicHermiteSpline(PPoly): - axis: Untyped - def __init__(self, x, y, dydx, axis: int = 0, extrapolate: Untyped | None = None): ... + def __init__(self, x: Untyped, y: Untyped, dydx: Untyped, axis: int = 0, extrapolate: Untyped | None = None) -> None: ... class PchipInterpolator(CubicHermiteSpline): - axis: Untyped - def __init__(self, x, y, axis: int = 0, extrapolate: Untyped | None = None): ... - -def pchip_interpolate(xi, yi, x, der: int = 0, axis: int = 0) -> Untyped: ... + def __init__(self, x: Untyped, y: Untyped, axis: int = 0, extrapolate: Untyped | None = None) -> None: ... class Akima1DInterpolator(CubicHermiteSpline): - axis: Untyped - def __init__(self, x, y, axis: int = 0, *, method: Literal["akima", "makima"] = "akima", extrapolate: bool | None = None): ... - def extend(self, c, x, right: bool = True): ... - @classmethod - def from_spline(cls, tck, extrapolate: Untyped | None = None): ... - @classmethod - def from_bernstein_basis(cls, bp, extrapolate: Untyped | None = None): ... + def __init__( + self, + x: Untyped, + y: Untyped, + axis: int = 0, + *, + method: Literal["akima", "makima"] = "akima", + extrapolate: bool | None = None, + ) -> None: ... + @override + def extend(self, c: Untyped, x: Untyped, right: bool = True) -> None: ... class CubicSpline(CubicHermiteSpline): - axis: Untyped - def __init__(self, x, y, axis: int = 0, bc_type: str = "not-a-knot", extrapolate: Untyped | None = None): ... + def __init__( + self, + x: Untyped, + y: Untyped, + axis: int = 0, + bc_type: str = "not-a-knot", + extrapolate: Untyped | None = None, + ) -> None: ... + +def prepare_input(x: Untyped, y: Untyped, axis: Untyped, dydx: Untyped | None = None) -> Untyped: ... # undocumented +def pchip_interpolate(xi: Untyped, yi: Untyped, x: Untyped, der: int = 0, axis: int = 0) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_fitpack2.pyi b/scipy-stubs/interpolate/_fitpack2.pyi index bd9d0b11..c65ef913 100644 --- a/scipy-stubs/interpolate/_fitpack2.pyi +++ b/scipy-stubs/interpolate/_fitpack2.pyi @@ -1,65 +1,95 @@ from typing_extensions import override +import numpy.typing as npt from scipy._typing import Untyped -dfitpack_int: Untyped +__all__ = [ + "BivariateSpline", + "InterpolatedUnivariateSpline", + "LSQBivariateSpline", + "LSQSphereBivariateSpline", + "LSQUnivariateSpline", + "RectBivariateSpline", + "RectSphereBivariateSpline", + "SmoothBivariateSpline", + "SmoothSphereBivariateSpline", + "UnivariateSpline", +] + +dfitpack_int: Untyped # undocumented class UnivariateSpline: + # at runtime the `__init__` might change the `__class__` attribute... def __init__( self, - x, - y, - /, - *, - w: Untyped | None = None, - bbox=..., + x: npt.ArrayLike, + y: npt.ArrayLike, + w: npt.ArrayLike | None = None, + bbox: npt.ArrayLike = ..., k: int = 3, - s: Untyped | None = None, - ext: int = 0, + s: float | None = None, + ext: int | str = 0, check_finite: bool = False, - ): ... - @staticmethod - def validate_input(x, y, w, bbox, k, s, ext, check_finite) -> Untyped: ... - def set_smoothing_factor(self, s): ... - def __call__(self, x, nu: int = 0, ext: Untyped | None = None) -> Untyped: ... + ) -> None: ... + def __call__(self, x: Untyped, nu: int = 0, ext: Untyped | None = None) -> Untyped: ... + def set_smoothing_factor(self, s: Untyped) -> None: ... def get_knots(self) -> Untyped: ... def get_coeffs(self) -> Untyped: ... def get_residual(self) -> Untyped: ... - def integral(self, a, b) -> Untyped: ... - def derivatives(self, x) -> Untyped: ... + def integral(self, a: Untyped, b: Untyped) -> Untyped: ... + def derivatives(self, x: Untyped) -> Untyped: ... def roots(self) -> Untyped: ... def derivative(self, n: int = 1) -> Untyped: ... def antiderivative(self, n: int = 1) -> Untyped: ... + @staticmethod + def validate_input( + x: npt.ArrayLike, + y: npt.ArrayLike, + w: npt.ArrayLike, + bbox: npt.ArrayLike, + k: int, + s: float | None, + ext: int, + check_finite: bool, + ) -> Untyped: ... -class InterpolatedUnivariateSpline(UnivariateSpline): ... +class InterpolatedUnivariateSpline(UnivariateSpline): + def __init__( + self, + x: npt.ArrayLike, + y: npt.ArrayLike, + w: npt.ArrayLike | None = None, + bbox: npt.ArrayLike = ..., + k: int = 3, + ext: int | str = 0, + check_finite: bool = False, + ) -> None: ... class LSQUnivariateSpline(UnivariateSpline): def __init__( self, - x, - y, - t, - /, - *, - w: Untyped | None = None, - bbox=..., + x: npt.ArrayLike, + y: npt.ArrayLike, + t: npt.ArrayLike, + w: npt.ArrayLike | None = None, + bbox: npt.ArrayLike = ..., k: int = 3, ext: int = 0, check_finite: bool = False, ) -> None: ... -class _BivariateSplineBase: +class _BivariateSplineBase: # undocumented + def __call__(self, x: Untyped, y: Untyped, dx: int = 0, dy: int = 0, grid: bool = True) -> Untyped: ... def get_residual(self) -> Untyped: ... def get_knots(self) -> Untyped: ... def get_coeffs(self) -> Untyped: ... - def __call__(self, x, y, dx: int = 0, dy: int = 0, /, *, grid: bool = True) -> Untyped: ... - def partial_derivative(self, dx, dy) -> Untyped: ... + def partial_derivative(self, dx: Untyped, dy: Untyped) -> Untyped: ... class BivariateSpline(_BivariateSplineBase): - def ev(self, xi, yi, dx: int = 0, dy: int = 0) -> Untyped: ... - def integral(self, xa, xb, ya, yb) -> Untyped: ... + def ev(self, xi: Untyped, yi: Untyped, dx: int = 0, dy: int = 0) -> Untyped: ... + def integral(self, xa: Untyped, xb: Untyped, ya: Untyped, yb: Untyped) -> Untyped: ... -class _DerivedBivariateSpline(_BivariateSplineBase): +class _DerivedBivariateSpline(_BivariateSplineBase): # undocumented @property def fp(self) -> Untyped: ... @@ -67,15 +97,14 @@ class SmoothBivariateSpline(BivariateSpline): fp: Untyped tck: Untyped degrees: Untyped + def __init__( self, - x, - y, - z, - /, - *, + x: Untyped, + y: Untyped, + z: Untyped, w: Untyped | None = None, - bbox=..., + bbox: Untyped = ..., kx: int = 3, ky: int = 3, s: Untyped | None = None, @@ -88,15 +117,13 @@ class LSQBivariateSpline(BivariateSpline): degrees: Untyped def __init__( self, - x, - y, - z, - /, - tx, - ty, - *, + x: Untyped, + y: Untyped, + z: Untyped, + tx: Untyped, + ty: Untyped, w: Untyped | None = None, - bbox=..., + bbox: Untyped = ..., kx: int = 3, ky: int = 3, eps: Untyped | None = None, @@ -106,28 +133,77 @@ class RectBivariateSpline(BivariateSpline): fp: Untyped tck: Untyped degrees: Untyped - def __init__(self, x, y, z, /, *, bbox=..., kx: int = 3, ky: int = 3, s: int = 0) -> None: ... + + def __init__( + self, + x: Untyped, + y: Untyped, + z: Untyped, + bbox: Untyped = ..., + kx: int = 3, + ky: int = 3, + s: int = 0, + ) -> None: ... class SphereBivariateSpline(_BivariateSplineBase): @override - def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, /, *, grid: bool = True) -> Untyped: ... - def ev(self, theta, phi, dtheta: int = 0, dphi: int = 0) -> Untyped: ... + def __call__( # type: ignore[override] + self, + theta: Untyped, + phi: Untyped, + dtheta: int = 0, + dphi: int = 0, + grid: bool = True, + ) -> Untyped: ... + def ev(self, theta: Untyped, phi: Untyped, dtheta: int = 0, dphi: int = 0) -> Untyped: ... class SmoothSphereBivariateSpline(SphereBivariateSpline): fp: Untyped tck: Untyped degrees: Untyped - def __init__(self, theta, phi, r, /, *, w: Untyped | None = None, s: float = 0.0, eps: float = 1e-16) -> None: ... + + def __init__( + self, + theta: Untyped, + phi: Untyped, + r: Untyped, + w: Untyped | None = None, + s: float = 0.0, + eps: float = 1e-16, + ) -> None: ... @override - def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, /, *, grid: bool = True) -> Untyped: ... + def __call__( # type: ignore[override] + self, + theta: Untyped, + phi: Untyped, + dtheta: int = 0, + dphi: int = 0, + grid: bool = True, + ) -> Untyped: ... class LSQSphereBivariateSpline(SphereBivariateSpline): fp: Untyped tck: Untyped degrees: Untyped - def __init__(self, theta, phi, r, /, tt, tp, *, w: Untyped | None = None, eps: float = 1e-16) -> None: ... + def __init__( + self, + theta: Untyped, + phi: Untyped, + r: Untyped, + tt: Untyped, + tp: Untyped, + w: Untyped | None = None, + eps: float = 1e-16, + ) -> None: ... @override - def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, /, *, grid: bool = True) -> Untyped: ... + def __call__( # type: ignore[override] + self, + theta: Untyped, + phi: Untyped, + dtheta: int = 0, + dphi: int = 0, + grid: bool = True, + ) -> Untyped: ... class RectSphereBivariateSpline(SphereBivariateSpline): fp: Untyped @@ -136,16 +212,21 @@ class RectSphereBivariateSpline(SphereBivariateSpline): v0: Untyped def __init__( self, - u, - v, - r, - /, + u: Untyped, + v: Untyped, + r: Untyped, s: float = 0.0, - *, pole_continuity: bool = False, pole_values: Untyped | None = None, pole_exact: bool = False, pole_flat: bool = False, ) -> None: ... @override - def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, /, *, grid: bool = True) -> Untyped: ... + def __call__( # type: ignore[override] + self, + theta: Untyped, + phi: Untyped, + dtheta: int = 0, + dphi: int = 0, + grid: bool = True, + ) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_fitpack_impl.pyi b/scipy-stubs/interpolate/_fitpack_impl.pyi index 45b05927..54d9bac2 100644 --- a/scipy-stubs/interpolate/_fitpack_impl.pyi +++ b/scipy-stubs/interpolate/_fitpack_impl.pyi @@ -1,9 +1,23 @@ from scipy._typing import Untyped +__all__ = [ + "bisplev", + "bisplrep", + "insert", + "spalde", + "splantider", + "splder", + "splev", + "splint", + "splprep", + "splrep", + "sproot", +] + dfitpack_int: Untyped def splprep( - x, + x: Untyped, w: Untyped | None = None, u: Untyped | None = None, ub: Untyped | None = None, @@ -18,8 +32,8 @@ def splprep( quiet: int = 1, ) -> Untyped: ... def splrep( - x, - y, + x: Untyped, + y: Untyped, w: Untyped | None = None, xb: Untyped | None = None, xe: Untyped | None = None, @@ -31,14 +45,14 @@ def splrep( per: int = 0, quiet: int = 1, ) -> Untyped: ... -def splev(x, tck, der: int = 0, ext: int = 0) -> Untyped: ... -def splint(a, b, tck, full_output: int = 0) -> Untyped: ... -def sproot(tck, mest: int = 10) -> Untyped: ... -def spalde(x, tck) -> Untyped: ... +def splev(x: Untyped, tck: Untyped, der: int = 0, ext: int = 0) -> Untyped: ... +def splint(a: Untyped, b: Untyped, tck: Untyped, full_output: int = 0) -> Untyped: ... +def sproot(tck: Untyped, mest: int = 10) -> Untyped: ... +def spalde(x: Untyped, tck: Untyped) -> Untyped: ... def bisplrep( - x, - y, - z, + x: Untyped, + y: Untyped, + z: Untyped, w: Untyped | None = None, xb: Untyped | None = None, xe: Untyped | None = None, @@ -56,8 +70,8 @@ def bisplrep( nyest: Untyped | None = None, quiet: int = 1, ) -> Untyped: ... -def bisplev(x, y, tck, dx: int = 0, dy: int = 0) -> Untyped: ... -def dblint(xa, xb, ya, yb, tck) -> Untyped: ... -def insert(x, tck, m: int = 1, per: int = 0) -> Untyped: ... -def splder(tck, n: int = 1) -> Untyped: ... -def splantider(tck, n: int = 1) -> Untyped: ... +def bisplev(x: Untyped, y: Untyped, tck: Untyped, dx: int = 0, dy: int = 0) -> Untyped: ... +def dblint(xa: Untyped, xb: Untyped, ya: Untyped, yb: Untyped, tck: Untyped) -> Untyped: ... +def insert(x: Untyped, tck: Untyped, m: int = 1, per: int = 0) -> Untyped: ... +def splder(tck: Untyped, n: int = 1) -> Untyped: ... +def splantider(tck: Untyped, n: int = 1) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_fitpack_py.pyi b/scipy-stubs/interpolate/_fitpack_py.pyi index cfe5e398..581e495d 100644 --- a/scipy-stubs/interpolate/_fitpack_py.pyi +++ b/scipy-stubs/interpolate/_fitpack_py.pyi @@ -1,9 +1,22 @@ from scipy._typing import Untyped -from ._bsplines import BSpline as BSpline -from ._fitpack_impl import bisplev as bisplev, bisplrep as bisplrep, dblint as dblint +from ._fitpack_impl import bisplev, bisplrep + +__all__ = [ + "bisplev", + "bisplrep", + "insert", + "spalde", + "splantider", + "splder", + "splev", + "splint", + "splprep", + "splrep", + "sproot", +] def splprep( - x, + x: Untyped, w: Untyped | None = None, u: Untyped | None = None, ub: Untyped | None = None, @@ -18,8 +31,8 @@ def splprep( quiet: int = 1, ) -> Untyped: ... def splrep( - x, - y, + x: Untyped, + y: Untyped, w: Untyped | None = None, xb: Untyped | None = None, xe: Untyped | None = None, @@ -31,10 +44,10 @@ def splrep( per: int = 0, quiet: int = 1, ) -> Untyped: ... -def splev(x, tck, der: int = 0, ext: int = 0) -> Untyped: ... -def splint(a, b, tck, full_output: int = 0) -> Untyped: ... -def sproot(tck, mest: int = 10) -> Untyped: ... -def spalde(x, tck) -> Untyped: ... -def insert(x, tck, m: int = 1, per: int = 0) -> Untyped: ... -def splder(tck, n: int = 1) -> Untyped: ... -def splantider(tck, n: int = 1) -> Untyped: ... +def splev(x: Untyped, tck: Untyped, der: int = 0, ext: int = 0) -> Untyped: ... +def splint(a: Untyped, b: Untyped, tck: Untyped, full_output: int = 0) -> Untyped: ... +def sproot(tck: Untyped, mest: int = 10) -> Untyped: ... +def spalde(x: Untyped, tck: Untyped) -> Untyped: ... +def insert(x: Untyped, tck: Untyped, m: int = 1, per: int = 0) -> Untyped: ... +def splder(tck: Untyped, n: int = 1) -> Untyped: ... +def splantider(tck: Untyped, n: int = 1) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_interpnd_info.pyi b/scipy-stubs/interpolate/_interpnd_info.pyi deleted file mode 100644 index e69de29b..00000000 diff --git a/scipy-stubs/interpolate/_interpolate.pyi b/scipy-stubs/interpolate/_interpolate.pyi index 837d89fb..cb8239ca 100644 --- a/scipy-stubs/interpolate/_interpolate.pyi +++ b/scipy-stubs/interpolate/_interpolate.pyi @@ -1,17 +1,21 @@ -from scipy._lib._util import copy_if_needed as copy_if_needed from scipy._typing import Untyped -from scipy.special import comb as comb -from ._bsplines import BSpline as BSpline, make_interp_spline as make_interp_spline from ._polyint import _Interpolator1D -def lagrange(x, w) -> Untyped: ... +__all__ = ["BPoly", "NdPPoly", "PPoly", "interp1d", "interp2d", "lagrange"] -err_mesg: str +err_mesg: str # undocumented class interp2d: def __init__( - self, x, y, z, kind: str = "linear", copy: bool = True, bounds_error: bool = False, fill_value: Untyped | None = None - ): ... + self, + x: Untyped, + y: Untyped, + z: Untyped, + kind: str = "linear", + copy: bool = True, + bounds_error: bool = False, + fill_value: Untyped | None = None, + ) -> None: ... class interp1d(_Interpolator1D): bounds_error: Untyped @@ -22,62 +26,65 @@ class interp1d(_Interpolator1D): x_bds: Untyped def __init__( self, - x, - y, + x: Untyped, + y: Untyped, kind: str = "linear", axis: int = -1, copy: bool = True, bounds_error: Untyped | None = None, - fill_value=..., + fill_value: Untyped = ..., assume_sorted: bool = False, - ): ... + ) -> None: ... @property def fill_value(self) -> Untyped: ... @fill_value.setter - def fill_value(self, fill_value): ... + def fill_value(self, fill_value: Untyped) -> None: ... class _PPolyBase: c: Untyped x: Untyped extrapolate: Untyped axis: Untyped - def __init__(self, c, x, extrapolate: Untyped | None = None, axis: int = 0): ... + def __init__(self, c: Untyped, x: Untyped, extrapolate: Untyped | None = None, axis: int = 0) -> None: ... @classmethod - def construct_fast(cls, c, x, extrapolate: Untyped | None = None, axis: int = 0) -> Untyped: ... - def extend(self, c, x): ... - def __call__(self, x, nu: int = 0, extrapolate: Untyped | None = None) -> Untyped: ... + def construct_fast(cls, c: Untyped, x: Untyped, extrapolate: Untyped | None = None, axis: int = 0) -> Untyped: ... + def extend(self, c: Untyped, x: Untyped) -> None: ... + def __call__(self, x: Untyped, nu: int = 0, extrapolate: Untyped | None = None) -> Untyped: ... class PPoly(_PPolyBase): def derivative(self, nu: int = 1) -> Untyped: ... def antiderivative(self, nu: int = 1) -> Untyped: ... - def integrate(self, a, b, extrapolate: Untyped | None = None) -> Untyped: ... + def integrate(self, a: Untyped, b: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... def solve(self, y: float = 0.0, discontinuity: bool = True, extrapolate: Untyped | None = None) -> Untyped: ... def roots(self, discontinuity: bool = True, extrapolate: Untyped | None = None) -> Untyped: ... @classmethod - def from_spline(cls, tck, extrapolate: Untyped | None = None) -> Untyped: ... + def from_spline(cls, tck: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... @classmethod - def from_bernstein_basis(cls, bp, extrapolate: Untyped | None = None) -> Untyped: ... + def from_bernstein_basis(cls, bp: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... class BPoly(_PPolyBase): def derivative(self, nu: int = 1) -> Untyped: ... def antiderivative(self, nu: int = 1) -> Untyped: ... - def integrate(self, a, b, extrapolate: Untyped | None = None) -> Untyped: ... - c: Untyped - def extend(self, c, x) -> Untyped: ... + def integrate(self, a: Untyped, b: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... @classmethod - def from_power_basis(cls, pp, extrapolate: Untyped | None = None) -> Untyped: ... + def from_power_basis(cls, pp: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... @classmethod - def from_derivatives(cls, xi, yi, orders: Untyped | None = None, extrapolate: Untyped | None = None) -> Untyped: ... + def from_derivatives( + cls, + xi: Untyped, + yi: Untyped, + orders: Untyped | None = None, + extrapolate: Untyped | None = None, + ) -> Untyped: ... class NdPPoly: - x: Untyped - c: Untyped - extrapolate: Untyped - def __init__(self, c, x, extrapolate: Untyped | None = None): ... + def __init__(self, c: Untyped, x: Untyped, extrapolate: Untyped | None = None) -> None: ... @classmethod - def construct_fast(cls, c, x, extrapolate: Untyped | None = None) -> Untyped: ... - def __call__(self, x, nu: Untyped | None = None, extrapolate: Untyped | None = None) -> Untyped: ... - def derivative(self, nu) -> Untyped: ... - def antiderivative(self, nu) -> Untyped: ... - def integrate_1d(self, a, b, axis, extrapolate: Untyped | None = None) -> Untyped: ... - def integrate(self, ranges, extrapolate: Untyped | None = None) -> Untyped: ... + def construct_fast(cls, c: Untyped, x: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... + def __call__(self, x: Untyped, nu: Untyped | None = None, extrapolate: Untyped | None = None) -> Untyped: ... + def derivative(self, nu: Untyped) -> Untyped: ... + def antiderivative(self, nu: Untyped) -> Untyped: ... + def integrate_1d(self, a: Untyped, b: Untyped, axis: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... + def integrate(self, ranges: Untyped, extrapolate: Untyped | None = None) -> Untyped: ... + +def lagrange(x: Untyped, w: Untyped) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_ndbspline.pyi b/scipy-stubs/interpolate/_ndbspline.pyi index 11008750..8cb85cdd 100644 --- a/scipy-stubs/interpolate/_ndbspline.pyi +++ b/scipy-stubs/interpolate/_ndbspline.pyi @@ -1,14 +1,23 @@ from scipy._typing import Untyped -from scipy.sparse import csr_array as csr_array + +__all__ = ["NdBSpline"] class NdBSpline: k: Untyped t: Untyped c: Untyped extrapolate: Untyped - def __init__(self, t, c, k, *, extrapolate: Untyped | None = None): ... - def __call__(self, xi, *, nu: Untyped | None = None, extrapolate: Untyped | None = None) -> Untyped: ... + + def __init__(self, t: Untyped, c: Untyped, k: Untyped, *, extrapolate: bool | None = None) -> None: ... + def __call__(self, xi: Untyped, *, nu: Untyped | None = None, extrapolate: bool | None = None) -> Untyped: ... @classmethod - def design_matrix(cls, xvals, t, k, extrapolate: bool = True) -> Untyped: ... + def design_matrix(cls, xvals: Untyped, t: Untyped, k: Untyped, extrapolate: bool = True) -> Untyped: ... -def make_ndbspl(points, values, k: int = 3, *, solver=..., **solver_args) -> Untyped: ... +def make_ndbspl( + points: Untyped, + values: Untyped, + k: int = 3, + *, + solver: Untyped = ..., + **solver_args: Untyped, +) -> Untyped: ... # undocumented diff --git a/scipy-stubs/interpolate/_pade.pyi b/scipy-stubs/interpolate/_pade.pyi index 69a0925c..23cb7877 100644 --- a/scipy-stubs/interpolate/_pade.pyi +++ b/scipy-stubs/interpolate/_pade.pyi @@ -1,4 +1,6 @@ -from scipy import linalg as linalg -from scipy._typing import Untyped +import numpy as np +import numpy.typing as npt -def pade(an, m, n: Untyped | None = None) -> Untyped: ... +__all__ = ["pade"] + +def pade(an: npt.ArrayLike, m: int, n: int | None = None) -> tuple[np.poly1d, np.poly1d]: ... diff --git a/scipy-stubs/interpolate/_polyint.pyi b/scipy-stubs/interpolate/_polyint.pyi index 0a1aa6c6..522034bb 100644 --- a/scipy-stubs/interpolate/_polyint.pyi +++ b/scipy-stubs/interpolate/_polyint.pyi @@ -1,36 +1,52 @@ -from scipy._lib._util import check_random_state as check_random_state, float_factorial as float_factorial from scipy._typing import Untyped -from scipy.special import factorial as factorial -class _Interpolator1D: +__all__ = [ + "BarycentricInterpolator", + "KroghInterpolator", + "approximate_taylor_polynomial", + "barycentric_interpolate", + "krogh_interpolate", +] + +class _Interpolator1D: # undocumented dtype: Untyped - def __init__(self, xi: Untyped | None = None, yi: Untyped | None = None, axis: Untyped | None = None): ... - def __call__(self, x) -> Untyped: ... + def __init__(self, xi: Untyped | None = None, yi: Untyped | None = None, axis: Untyped | None = None) -> None: ... + def __call__(self, x: Untyped) -> Untyped: ... -class _Interpolator1DWithDerivatives(_Interpolator1D): - def derivatives(self, x, der: Untyped | None = None) -> Untyped: ... - def derivative(self, x, der: int = 1) -> Untyped: ... +class _Interpolator1DWithDerivatives(_Interpolator1D): # undocumented + def derivatives(self, x: Untyped, der: Untyped | None = None) -> Untyped: ... + def derivative(self, x: Untyped, der: int = 1) -> Untyped: ... class KroghInterpolator(_Interpolator1DWithDerivatives): xi: Untyped yi: Untyped c: Untyped - def __init__(self, xi, yi, axis: int = 0): ... - -def krogh_interpolate(xi, yi, x, der: int = 0, axis: int = 0) -> Untyped: ... -def approximate_taylor_polynomial(f, x, degree, scale, order: Untyped | None = None) -> Untyped: ... + def __init__(self, xi: Untyped, yi: Untyped, axis: int = 0) -> None: ... class BarycentricInterpolator(_Interpolator1DWithDerivatives): xi: Untyped n: Untyped wi: Untyped - def __init__( - self, xi, yi: Untyped | None = None, axis: int = 0, *, wi: Untyped | None = None, random_state: Untyped | None = None - ): ... yi: Untyped - def set_yi(self, yi, axis: Untyped | None = None): ... - def add_xi(self, xi, yi: Untyped | None = None): ... - def __call__(self, x) -> Untyped: ... - def derivative(self, x, der: int = 1) -> Untyped: ... -def barycentric_interpolate(xi, yi, x, axis: int = 0, *, der: int = 0) -> Untyped: ... + def __init__( + self, + xi: Untyped, + yi: Untyped | None = None, + axis: int = 0, + *, + wi: Untyped | None = None, + random_state: Untyped | None = None, + ) -> None: ... + def set_yi(self, yi: Untyped, axis: Untyped | None = None) -> None: ... + def add_xi(self, xi: Untyped, yi: Untyped | None = None) -> None: ... + +def krogh_interpolate(xi: Untyped, yi: Untyped, x: Untyped, der: int = 0, axis: int = 0) -> Untyped: ... +def approximate_taylor_polynomial( + f: Untyped, + x: Untyped, + degree: Untyped, + scale: Untyped, + order: Untyped | None = None, +) -> Untyped: ... +def barycentric_interpolate(xi: Untyped, yi: Untyped, x: Untyped, axis: int = 0, *, der: int = 0) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_rbf.pyi b/scipy-stubs/interpolate/_rbf.pyi index 8dea9876..8b644fe1 100644 --- a/scipy-stubs/interpolate/_rbf.pyi +++ b/scipy-stubs/interpolate/_rbf.pyi @@ -1,7 +1,6 @@ -from scipy import linalg as linalg from scipy._typing import Untyped -from scipy.spatial.distance import cdist as cdist, pdist as pdist, squareform as squareform -from scipy.special import xlogy as xlogy + +__all__ = ["Rbf"] class Rbf: xi: Untyped @@ -13,7 +12,7 @@ class Rbf: smooth: Untyped function: Untyped nodes: Untyped - def __init__(self, *args, **kwargs) -> None: ... @property def A(self) -> Untyped: ... - def __call__(self, *args) -> Untyped: ... + def __init__(self, *args: Untyped, **kwargs: Untyped) -> None: ... + def __call__(self, *args: Untyped) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_rbfinterp_pythran.pyi b/scipy-stubs/interpolate/_rbfinterp_pythran.pyi index e049936d..58c51223 100644 --- a/scipy-stubs/interpolate/_rbfinterp_pythran.pyi +++ b/scipy-stubs/interpolate/_rbfinterp_pythran.pyi @@ -1,17 +1 @@ -from scipy._typing import Untyped - -def linear(r) -> Untyped: ... -def thin_plate_spline(r) -> Untyped: ... -def cubic(r) -> Untyped: ... -def quintic(r) -> Untyped: ... -def multiquadric(r) -> Untyped: ... -def inverse_multiquadric(r) -> Untyped: ... -def inverse_quadratic(r) -> Untyped: ... -def gaussian(r) -> Untyped: ... - -NAME_TO_FUNC: Untyped - -def kernel_vector(x, y, kernel_func, out): ... -def polynomial_vector(x, powers, out): ... -def kernel_matrix(x, kernel_func, out): ... -def polynomial_matrix(x, powers, out): ... +__pythran__: tuple[str, str] diff --git a/scipy-stubs/interpolate/interpnd.pyi b/scipy-stubs/interpolate/interpnd.pyi index 6e7b2b43..eebf00b7 100644 --- a/scipy-stubs/interpolate/interpnd.pyi +++ b/scipy-stubs/interpolate/interpnd.pyi @@ -4,6 +4,9 @@ from typing_extensions import override import numpy as np import numpy.typing as npt import optype.numpy as onpt +from scipy._typing import Untyped + +class GradientEstimationWarning(Warning): ... class NDInterpolatorBase: def __init__( @@ -42,3 +45,5 @@ class CloughTocher2DInterpolator(NDInterpolatorBase): maxiter: int = 400, rescale: bool = False, ) -> None: ... + +def estimate_gradients_2d_global(tri: Untyped, y: npt.ArrayLike, maxiter: int = 400, tol: float = 1e-6) -> Untyped: ... diff --git a/scipy-stubs/interpolate/interpolate.pyi b/scipy-stubs/interpolate/interpolate.pyi index 70a2f101..cdc03787 100644 --- a/scipy-stubs/interpolate/interpolate.pyi +++ b/scipy-stubs/interpolate/interpolate.pyi @@ -1,6 +1,11 @@ # This module is not meant for public use and will be removed in SciPy v2.0.0. from typing_extensions import deprecated +from ._bsplines import BSpline as _BSpline +from ._fitpack2 import RectBivariateSpline as _RectBivariateSpline +from ._interpolate import BPoly as _BPoly, NdPPoly as _NdPPoly, PPoly as _PPoly, interp1d as _interp1d, interp2d as _interp2d +from ._rgi import RegularGridInterpolator as _RegularGridInterpolator + __all__ = [ "BPoly", "BSpline", @@ -15,127 +20,48 @@ __all__ = [ "make_interp_spline", ] -# _fitpack2 @deprecated("will be removed in SciPy v2.0.0") -class RectBivariateSpline: - def __init__( - self, x: object, y: object, z: object, /, *, bbox: object = ..., kx: object = ..., ky: object = ..., s: object = ... - ) -> None: ... +class RectBivariateSpline(_RectBivariateSpline): ... -# _rgi @deprecated("will be removed in SciPy v2.0.0") -class RegularGridInterpolator: - def __init__( - self, - points: object, - values: object, - method: object = ..., - bounds_error: object = ..., - fill_value: object = ..., - *, - solver: object = ..., - solver_args: object = ..., - ) -> None: ... - def __call__(self, xi: object, method: object = ..., *, nu: object = ...) -> object: ... +class RegularGridInterpolator(_RegularGridInterpolator): ... @deprecated("will be removed in SciPy v2.0.0") -def interpn( - points: object, - values: object, - xi: object, - method: object = ..., - bounds_error: object = ..., - fill_value: object = ..., -) -> object: ... +class BPoly(_BPoly): ... -# _interpolate @deprecated("will be removed in SciPy v2.0.0") -class BPoly: - def derivative(self, nu: object = ...) -> object: ... - def antiderivative(self, nu: object = ...) -> object: ... - def integrate(self, a: object, b: object, extrapolate: object = ...) -> object: ... - def extend(self, c: object, x: object) -> object: ... - @classmethod - def from_power_basis(cls, pp: object, extrapolate: object = ...) -> object: ... - @classmethod - def from_derivatives(cls, xi: object, yi: object, orders: object = ..., extrapolate: object = ...) -> object: ... +class NdPPoly(_NdPPoly): ... @deprecated("will be removed in SciPy v2.0.0") -class NdPPoly: - def __init__(self, c: object, x: object, extrapolate: object = ...) -> None: ... - @classmethod - def construct_fast(cls, c: object, x: object, extrapolate: object = ...) -> object: ... - def __call__(self, x: object, nu: object = ..., extrapolate: object = ...) -> object: ... - def derivative(self, nu: object) -> object: ... - def antiderivative(self, nu: object) -> object: ... - def integrate_1d(self, a: object, b: object, axis: object, extrapolate: object = ...) -> object: ... - def integrate(self, ranges: object, extrapolate: object = ...) -> object: ... +class PPoly(_PPoly): ... @deprecated("will be removed in SciPy v2.0.0") -class PPoly: - def derivative(self, nu: object = ...) -> object: ... - def antiderivative(self, nu: object = ...) -> object: ... - def integrate(self, a: object, b: object, extrapolate: object = ...) -> object: ... - def solve(self, y: object = ..., discontinuity: object = ..., extrapolate: object = ...) -> object: ... - def roots(self, discontinuity: object = ..., extrapolate: object = ...) -> object: ... - @classmethod - def from_spline(cls, tck: object, extrapolate: object = ...) -> object: ... - @classmethod - def from_bernstein_basis(cls, bp: object, extrapolate: object = ...) -> object: ... +class BSpline(_BSpline): ... @deprecated("will be removed in SciPy v2.0.0") -class BSpline: - def __init__(self, t: object, c: object, k: object, extrapolate: object = ..., axis: object = ...) -> None: ... - @classmethod - def construct_fast(cls, t: object, c: object, k: object, extrapolate: object = ..., axis: object = ...) -> object: ... - @property - def tck(self) -> object: ... - @classmethod - def basis_element(cls, t: object, extrapolate: object = ...) -> object: ... - @classmethod - def design_matrix(cls, x: object, t: object, k: object, extrapolate: object = ...) -> object: ... - def __call__(self, x: object, nu: object = ..., extrapolate: object = ...) -> object: ... - def derivative(self, nu: object = ...) -> object: ... - def antiderivative(self, nu: object = ...) -> object: ... - def integrate(self, a: object, b: object, extrapolate: object = ...) -> object: ... - @classmethod - def from_power_basis(cls, pp: object, bc_type: object = ...) -> object: ... - def insert_knot(self, x: object, m: object = ...) -> object: ... +class interp1d(_interp1d): ... @deprecated("will be removed in SciPy v2.0.0") -class interp1d: - def __init__( - self, - x: object, - y: object, - kind: object = ..., - axis: object = ..., - copy: object = ..., - bounds_error: object = ..., - fill_value: object = ..., - assume_sorted: object = ..., - ) -> None: ... - @property - def fill_value(self) -> object: ... - @fill_value.setter - def fill_value(self, fill_value: object) -> None: ... +class interp2d(_interp2d): ... @deprecated("will be removed in SciPy v2.0.0") -class interp2d: - def __init__( - self, - x: object, - y: object, - z: object, - kind: object = ..., - copy: object = ..., - bounds_error: object = ..., - fill_value: object = ..., - ) -> None: ... - +def interpn( + points: object, + values: object, + xi: object, + method: object = ..., + bounds_error: object = ..., + fill_value: object = ..., +) -> object: ... @deprecated("will be removed in SciPy v2.0.0") def lagrange(x: object, w: object) -> object: ... @deprecated("will be removed in SciPy v2.0.0") def make_interp_spline( - x: object, y: object, k: object = ..., t: object = ..., bc_type: object = ..., axis: object = ..., check_finite: object = ... + x: object, + y: object, + k: object = ..., + t: object = ..., + bc_type: object = ..., + axis: object = ..., + check_finite: object = ..., ) -> object: ... diff --git a/tests/stubtest/allowlist.txt b/tests/stubtest/allowlist.txt index 1740f1e6..0c9da8f2 100644 --- a/tests/stubtest/allowlist.txt +++ b/tests/stubtest/allowlist.txt @@ -80,9 +80,6 @@ scipy.stats._unuran.unuran_wrapper # mypy hallucinations scipy._lib._ccallback.PyCFuncPtr # `final(T)` is impossible scipy.integrate._quadrature.QMCQuadResult.__replace__ # bruh... -scipy.interpolate.AAA -scipy.interpolate._aaa -scipy.interpolate._interpnd_info # TODO: scipy._lib._ccallback.__all__