Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👽️ interpolate: 1.15.0 support #338

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .mypyignore-todo
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
scipy\.interpolate\.__all__
scipy\.interpolate\.AAA
scipy\.interpolate\.FloaterHormannInterpolator
scipy\.interpolate\.(_bsplines\.)?make_lsq_spline
scipy\.interpolate\.(_ndbspline\.)?(An|N)dBSpline\.(k|t)
scipy\.interpolate\.(_?polyint\.)?BarycentricInterpolator\.__init__
scipy\.interpolate\.(_?polyint\.)?barycentric_interpolate
scipy\.interpolate\.generate_knots
scipy\.interpolate\.make_spl(p)?rep

scipy\.io\._idl\.AttrDict\.__init__
scipy\.io\._mmio\.MMFile\.read
scipy\.io\.(_?harwell_boeing\.(hb\.)?)?hb_read
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ reportIgnoreCommentWithoutRule = true # based
reportImplicitAbstractClass = true # based
reportImplicitOverride = true
reportImplicitRelativeImport = true # based
reportImplicitStringConcatenation = true # based
reportImplicitStringConcatenation = false # based, but I disagree
reportImportCycles = true
reportInvalidCast = true # based
reportInvalidStubStatement = false # see execution environments
Expand Down
40 changes: 32 additions & 8 deletions scipy-stubs/interpolate/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
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 ._bary_rational import AAA, FloaterHormannInterpolator
from ._bsplines import BSpline, make_interp_spline, make_lsq_spline, make_smoothing_spline
from ._cubic import Akima1DInterpolator, CubicHermiteSpline, CubicSpline, PchipInterpolator, pchip_interpolate
from ._fitpack2 import (
BivariateSpline,
InterpolatedUnivariateSpline,
LSQBivariateSpline,
LSQSphereBivariateSpline,
LSQUnivariateSpline,
RectBivariateSpline,
RectSphereBivariateSpline,
SmoothBivariateSpline,
SmoothSphereBivariateSpline,
UnivariateSpline,
)
from ._fitpack_py import bisplev, bisplrep, insert, spalde, splantider, splder, splev, splint, splprep, splrep, sproot
from ._fitpack_repro import generate_knots, make_splprep, make_splrep
from ._interpolate import BPoly, NdPPoly, PPoly, interp1d, interp2d, lagrange
from ._ndbspline import NdBSpline
from ._ndgriddata import *
from ._pade import *
from ._polyint import *
from ._ndgriddata import CloughTocher2DInterpolator, LinearNDInterpolator, NearestNDInterpolator, griddata
from ._pade import pade
from ._polyint import (
BarycentricInterpolator,
KroghInterpolator,
approximate_taylor_polynomial,
barycentric_interpolate,
krogh_interpolate,
)
from ._rbf import Rbf
from ._rbfinterp import RBFInterpolator
from ._rgi import RegularGridInterpolator, interpn

__all__ = [
"AAA",
"Akima1DInterpolator",
"BPoly",
"BSpline",
Expand All @@ -21,6 +41,7 @@ __all__ = [
"CloughTocher2DInterpolator",
"CubicHermiteSpline",
"CubicSpline",
"FloaterHormannInterpolator",
"InterpolatedUnivariateSpline",
"KroghInterpolator",
"LSQBivariateSpline",
Expand All @@ -46,6 +67,7 @@ __all__ = [
"bisplrep",
"fitpack",
"fitpack2",
"generate_knots",
"griddata",
"insert",
"interp1d",
Expand All @@ -58,6 +80,8 @@ __all__ = [
"make_interp_spline",
"make_lsq_spline",
"make_smoothing_spline",
"make_splprep",
"make_splrep",
"ndgriddata",
"pade",
"pchip_interpolate",
Expand Down
158 changes: 158 additions & 0 deletions scipy-stubs/interpolate/_bary_rational.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
from collections.abc import Sequence
from typing import Any, Generic, TypeAlias, overload
from typing_extensions import TypeVar

import numpy as np
import optype.numpy as onp

__all__ = ["AAA", "FloaterHormannInterpolator"]

_SCT = TypeVar("_SCT", bound=np.inexact[Any])
_SCT_co = TypeVar("_SCT_co", bound=np.inexact[Any], default=np.inexact[Any], covariant=True)
_ShapeT = TypeVar("_ShapeT", bound=tuple[int, ...])
_ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=tuple[int, ...], covariant=True)

_ToFloat16: TypeAlias = np.bool_ | np.integer[Any] | np.float16
_ToFloat64: TypeAlias = _ToFloat16 | np.float32 | np.float64
_ToComplex128: TypeAlias = _ToFloat64 | np.complex64 | np.complex128

###

class _BarycentricRational(Generic[_SCT_co, _ShapeT_co]):
def __init__(self, /, x: onp.ToComplex1D, y: onp.ToComplexND) -> None: ...

#
@overload
def __call__(
self: _BarycentricRational[_SCT, tuple[int]],
/,
z: onp.ArrayND[_SCT, _ShapeT],
) -> onp.ArrayND[_SCT, _ShapeT]: ...
@overload
def __call__(self, /, z: onp.ToFloat) -> onp.ArrayND[_SCT_co, _ShapeT_co]: ...
@overload
def __call__(self, /, z: onp.ToComplex) -> onp.ArrayND[np.inexact[Any], _ShapeT_co]: ...
@overload
def __call__(self, /, z: onp.ToComplexND) -> onp.ArrayND[np.inexact[Any]]: ...

#
def poles(self, /) -> onp.Array1D[np.complexfloating[Any, Any]]: ...
def roots(self, /) -> onp.Array1D[np.complexfloating[Any, Any]]: ...
def residues(self, /) -> onp.ArrayND[np.inexact[Any]]: ...

class AAA(_BarycentricRational[_SCT_co, tuple[int]], Generic[_SCT_co]):
weights: onp.Array1D[_SCT_co]

@property
def support_points(self) -> onp.Array1D[_SCT_co]: ...
@property
def support_values(self) -> onp.Array1D[_SCT_co]: ...

#
@overload
def __init__(
self,
x: onp.CanArrayND[_SCT_co] | Sequence[_SCT_co],
y: onp.CanArrayND[_SCT_co | _ToFloat16] | Sequence[_SCT_co | _ToFloat16],
*,
rtol: float | None = None,
max_terms: int = 100,
clean_up: bool = True,
clean_up_tol: float = 1e-13,
) -> None: ...
@overload
def __init__(
self: AAA[np.float64],
x: Sequence[float],
y: onp.CanArrayND[_ToFloat64] | Sequence[float | _ToFloat64],
*,
rtol: float | None = None,
max_terms: int = 100,
clean_up: bool = True,
clean_up_tol: float = 1e-13,
) -> None: ...
@overload
def __init__(
self: AAA[np.float64],
x: onp.CanArrayND[_ToFloat64] | Sequence[float | _ToFloat64],
y: Sequence[float],
*,
rtol: float | None = None,
max_terms: int = 100,
clean_up: bool = True,
clean_up_tol: float = 1e-13,
) -> None: ...
@overload
def __init__(
self: AAA[np.complex128],
x: Sequence[complex],
y: onp.CanArrayND[_ToFloat64] | Sequence[complex | _ToComplex128],
*,
rtol: float | None = None,
max_terms: int = 100,
clean_up: bool = True,
clean_up_tol: float = 1e-13,
) -> None: ...
@overload
def __init__(
self: AAA[np.complex128],
x: onp.CanArrayND[_ToComplex128] | Sequence[complex | _ToComplex128],
y: Sequence[complex],
*,
rtol: float | None = None,
max_terms: int = 100,
clean_up: bool = True,
clean_up_tol: float = 1e-13,
) -> None: ...

#
def clean_up(self, /, cleanup_tol: float = 1e-13) -> int: ...

class FloaterHormannInterpolator(_BarycentricRational[_SCT_co, _ShapeT_co], Generic[_SCT_co, _ShapeT_co]):
@overload
def __init__(
self,
/,
points: onp.CanArrayND[_SCT_co | _ToFloat16] | Sequence[_SCT_co | _ToFloat16 | int],
values: onp.CanArrayND[_SCT_co, _ShapeT_co],
*,
d: int = 3,
) -> None: ...
@overload
def __init__(
self: FloaterHormannInterpolator[np.floating[Any], tuple[int]],
/,
points: onp.ToFloat1D,
values: onp.ToFloatStrict1D,
*,
d: int = 3,
) -> None: ...
@overload
def __init__(
self: FloaterHormannInterpolator[np.floating[Any], tuple[int, int]],
/,
points: onp.ToFloat1D,
values: onp.ToFloatStrict2D,
*,
d: int = 3,
) -> None: ...
@overload
def __init__(
self: FloaterHormannInterpolator[np.inexact[Any], tuple[int]],
/,
points: onp.ToComplex1D,
values: onp.ToComplexStrict1D,
*,
d: int = 3,
) -> None: ...
@overload
def __init__(
self: FloaterHormannInterpolator[np.inexact[Any], tuple[int, int]],
/,
points: onp.ToComplex1D,
values: onp.ToComplexStrict2D,
*,
d: int = 3,
) -> None: ...
@overload
def __init__(self, /, points: onp.ToComplex1D, values: onp.ToComplexND, *, d: int = 3) -> None: ...
3 changes: 3 additions & 0 deletions scipy-stubs/interpolate/_bsplines.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __all__ = ["BSpline", "make_interp_spline", "make_lsq_spline", "make_smoothing_s

_Extrapolate: TypeAlias = Literal["periodic"] | bool
_BCType: TypeAlias = Literal["not-a-knot", "natural", "clamped", "periodic"]
_LSQMethod: TypeAlias = Literal["qr", "norm-eq"]

_SCT_co = TypeVar("_SCT_co", bound=np.floating[Any], default=np.floating[Any], covariant=True)

Expand Down Expand Up @@ -87,6 +88,8 @@ def make_lsq_spline(
w: onp.ToFloat1D | None = None,
axis: op.CanIndex = 0,
check_finite: onp.ToBool = True,
*,
method: _LSQMethod = "qr",
) -> BSpline: ...

#
Expand Down
17 changes: 11 additions & 6 deletions scipy-stubs/interpolate/_cubic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import numpy as np
import optype.numpy as onp
from ._interpolate import PPoly

_T = TypeVar("_T")
_Tuple2: TypeAlias = tuple[_T, _T]
__all__ = [
"Akima1DInterpolator",
"CubicHermiteSpline",
"CubicSpline",
"PchipInterpolator",
"pchip_interpolate",
]

_ToAxis: TypeAlias = int | np.integer[Any]
_T = TypeVar("_T")
_CT_co = TypeVar("_CT_co", bound=np.float64 | np.complex128, default=np.float64 | np.complex128, covariant=True)
_AxisT = TypeVar("_AxisT", bound=_ToAxis)

_CT_co = TypeVar("_CT_co", bound=np.float64 | np.complex128, default=np.float64 | np.complex128, covariant=True)
_Tuple2: TypeAlias = tuple[_T, _T]
_ToAxis: TypeAlias = int | np.integer[Any]

_Akima1DMethod: TypeAlias = Literal["akima", "makima"]
_Extrapolate: TypeAlias = Literal["periodic"] | bool
Expand All @@ -21,8 +28,6 @@ _CubicBCType: TypeAlias = Literal[_CubicBCName, "periodic"] | _Tuple2[_CubicBCNa

###

__all__ = ["Akima1DInterpolator", "CubicHermiteSpline", "CubicSpline", "PchipInterpolator", "pchip_interpolate"]

class CubicHermiteSpline(PPoly[_CT_co]):
@overload
def __init__(
Expand Down
Loading
Loading