diff --git a/README.md b/README.md index d1e4728e..95b1cdf3 100644 --- a/README.md +++ b/README.md @@ -83,33 +83,33 @@ pip install scipy-stubs | Module | Stubs status | |---------------------------------- |---------------- | | `scipy` | 1: skeleton | -| `scipy._lib` | 1: skeleton | -| `scipy._lib.uarray` | 1: skeleton | -| `scipy._lib.array_api_compat` | 1: partial | +| `scipy._lib` | 2: partial | +| `scipy._lib.uarray` | 2: ready | +| `scipy._lib.array_api_compat` | 2: partial | | `scipy.cluster` | 1: skeleton | | `scipy.constants` | 3: ready | | `scipy.datasets` | 1: skeleton | | `scipy.fft` | 1: skeleton | -| `scipy.fft._pocketfft` | 1: skeleton | +| `scipy.fft._pocketfft` | 1: partial | | `scipy.fftpack` | 1: skeleton | -| `scipy.integrate` | 1: skeleton | -| `scipy.integrate._ivp` | 1: skeleton | -| `scipy.interpolate` | 1: skeleton | +| `scipy.integrate` | 2: partial | +| `scipy.integrate._ivp` | 1: partial | +| `scipy.interpolate` | 2: partial | | `scipy.io` | 1: skeleton | | `scipy.io.arff` | 1: skeleton | -| `scipy.io.matlab` | 1: skeleton | +| `scipy.io.matlab` | 2: partial | | `scipy.linalg` | 3: ready | | `scipy.misc` | 0: missing | | `scipy.ndimage` | 1: skeleton | | `scipy.odr` | 1: skeleton | -| `scipy.optimize` | 1: skeleton | +| `scipy.optimize` | 2: partial | | `scipy.optimize.cython_optimize` | 0: missing | | `scipy.optimize.zeros` | 0: missing | -| `scipy.signal` | 1: skeleton | +| `scipy.signal` | 1: partial | | `scipy.signal.windows` | 1: skeleton | -| `scipy.sparse` | 1: skeleton | -| `scipy.sparse.csgraph` | 1: skeleton | -| `scipy.sparse.linalg` | 1: skeleton | +| `scipy.sparse` | 2: partial | +| `scipy.sparse.csgraph` | 2: partial | +| `scipy.sparse.linalg` | 2: partial | | `scipy.spatial` | 2: partial | | `scipy.spatial.distance` | 3: ready | | `scipy.special` | 3: ready | diff --git a/pyproject.toml b/pyproject.toml index ee24ded4..2d0e89c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -149,12 +149,11 @@ banned-from = [ [tool.ruff.lint.isort] combine-as-imports = true known-first-party = ["scipy"] -no-lines-before = ["local-folder"] +no-lines-before = ["typing", "first-party", "local-folder"] section-order = [ "standard-library", "typing", "third-party", - "typing-extra", "first-party", "local-folder", ] @@ -162,7 +161,6 @@ split-on-trailing-comma = true [tool.ruff.lint.isort.sections] typing = ["collections.abc", "types", "typing", "typing_extensions"] -typing-extra = ["optype", "optype.numpy", "numpy.typing", "scipy._typing"] [tool.ruff.lint.flake8-annotations] allow-star-arg-any = true diff --git a/scipy-stubs/__init__.pyi b/scipy-stubs/__init__.pyi index e8d7158e..57caf6e6 100644 --- a/scipy-stubs/__init__.pyi +++ b/scipy-stubs/__init__.pyi @@ -1,7 +1,6 @@ -from scipy._typing import Untyped - from scipy._lib._ccallback import LowLevelCallable as LowLevelCallable from scipy._lib._testutils import PytestTester as PytestTester +from scipy._typing import Untyped msg: str np_minversion: str diff --git a/scipy-stubs/_lib/_array_api.pyi b/scipy-stubs/_lib/_array_api.pyi index c0627a7d..1834c690 100644 --- a/scipy-stubs/_lib/_array_api.pyi +++ b/scipy-stubs/_lib/_array_api.pyi @@ -1,9 +1,8 @@ from types import ModuleType from typing import Any, Literal -from scipy._typing import Untyped - from scipy._lib.array_api_compat import device, size +from scipy._typing import Untyped __all__ = ["_asarray", "array_namespace", "device", "size"] diff --git a/scipy-stubs/_lib/_ccallback.pyi b/scipy-stubs/_lib/_ccallback.pyi index 636a952e..0256c5e3 100644 --- a/scipy-stubs/_lib/_ccallback.pyi +++ b/scipy-stubs/_lib/_ccallback.pyi @@ -1,6 +1,5 @@ import ctypes as ct from _ctypes import CFuncPtr as PyCFuncPtr - from types import ModuleType from typing import ClassVar, Generic, Literal, TypeAlias from typing_extensions import CapsuleType, Self, TypeVar diff --git a/scipy-stubs/_lib/_pep440.pyi b/scipy-stubs/_lib/_pep440.pyi index b95f3a25..0bc21ce1 100644 --- a/scipy-stubs/_lib/_pep440.pyi +++ b/scipy-stubs/_lib/_pep440.pyi @@ -1,26 +1,29 @@ -from typing import NamedTuple +from typing import Literal, NamedTuple +from typing_extensions import override from scipy._typing import Untyped class Infinity: - def __hash__(self) -> Untyped: ... - def __lt__(self, other) -> Untyped: ... - def __le__(self, other) -> Untyped: ... - def __eq__(self, other) -> Untyped: ... - def __ne__(self, other) -> Untyped: ... - def __gt__(self, other) -> Untyped: ... - def __ge__(self, other) -> Untyped: ... - def __neg__(self) -> Untyped: ... + @override + def __eq__(self, other: object, /) -> bool: ... + @override + def __ne__(self, other: object, /) -> bool: ... + def __lt__(self, other: object, /) -> Literal[False]: ... + def __le__(self, other: object, /) -> Literal[False]: ... + def __gt__(self, other: object, /) -> Literal[True]: ... + def __ge__(self, other: object, /) -> Literal[True]: ... + def __neg__(self) -> NegativeInfinity: ... class NegativeInfinity: - def __hash__(self) -> Untyped: ... - def __lt__(self, other) -> Untyped: ... - def __le__(self, other) -> Untyped: ... - def __eq__(self, other) -> Untyped: ... - def __ne__(self, other) -> Untyped: ... - def __gt__(self, other) -> Untyped: ... - def __ge__(self, other) -> Untyped: ... - def __neg__(self) -> Untyped: ... + @override + def __eq__(self, other: object, /) -> bool: ... + @override + def __ne__(self, other: object, /) -> bool: ... + def __lt__(self, other: object, /) -> Literal[True]: ... + def __le__(self, other: object, /) -> Literal[True]: ... + def __gt__(self, other: object, /) -> Literal[False]: ... + def __ge__(self, other: object, /) -> Literal[False]: ... + def __neg__(self) -> Infinity: ... class _Version(NamedTuple): epoch: Untyped @@ -35,13 +38,14 @@ def parse(version) -> Untyped: ... class InvalidVersion(ValueError): ... class _BaseVersion: - def __hash__(self) -> Untyped: ... - def __lt__(self, other) -> Untyped: ... - def __le__(self, other) -> Untyped: ... - def __eq__(self, other) -> Untyped: ... - def __ge__(self, other) -> Untyped: ... - def __gt__(self, other) -> Untyped: ... - def __ne__(self, other) -> Untyped: ... + @override + def __eq__(self, other: _BaseVersion, /) -> bool: ... # type: ignore[override] + @override + def __ne__(self, other: _BaseVersion, /) -> bool: ... # type: ignore[override] + def __lt__(self, other: _BaseVersion, /) -> bool: ... + def __le__(self, other: _BaseVersion, /) -> bool: ... + def __ge__(self, other: _BaseVersion, /) -> bool: ... + def __gt__(self, other: _BaseVersion, /) -> bool: ... class LegacyVersion(_BaseVersion): def __init__(self, version) -> None: ... @@ -50,7 +54,7 @@ class LegacyVersion(_BaseVersion): @property def base_version(self) -> Untyped: ... @property - def local(self): ... + def local(self) -> Untyped: ... @property def is_prerelease(self) -> Untyped: ... @property diff --git a/scipy-stubs/_lib/_uarray/_backend.pyi b/scipy-stubs/_lib/_uarray/_backend.pyi index 2e922069..4541d9b0 100644 --- a/scipy-stubs/_lib/_uarray/_backend.pyi +++ b/scipy-stubs/_lib/_uarray/_backend.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Generator from typing import TypeAlias -from scipy._typing import Untyped +from scipy._typing import Untyped, UntypedCallable __all__ = [ "BackendNotImplementedError", @@ -49,7 +49,7 @@ def generate_multimethod( argument_extractor: ArgumentExtractorType, argument_replacer: ArgumentReplacerType, domain: str, - default: typing.Callable | None = None, + default: UntypedCallable | None = None, ): ... def set_backend(backend, coerce: bool = False, only: bool = False) -> Untyped: ... def skip_backend(backend) -> Untyped: ... diff --git a/scipy-stubs/_lib/_util.pyi b/scipy-stubs/_lib/_util.pyi index 7fdd72d4..8c83d31a 100644 --- a/scipy-stubs/_lib/_util.pyi +++ b/scipy-stubs/_lib/_util.pyi @@ -3,7 +3,6 @@ from typing import Any, NamedTuple, TypeAlias from typing_extensions import TypeVar, override import numpy as np - from scipy._typing import Untyped AxisError: type[Exception] diff --git a/scipy-stubs/_lib/array_api_compat/common/_helpers.pyi b/scipy-stubs/_lib/array_api_compat/common/_helpers.pyi index 07c3885a..e61a5093 100644 --- a/scipy-stubs/_lib/array_api_compat/common/_helpers.pyi +++ b/scipy-stubs/_lib/array_api_compat/common/_helpers.pyi @@ -2,7 +2,6 @@ from types import ModuleType from typing_extensions import TypeIs import numpy as np - from ._typing import Array, Device __all__ = [ diff --git a/scipy-stubs/_lib/array_api_compat/common/_typing.pyi b/scipy-stubs/_lib/array_api_compat/common/_typing.pyi index 228a7a36..e456e950 100644 --- a/scipy-stubs/_lib/array_api_compat/common/_typing.pyi +++ b/scipy-stubs/_lib/array_api_compat/common/_typing.pyi @@ -1,11 +1,9 @@ import array as _array import mmap - from typing import Any, Literal, Protocol, TypeAlias, TypeVar from typing_extensions import Buffer import numpy as np - import optype as op __all__ = ["NestedSequence", "SupportsBufferProtocol"] diff --git a/scipy-stubs/_lib/decorator.pyi b/scipy-stubs/_lib/decorator.pyi index fcaa69f4..fc20bf80 100644 --- a/scipy-stubs/_lib/decorator.pyi +++ b/scipy-stubs/_lib/decorator.pyi @@ -1,8 +1,7 @@ -from contextlib import GeneratorContextManager as _GeneratorContextManager - +from contextlib import _GeneratorContextManager from typing import NamedTuple -from scipy._typing import Untyped +from scipy._typing import Untyped, UntypedCallable __version__: str @@ -52,18 +51,17 @@ class FunctionMaker: **attrs, ) -> Untyped: ... -def decorate(func, caller) -> Untyped: ... -def decorator(caller, _func: Untyped | None = None) -> Untyped: ... +def decorate(func: UntypedCallable, caller) -> Untyped: ... +def decorator(caller, _func: UntypedCallable | None = None) -> UntypedCallable: ... -class ContextManager(_GeneratorContextManager): - def __call__(self, func) -> Untyped: ... +class ContextManager(_GeneratorContextManager[Untyped]): ... init: Untyped n_args: Untyped def __init__(self, g, *a, **k): ... -contextmanager: Untyped +contextmanager: UntypedCallable def append(a, vancestors): ... def dispatch_on(*dispatch_args) -> Untyped: ... diff --git a/scipy-stubs/_lib/deprecation.pyi b/scipy-stubs/_lib/deprecation.pyi index 552876b0..74a3dd6a 100644 --- a/scipy-stubs/_lib/deprecation.pyi +++ b/scipy-stubs/_lib/deprecation.pyi @@ -1,8 +1,20 @@ +from collections.abc import Callable +from types import ModuleType +from typing import Any, TypeVar + from scipy._typing import Untyped +__all__ = ["_deprecated"] + +_F = TypeVar("_F", bound=Callable[..., Any]) + class _DeprecationHelperStr: - def __init__(self, content, message) -> None: ... - def __hash__(self) -> Untyped: ... - def __eq__(self, other) -> Untyped: ... + def __init__(self, content: Untyped, message: str) -> None: ... -def deprecate_cython_api(module, routine_name, new_name: Untyped | None = None, message: Untyped | None = None): ... +def _deprecated(msg: str, stacklevel: int = 2) -> Callable[[_F], _F]: ... +def deprecate_cython_api( + module: ModuleType, + routine_name: str, + new_name: str | None = None, + message: str | None = None, +) -> None: ... diff --git a/scipy-stubs/_typing.pyi b/scipy-stubs/_typing.pyi index 09652e98..59aab861 100644 --- a/scipy-stubs/_typing.pyi +++ b/scipy-stubs/_typing.pyi @@ -1,10 +1,11 @@ # Helper types for internal use (type-check only). +from collections.abc import Callable from typing import Literal, Protocol, TypeAlias, type_check_only from typing_extensions import LiteralString, TypeVar import numpy as np - import numpy.typing as npt +import optype.numpy as onpt __all__ = [ "AnyBool", @@ -17,11 +18,21 @@ __all__ = [ "CorrelateMode", "Seed", "Untyped", + "UntypedArray", + "UntypedCallable", + "UntypedDict", + "UntypedList", + "UntypedTuple", "_FortranFunction", ] -# placeholder for missing annotations +# placeholders for missing annotations Untyped: TypeAlias = object +UntypedTuple: TypeAlias = tuple[Untyped, ...] +UntypedList: TypeAlias = list[Untyped] +UntypedDict: TypeAlias = dict[Untyped, Untyped] +UntypedCallable: TypeAlias = Callable[..., Untyped] +UntypedArray: TypeAlias = onpt.Array[tuple[int, ...], np.generic] _SCT = TypeVar("_SCT", bound=np.generic, default=np.generic) Array0D: TypeAlias = np.ndarray[tuple[()], np.dtype[_SCT]] diff --git a/scipy-stubs/cluster/__init__.pyi b/scipy-stubs/cluster/__init__.pyi index 72d94729..ebffcf50 100644 --- a/scipy-stubs/cluster/__init__.pyi +++ b/scipy-stubs/cluster/__init__.pyi @@ -1,4 +1,3 @@ -from scipy._typing import Untyped - from scipy._lib._testutils import PytestTester as PytestTester +from scipy._typing import Untyped from . import hierarchy as hierarchy, vq as vq diff --git a/scipy-stubs/cluster/hierarchy.pyi b/scipy-stubs/cluster/hierarchy.pyi index 18c0c981..62e8ea15 100644 --- a/scipy-stubs/cluster/hierarchy.pyi +++ b/scipy-stubs/cluster/hierarchy.pyi @@ -1,7 +1,40 @@ +from scipy._lib._disjoint_set import DisjointSet from scipy._typing import Untyped -from scipy._lib._array_api import array_namespace as array_namespace, is_jax as is_jax, xp_copy as xp_copy -from scipy._lib._disjoint_set import DisjointSet as DisjointSet +__all__ = [ + "ClusterNode", + "DisjointSet", + "average", + "centroid", + "complete", + "cophenet", + "correspond", + "cut_tree", + "dendrogram", + "fcluster", + "fclusterdata", + "from_mlab_linkage", + "inconsistent", + "is_isomorphic", + "is_monotonic", + "is_valid_im", + "is_valid_linkage", + "leaders", + "leaves_list", + "linkage", + "maxRstat", + "maxdists", + "maxinconsts", + "median", + "num_obs_linkage", + "optimal_leaf_ordering", + "set_link_color_palette", + "single", + "to_mlab_linkage", + "to_tree", + "ward", + "weighted", +] class ClusterWarning(UserWarning): ... @@ -24,7 +57,7 @@ class ClusterNode: def __init__(self, id, left: Untyped | None = None, right: Untyped | None = None, dist: int = 0, count: int = 1): ... def __lt__(self, node) -> Untyped: ... def __gt__(self, node) -> Untyped: ... - def __eq__(self, node) -> Untyped: ... + def __eq__(self, node) -> Untyped: ... # type: ignore[override] def get_id(self) -> Untyped: ... def get_count(self) -> Untyped: ... def get_left(self) -> Untyped: ... diff --git a/scipy-stubs/cluster/vq.pyi b/scipy-stubs/cluster/vq.pyi index dd5d752c..61075dfc 100644 --- a/scipy-stubs/cluster/vq.pyi +++ b/scipy-stubs/cluster/vq.pyi @@ -1,16 +1,6 @@ from scipy._typing import Untyped -from scipy._lib._array_api import ( - array_namespace as array_namespace, - xp_atleast_nd as xp_atleast_nd, - xp_copy as xp_copy, - xp_cov as xp_cov, - xp_size as xp_size, -) -from scipy._lib._util import check_random_state as check_random_state, rng_integers as rng_integers -from scipy.spatial.distance import cdist as cdist - -__docformat__: str +__all__ = ["kmeans", "kmeans2", "vq", "whiten"] class ClusterError(Exception): ... @@ -18,7 +8,13 @@ def whiten(obs, check_finite: bool = True) -> Untyped: ... def vq(obs, code_book, check_finite: bool = True) -> Untyped: ... def py_vq(obs, code_book, check_finite: bool = True) -> Untyped: ... def kmeans( - obs, k_or_guess, iter: int = 20, thresh: float = 1e-05, check_finite: bool = True, *, seed: Untyped | None = None + obs, + k_or_guess, + iter: int = 20, + thresh: float = 1e-05, + check_finite: bool = True, + *, + seed: Untyped | None = None, ) -> Untyped: ... def kmeans2( data, diff --git a/scipy-stubs/constants/_constants.pyi b/scipy-stubs/constants/_constants.pyi index ca626e7c..216e4f3f 100644 --- a/scipy-stubs/constants/_constants.pyi +++ b/scipy-stubs/constants/_constants.pyi @@ -1,7 +1,6 @@ from typing import Literal import numpy as np - import numpy.typing as npt __all__ = [ diff --git a/scipy-stubs/datasets/_fetchers.pyi b/scipy-stubs/datasets/_fetchers.pyi index 8d712f45..3a22b4f6 100644 --- a/scipy-stubs/datasets/_fetchers.pyi +++ b/scipy-stubs/datasets/_fetchers.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._registry import registry as registry, registry_urls as registry_urls data_fetcher: Untyped diff --git a/scipy-stubs/datasets/_utils.pyi b/scipy-stubs/datasets/_utils.pyi index da582b3b..be4c9f84 100644 --- a/scipy-stubs/datasets/_utils.pyi +++ b/scipy-stubs/datasets/_utils.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._registry import method_files_map as method_files_map def clear_cache(datasets: Untyped | None = None): ... diff --git a/scipy-stubs/fft/_basic_backend.pyi b/scipy-stubs/fft/_basic_backend.pyi index d12a9ce2..899efd53 100644 --- a/scipy-stubs/fft/_basic_backend.pyi +++ b/scipy-stubs/fft/_basic_backend.pyi @@ -1,12 +1,5 @@ from scipy._typing import Untyped -from scipy._lib._array_api import ( - array_namespace as array_namespace, - is_complex as is_complex, - is_numpy as is_numpy, - xp_unsupported_param_msg as xp_unsupported_param_msg, -) - def fft( x, n: Untyped | None = None, diff --git a/scipy-stubs/fft/_fftlog.pyi b/scipy-stubs/fft/_fftlog.pyi index 0a031fc7..44a31913 100644 --- a/scipy-stubs/fft/_fftlog.pyi +++ b/scipy-stubs/fft/_fftlog.pyi @@ -1,4 +1,7 @@ from scipy._typing import Untyped +from ._fftlog_backend import fhtoffset -def fht(a, dln, mu, offset: float = 0.0, bias: float = 0.0) -> Untyped: ... -def ifht(A, dln, mu, offset: float = 0.0, bias: float = 0.0) -> Untyped: ... +__all__ = ["fht", "fhtoffset", "ifht"] + +def fht(a: Untyped, dln: Untyped, mu: Untyped, offset: float = 0.0, bias: float = 0.0) -> Untyped: ... +def ifht(A: Untyped, dln: Untyped, mu: Untyped, offset: float = 0.0, bias: float = 0.0) -> Untyped: ... diff --git a/scipy-stubs/fft/_fftlog_backend.pyi b/scipy-stubs/fft/_fftlog_backend.pyi index 62988359..a3279d93 100644 --- a/scipy-stubs/fft/_fftlog_backend.pyi +++ b/scipy-stubs/fft/_fftlog_backend.pyi @@ -2,7 +2,7 @@ from scipy._typing import Untyped __all__ = ["fht", "fhtoffset", "ifht"] -def fht(a, dln, mu, offset: float = 0.0, bias: float = 0.0) -> Untyped: ... -def ifht(A, dln, mu, offset: float = 0.0, bias: float = 0.0) -> Untyped: ... -def fhtcoeff(n, dln, mu, offset: float = 0.0, bias: float = 0.0, inverse: bool = False) -> Untyped: ... -def fhtoffset(dln, mu, initial: float = 0.0, bias: float = 0.0) -> Untyped: ... +def fht(a: Untyped, dln: Untyped, mu: Untyped, offset: float = 0.0, bias: float = 0.0) -> Untyped: ... +def ifht(A: Untyped, dln: Untyped, mu: Untyped, offset: float = 0.0, bias: float = 0.0) -> Untyped: ... +def fhtcoeff(n: Untyped, dln: Untyped, mu: Untyped, offset: float = 0.0, bias: float = 0.0, inverse: bool = False) -> Untyped: ... +def fhtoffset(dln: Untyped, mu: Untyped, initial: float = 0.0, bias: float = 0.0) -> Untyped: ... diff --git a/scipy-stubs/fft/_helper.pyi b/scipy-stubs/fft/_helper.pyi index 3da4e7f7..c1d32ca6 100644 --- a/scipy-stubs/fft/_helper.pyi +++ b/scipy-stubs/fft/_helper.pyi @@ -1,15 +1,7 @@ from scipy._typing import Untyped -from scipy._lib._array_api import array_namespace as array_namespace - def next_fast_len(target, real: bool = False): ... - -next_fast_len: Untyped - def prev_fast_len(target, real: bool = False): ... - -prev_fast_len: Untyped - def fftfreq(n, d: float = 1.0, *, xp: Untyped | None = None, device: Untyped | None = None) -> Untyped: ... def rfftfreq(n, d: float = 1.0, *, xp: Untyped | None = None, device: Untyped | None = None) -> Untyped: ... def fftshift(x, axes: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/fft/_pocketfft/helper.pyi b/scipy-stubs/fft/_pocketfft/helper.pyi index 8f21e0d7..146e8f35 100644 --- a/scipy-stubs/fft/_pocketfft/helper.pyi +++ b/scipy-stubs/fft/_pocketfft/helper.pyi @@ -1,9 +1,8 @@ from collections.abc import Generator -from scipy._typing import Untyped +from .pypocketfft import good_size, prev_good_size -from scipy._lib._util import copy_if_needed as copy_if_needed -from .pypocketfft import good_size as good_size, prev_good_size as prev_good_size +__all__ = ["get_workers", "good_size", "prev_good_size", "set_workers"] -def set_workers(workers) -> Generator[None, None, None]: ... -def get_workers() -> Untyped: ... +def set_workers(workers: int) -> Generator[None, None, None]: ... +def get_workers() -> int: ... diff --git a/scipy-stubs/fft/_pocketfft/pypocketfft.pyi b/scipy-stubs/fft/_pocketfft/pypocketfft.pyi new file mode 100644 index 00000000..51556bfa --- /dev/null +++ b/scipy-stubs/fft/_pocketfft/pypocketfft.pyi @@ -0,0 +1,5 @@ +# TODO +from scipy._typing import Untyped + +def good_size(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def prev_good_size(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/fft/_realtransforms_backend.pyi b/scipy-stubs/fft/_realtransforms_backend.pyi index b384616a..4afaaaad 100644 --- a/scipy-stubs/fft/_realtransforms_backend.pyi +++ b/scipy-stubs/fft/_realtransforms_backend.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._array_api import array_namespace as array_namespace +from scipy._typing import Untyped def dctn( x, diff --git a/scipy-stubs/fftpack/_helper.pyi b/scipy-stubs/fftpack/_helper.pyi index a82f1014..80df04a2 100644 --- a/scipy-stubs/fftpack/_helper.pyi +++ b/scipy-stubs/fftpack/_helper.pyi @@ -1,5 +1,4 @@ from numpy.fft import fftfreq, fftshift, ifftshift # noqa: ICN003 - from scipy._typing import Untyped __all__ = ["fftfreq", "fftshift", "ifftshift", "next_fast_len", "rfftfreq"] diff --git a/scipy-stubs/fftpack/_pseudo_diffs.pyi b/scipy-stubs/fftpack/_pseudo_diffs.pyi index 22a36cc9..baaa5de0 100644 --- a/scipy-stubs/fftpack/_pseudo_diffs.pyi +++ b/scipy-stubs/fftpack/_pseudo_diffs.pyi @@ -1,6 +1,6 @@ from scipy._typing import Untyped -from . import convolve as convolve +__all__ = ["cc_diff", "cs_diff", "diff", "hilbert", "ihilbert", "itilbert", "sc_diff", "shift", "ss_diff", "tilbert"] def diff(x, order: int = 1, period: Untyped | None = None, _cache=...) -> Untyped: ... def tilbert(x, h, period: Untyped | None = None, _cache=...) -> Untyped: ... diff --git a/scipy-stubs/integrate/_bvp.pyi b/scipy-stubs/integrate/_bvp.pyi index 916c4382..a037b7f8 100644 --- a/scipy-stubs/integrate/_bvp.pyi +++ b/scipy-stubs/integrate/_bvp.pyi @@ -1,28 +1,35 @@ from scipy._typing import Untyped - -from scipy.optimize import OptimizeResult as OptimizeResult -from scipy.sparse import coo_matrix as coo_matrix, csc_matrix as csc_matrix -from scipy.sparse.linalg import splu as splu +from scipy.optimize import OptimizeResult EPS: Untyped +TERMINATION_MESSAGES: Untyped + +class BVPResult(OptimizeResult): ... def estimate_fun_jac(fun, x, y, p, f0: Untyped | None = None) -> Untyped: ... def estimate_bc_jac(bc, ya, yb, p, bc0: Untyped | None = None) -> Untyped: ... def compute_jac_indices(n, m, k) -> Untyped: ... def stacked_matmul(a, b) -> Untyped: ... def construct_global_jac( - n, m, k, i_jac, j_jac, h, df_dy, df_dy_middle, df_dp, df_dp_middle, dbc_dya, dbc_dyb, dbc_dp + n, + m, + k, + i_jac, + j_jac, + h, + df_dy, + df_dy_middle, + df_dp, + df_dp_middle, + dbc_dya, + dbc_dyb, + dbc_dp, ) -> Untyped: ... def collocation_fun(fun, y, p, x, h) -> Untyped: ... def prepare_sys(n, m, k, fun, bc, fun_jac, bc_jac, x, h) -> Untyped: ... def solve_newton(n, m, h, col_fun, bc, jac, y, p, B, bvp_tol, bc_tol) -> Untyped: ... def print_iteration_header(): ... def print_iteration_progress(iteration, residual, bc_residual, total_nodes, nodes_added): ... - -class BVPResult(OptimizeResult): ... - -TERMINATION_MESSAGES: Untyped - def estimate_rms_residuals(fun, sol, x, h, p, r_middle, f_middle) -> Untyped: ... def create_spline(y, yp, x, h) -> Untyped: ... def modify_mesh(x, insert_1, insert_2) -> Untyped: ... diff --git a/scipy-stubs/integrate/_ivp/bdf.pyi b/scipy-stubs/integrate/_ivp/bdf.pyi index 1f7ce9aa..462b6466 100644 --- a/scipy-stubs/integrate/_ivp/bdf.pyi +++ b/scipy-stubs/integrate/_ivp/bdf.pyi @@ -1,25 +1,12 @@ -from scipy._typing import Untyped +from typing import Final -from scipy.linalg import lu_factor as lu_factor, lu_solve as lu_solve -from scipy.optimize._numdiff import group_columns as group_columns -from scipy.sparse import csc_matrix as csc_matrix, eye as eye, issparse as issparse -from scipy.sparse.linalg import splu as splu -from .base import DenseOutput as DenseOutput, OdeSolver as OdeSolver -from .common import ( - EPS as EPS, - norm as norm, - num_jac as num_jac, - select_initial_step as select_initial_step, - validate_first_step as validate_first_step, - validate_max_step as validate_max_step, - validate_tol as validate_tol, - warn_extraneous as warn_extraneous, -) +from scipy._typing import Untyped +from .base import DenseOutput, OdeSolver -MAX_ORDER: int -NEWTON_MAXITER: int -MIN_FACTOR: float -MAX_FACTOR: int +MAX_ORDER: Final = 5 +NEWTON_MAXITER: Final = 4 +MIN_FACTOR: Final = 0.2 +MAX_FACTOR: Final = 10 def compute_R(order, factor) -> Untyped: ... def change_D(D, order, factor): ... diff --git a/scipy-stubs/integrate/_ivp/common.pyi b/scipy-stubs/integrate/_ivp/common.pyi index cf46d5f6..9db33c2d 100644 --- a/scipy-stubs/integrate/_ivp/common.pyi +++ b/scipy-stubs/integrate/_ivp/common.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse import coo_matrix as coo_matrix, find as find EPS: Untyped diff --git a/scipy-stubs/integrate/_ivp/ivp.pyi b/scipy-stubs/integrate/_ivp/ivp.pyi index 0375a147..6cd404aa 100644 --- a/scipy-stubs/integrate/_ivp/ivp.pyi +++ b/scipy-stubs/integrate/_ivp/ivp.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.optimize import OptimizeResult as OptimizeResult from .base import OdeSolver as OdeSolver from .bdf import BDF as BDF diff --git a/scipy-stubs/integrate/_ivp/lsoda.pyi b/scipy-stubs/integrate/_ivp/lsoda.pyi index 7ade0d72..01d53fe4 100644 --- a/scipy-stubs/integrate/_ivp/lsoda.pyi +++ b/scipy-stubs/integrate/_ivp/lsoda.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.integrate import ode as ode from .base import DenseOutput as DenseOutput, OdeSolver as OdeSolver from .common import validate_first_step as validate_first_step, validate_tol as validate_tol, warn_extraneous as warn_extraneous diff --git a/scipy-stubs/integrate/_ivp/radau.pyi b/scipy-stubs/integrate/_ivp/radau.pyi index 1b445933..cf020a5c 100644 --- a/scipy-stubs/integrate/_ivp/radau.pyi +++ b/scipy-stubs/integrate/_ivp/radau.pyi @@ -1,20 +1,5 @@ from scipy._typing import Untyped - -from scipy.linalg import lu_factor as lu_factor, lu_solve as lu_solve -from scipy.optimize._numdiff import group_columns as group_columns -from scipy.sparse import csc_matrix as csc_matrix, eye as eye, issparse as issparse -from scipy.sparse.linalg import splu as splu -from .base import DenseOutput as DenseOutput, OdeSolver as OdeSolver -from .common import ( - EPS as EPS, - norm as norm, - num_jac as num_jac, - select_initial_step as select_initial_step, - validate_first_step as validate_first_step, - validate_max_step as validate_max_step, - validate_tol as validate_tol, - warn_extraneous as warn_extraneous, -) +from .base import DenseOutput, OdeSolver S6: Untyped C: Untyped diff --git a/scipy-stubs/integrate/_ivp/rk.pyi b/scipy-stubs/integrate/_ivp/rk.pyi index 5fd1aa85..f36eb03a 100644 --- a/scipy-stubs/integrate/_ivp/rk.pyi +++ b/scipy-stubs/integrate/_ivp/rk.pyi @@ -1,17 +1,8 @@ -import numpy as np - -from scipy._typing import Untyped +from typing import ClassVar, Literal -from . import dop853_coefficients as dop853_coefficients -from .base import DenseOutput as DenseOutput, OdeSolver as OdeSolver -from .common import ( - norm as norm, - select_initial_step as select_initial_step, - validate_first_step as validate_first_step, - validate_max_step as validate_max_step, - validate_tol as validate_tol, - warn_extraneous as warn_extraneous, -) +import numpy as np +from scipy._typing import Untyped, UntypedArray +from .base import DenseOutput, OdeSolver SAFETY: float MIN_FACTOR: float @@ -20,14 +11,14 @@ MAX_FACTOR: int def rk_step(fun, t, y, f, h, A, B, C, K) -> Untyped: ... class RungeKutta(OdeSolver): - C: np.ndarray - A: np.ndarray - B: np.ndarray - E: np.ndarray - P: np.ndarray - order: int - error_estimator_order: int - n_stages: int + C: ClassVar[UntypedArray] + A: ClassVar[UntypedArray] + B: ClassVar[UntypedArray] + E: ClassVar[UntypedArray] + P: ClassVar[UntypedArray] + order: ClassVar[int] + error_estimator_order: ClassVar[int] + n_stages: ClassVar[int] y_old: Untyped max_step: Untyped f: Untyped @@ -49,38 +40,16 @@ class RungeKutta(OdeSolver): **extraneous, ): ... -class RK23(RungeKutta): - order: int - error_estimator_order: int - n_stages: int - C: Untyped - A: Untyped - B: Untyped - E: Untyped - P: Untyped - -class RK45(RungeKutta): - order: int - error_estimator_order: int - n_stages: int - C: Untyped - A: Untyped - B: Untyped - E: Untyped - P: Untyped +class RK23(RungeKutta): ... +class RK45(RungeKutta): ... class DOP853(RungeKutta): - n_stages: Untyped - order: int - error_estimator_order: int - A: Untyped - B: Untyped - C: Untyped - E3: Untyped - E5: Untyped - D: Untyped - A_EXTRA: Untyped - C_EXTRA: Untyped + E3: ClassVar[UntypedArray] + E5: ClassVar[UntypedArray] + D: ClassVar[UntypedArray] + A_EXTRA: ClassVar[UntypedArray] + C_EXTRA: ClassVar[UntypedArray] + K_extended: Untyped K: Untyped def __init__( diff --git a/scipy-stubs/integrate/_ode.pyi b/scipy-stubs/integrate/_ode.pyi index d271354f..43ac09f4 100644 --- a/scipy-stubs/integrate/_ode.pyi +++ b/scipy-stubs/integrate/_ode.pyi @@ -1,15 +1,17 @@ from scipy._typing import Untyped +__all__ = ["complex_ode", "ode"] + class ode: stiff: int f: Untyped jac: Untyped f_params: Untyped jac_params: Untyped - def __init__(self, f, jac: Untyped | None = None): ... + t: Untyped + def __init__(self, f, jac: Untyped | None = None) -> None: ... @property def y(self) -> Untyped: ... - t: Untyped def set_initial_value(self, y, t: float = 0.0) -> Untyped: ... def set_integrator(self, name, **integrator_params) -> Untyped: ... def integrate(self, t, step: bool = False, relax: bool = False) -> Untyped: ... @@ -95,11 +97,12 @@ class vode(IntegratorBase): def step(self, *args) -> Untyped: ... def run_relax(self, *args) -> Untyped: ... +# pyright: reportUnnecessaryTypeIgnoreComment=false class zvode(vode): runner: Untyped supports_run_relax: int supports_step: int - scalar = complex + scalar: complex # type: ignore[assignment] active_global_handle: int zwork: Untyped rwork: Untyped diff --git a/scipy-stubs/integrate/_quad_vec.pyi b/scipy-stubs/integrate/_quad_vec.pyi index 674b3cd8..01ae77eb 100644 --- a/scipy-stubs/integrate/_quad_vec.pyi +++ b/scipy-stubs/integrate/_quad_vec.pyi @@ -1,13 +1,12 @@ import collections +from typing_extensions import override from scipy._typing import Untyped -from scipy._lib._util import MapWrapper as MapWrapper - -class LRUDict(collections.OrderedDict): - def __init__(self, max_size) -> None: ... - def __setitem__(self, key, value) -> None: ... - def update(self, other): ... +class LRUDict(collections.OrderedDict[tuple[float, float], Untyped]): + def __init__(self, max_size: int) -> None: ... + @override + def update(self, other) -> None: ... # type: ignore[override] class SemiInfiniteFunc: def __init__(self, func, start, infty) -> None: ... diff --git a/scipy-stubs/integrate/_quadrature.pyi b/scipy-stubs/integrate/_quadrature.pyi index 67cf36f6..2174bbd1 100644 --- a/scipy-stubs/integrate/_quadrature.pyi +++ b/scipy-stubs/integrate/_quadrature.pyi @@ -1,34 +1,62 @@ -from collections.abc import Callable -from typing import Any, NamedTuple, Protocol +from typing import NamedTuple +from typing_extensions import deprecated + +import numpy.typing as npt +from scipy._typing import Untyped, UntypedCallable, UntypedTuple +from scipy.stats.qmc import QMCEngine + +__all__ = [ + "AccuracyWarning", + "cumulative_simpson", + "cumulative_trapezoid", + "fixed_quad", + "newton_cotes", + "qmc_quad", + "quadrature", + "romb", + "romberg", + "simpson", + "trapezoid", +] + +class AccuracyWarning(Warning): ... -from scipy._typing import Untyped - -from scipy.special import gammaln as gammaln, logsumexp as logsumexp, roots_legendre as roots_legendre - -def trapezoid(y, x: Untyped | None = None, dx: float = 1.0, axis: int = -1) -> Untyped: ... - -class CacheAttributes(Protocol): - cache: dict[int, tuple[Any, Any]] - -CacheAttributes = Callable - -def cache_decorator(func: Callable) -> CacheAttributes: ... -def fixed_quad(func, a, b, args=(), n: int = 5) -> Untyped: ... -def tupleset(t, i, value) -> Untyped: ... +class QMCQuadResult(NamedTuple): + integral: float + standard_error: float + +@deprecated("deprecated as of SciPy 1.12.0 and will be removed in SciPy 1.15.0") +def quadrature(*args: Untyped, **kwargs: Untyped) -> UntypedTuple: ... +@deprecated("deprecated as of SciPy 1.12.0 and will be removed in SciPy 1.15.0") +def romberg(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def trapezoid(y: npt.ArrayLike, x: npt.ArrayLike | None = None, dx: float = 1.0, axis: int = -1) -> Untyped: ... +def fixed_quad(func: UntypedCallable, a: float, b: float, args: UntypedTuple = (), n: int = 5) -> Untyped: ... def cumulative_trapezoid( - y, x: Untyped | None = None, dx: float = 1.0, axis: int = -1, initial: Untyped | None = None + y: npt.ArrayLike, + x: npt.ArrayLike | None = None, + dx: float = 1.0, + axis: int = -1, + initial: Untyped | None = None, ) -> Untyped: ... -def simpson(y, *, x: Untyped | None = None, dx: float = 1.0, axis: int = -1) -> Untyped: ... +def simpson(y: npt.ArrayLike, *, x: npt.ArrayLike | None = None, dx: float = 1.0, axis: int = -1) -> Untyped: ... def cumulative_simpson( - y, *, x: Untyped | None = None, dx: float = 1.0, axis: int = -1, initial: Untyped | None = None + y: npt.ArrayLike, + *, + x: npt.ArrayLike | None = None, + dx: float = 1.0, + axis: int = -1, + initial: Untyped | None = None, ) -> Untyped: ... -def romb(y, dx: float = 1.0, axis: int = -1, show: bool = False) -> Untyped: ... -def newton_cotes(rn, equal: int = 0) -> Untyped: ... - -class QMCQuadResult(NamedTuple): - integral: Untyped - standard_error: Untyped - +def romb(y: npt.ArrayLike, dx: float = 1.0, axis: int = -1, show: bool = False) -> Untyped: ... +def newton_cotes(rn: int, equal: int = 0) -> Untyped: ... def qmc_quad( - func, a, b, *, n_estimates: int = 8, n_points: int = 1024, qrng: Untyped | None = None, log: bool = False + func: UntypedCallable, + a: npt.ArrayLike, + b: npt.ArrayLike, + *, + n_estimates: int = 8, + n_points: int = 1024, + qrng: QMCEngine | None = None, + log: bool = False, ) -> Untyped: ... +def tupleset(t: UntypedTuple, i: int, value: Untyped) -> UntypedTuple: ... diff --git a/scipy-stubs/integrate/_tanhsinh.pyi b/scipy-stubs/integrate/_tanhsinh.pyi index 9705290a..3430648e 100644 --- a/scipy-stubs/integrate/_tanhsinh.pyi +++ b/scipy-stubs/integrate/_tanhsinh.pyi @@ -1,15 +1,3 @@ from scipy._typing import Untyped -from scipy import special as special -from scipy._lib._array_api import ( - array_namespace as array_namespace, - is_cupy as is_cupy, - is_numpy as is_numpy, - is_torch as is_torch, - xp_copy as xp_copy, - xp_ravel as xp_ravel, - xp_real as xp_real, - xp_take_along_axis as xp_take_along_axis, -) - def nsum(f, a, b, *, step: int = 1, args=(), log: bool = False, maxterms=..., tolerances: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_bsplines.pyi b/scipy-stubs/interpolate/_bsplines.pyi index f89ad2d4..ced25b28 100644 --- a/scipy-stubs/interpolate/_bsplines.pyi +++ b/scipy-stubs/interpolate/_bsplines.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - 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, diff --git a/scipy-stubs/interpolate/_cubic.pyi b/scipy-stubs/interpolate/_cubic.pyi index 10d030d8..a2175738 100644 --- a/scipy-stubs/interpolate/_cubic.pyi +++ b/scipy-stubs/interpolate/_cubic.pyi @@ -1,7 +1,6 @@ from typing import Literal from scipy._typing import Untyped - from scipy.linalg import solve as solve, solve_banded as solve_banded from . import PPoly as PPoly diff --git a/scipy-stubs/interpolate/_fitpack2.pyi b/scipy-stubs/interpolate/_fitpack2.pyi index 2d91d68a..bd9d0b11 100644 --- a/scipy-stubs/interpolate/_fitpack2.pyi +++ b/scipy-stubs/interpolate/_fitpack2.pyi @@ -1,3 +1,5 @@ +from typing_extensions import override + from scipy._typing import Untyped dfitpack_int: Untyped @@ -7,6 +9,8 @@ class UnivariateSpline: self, x, y, + /, + *, w: Untyped | None = None, bbox=..., k: int = 3, @@ -27,17 +31,28 @@ class UnivariateSpline: def derivative(self, n: int = 1) -> Untyped: ... def antiderivative(self, n: int = 1) -> Untyped: ... -class InterpolatedUnivariateSpline(UnivariateSpline): - def __init__(self, x, y, w: Untyped | None = None, bbox=..., k: int = 3, ext: int = 0, check_finite: bool = False): ... +class InterpolatedUnivariateSpline(UnivariateSpline): ... class LSQUnivariateSpline(UnivariateSpline): - def __init__(self, x, y, t, w: Untyped | None = None, bbox=..., k: int = 3, ext: int = 0, check_finite: bool = False): ... + def __init__( + self, + x, + y, + t, + /, + *, + w: Untyped | None = None, + bbox=..., + k: int = 3, + ext: int = 0, + check_finite: bool = False, + ) -> None: ... class _BivariateSplineBase: 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 __call__(self, x, y, dx: int = 0, dy: int = 0, /, *, grid: bool = True) -> Untyped: ... def partial_derivative(self, dx, dy) -> Untyped: ... class BivariateSpline(_BivariateSplineBase): @@ -46,48 +61,73 @@ class BivariateSpline(_BivariateSplineBase): class _DerivedBivariateSpline(_BivariateSplineBase): @property - def fp(self): ... - def get_residual(self): ... + def fp(self) -> Untyped: ... class SmoothBivariateSpline(BivariateSpline): fp: Untyped tck: Untyped degrees: Untyped def __init__( - self, x, y, z, w: Untyped | None = None, bbox=..., kx: int = 3, ky: int = 3, s: Untyped | None = None, eps: float = 1e-16 - ): ... + self, + x, + y, + z, + /, + *, + w: Untyped | None = None, + bbox=..., + kx: int = 3, + ky: int = 3, + s: Untyped | None = None, + eps: float = 1e-16, + ) -> None: ... class LSQBivariateSpline(BivariateSpline): fp: Untyped tck: Untyped degrees: Untyped def __init__( - self, x, y, z, tx, ty, w: Untyped | None = None, bbox=..., kx: int = 3, ky: int = 3, eps: Untyped | None = None - ): ... + self, + x, + y, + z, + /, + tx, + ty, + *, + w: Untyped | None = None, + bbox=..., + kx: int = 3, + ky: int = 3, + eps: Untyped | None = None, + ) -> None: ... 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): ... + def __init__(self, x, y, z, /, *, bbox=..., kx: int = 3, ky: int = 3, s: int = 0) -> None: ... class SphereBivariateSpline(_BivariateSplineBase): - def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, grid: bool = True) -> Untyped: ... + @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: ... 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): ... - def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, grid: bool = True) -> Untyped: ... + def __init__(self, theta, phi, r, /, *, 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: ... 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): ... - def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, grid: bool = True) -> Untyped: ... + def __init__(self, theta, phi, r, /, tt, tp, *, 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: ... class RectSphereBivariateSpline(SphereBivariateSpline): fp: Untyped @@ -99,10 +139,13 @@ class RectSphereBivariateSpline(SphereBivariateSpline): u, v, r, + /, s: float = 0.0, + *, pole_continuity: bool = False, pole_values: Untyped | None = None, pole_exact: bool = False, pole_flat: bool = False, - ): ... - def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, grid: bool = True) -> Untyped: ... + ) -> None: ... + @override + def __call__(self, theta, phi, dtheta: int = 0, dphi: int = 0, /, *, grid: bool = True) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_fitpack_py.pyi b/scipy-stubs/interpolate/_fitpack_py.pyi index cc6d2894..cfe5e398 100644 --- a/scipy-stubs/interpolate/_fitpack_py.pyi +++ b/scipy-stubs/interpolate/_fitpack_py.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._bsplines import BSpline as BSpline from ._fitpack_impl import bisplev as bisplev, bisplrep as bisplrep, dblint as dblint diff --git a/scipy-stubs/interpolate/_interpolate.pyi b/scipy-stubs/interpolate/_interpolate.pyi index 916399e3..837d89fb 100644 --- a/scipy-stubs/interpolate/_interpolate.pyi +++ b/scipy-stubs/interpolate/_interpolate.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - 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 diff --git a/scipy-stubs/interpolate/_ndbspline.pyi b/scipy-stubs/interpolate/_ndbspline.pyi index 56b95bc2..11008750 100644 --- a/scipy-stubs/interpolate/_ndbspline.pyi +++ b/scipy-stubs/interpolate/_ndbspline.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse import csr_array as csr_array class NdBSpline: diff --git a/scipy-stubs/interpolate/_ndgriddata.pyi b/scipy-stubs/interpolate/_ndgriddata.pyi index 42ec4643..407429b3 100644 --- a/scipy-stubs/interpolate/_ndgriddata.pyi +++ b/scipy-stubs/interpolate/_ndgriddata.pyi @@ -2,11 +2,9 @@ from typing import Any from typing_extensions import override import numpy as np - import numpy.typing as npt import optype.numpy as onpt from scipy._typing import Untyped - from .interpnd import CloughTocher2DInterpolator, LinearNDInterpolator, NDInterpolatorBase __all__ = ["CloughTocher2DInterpolator", "LinearNDInterpolator", "NearestNDInterpolator", "griddata"] diff --git a/scipy-stubs/interpolate/_pade.pyi b/scipy-stubs/interpolate/_pade.pyi index 88153774..69a0925c 100644 --- a/scipy-stubs/interpolate/_pade.pyi +++ b/scipy-stubs/interpolate/_pade.pyi @@ -1,5 +1,4 @@ -from scipy._typing import Untyped - from scipy import linalg as linalg +from scipy._typing import Untyped def pade(an, m, n: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_polyint.pyi b/scipy-stubs/interpolate/_polyint.pyi index a00d8a18..0a1aa6c6 100644 --- a/scipy-stubs/interpolate/_polyint.pyi +++ b/scipy-stubs/interpolate/_polyint.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - 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: diff --git a/scipy-stubs/interpolate/_rbf.pyi b/scipy-stubs/interpolate/_rbf.pyi index a0c7ab7f..8dea9876 100644 --- a/scipy-stubs/interpolate/_rbf.pyi +++ b/scipy-stubs/interpolate/_rbf.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - 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 diff --git a/scipy-stubs/interpolate/_rbfinterp.pyi b/scipy-stubs/interpolate/_rbfinterp.pyi index 1f242756..f19f1d1c 100644 --- a/scipy-stubs/interpolate/_rbfinterp.pyi +++ b/scipy-stubs/interpolate/_rbfinterp.pyi @@ -1,8 +1,6 @@ from scipy._typing import Untyped -from scipy.linalg.lapack import dgesv as dgesv -from scipy.spatial import KDTree as KDTree -from scipy.special import comb as comb +__all__ = ["RBFInterpolator"] class RBFInterpolator: y: Untyped @@ -16,12 +14,12 @@ class RBFInterpolator: powers: Untyped def __init__( self, - y, - d, + y: Untyped, + d: Untyped, neighbors: Untyped | None = None, smoothing: float = 0.0, kernel: str = "thin_plate_spline", epsilon: Untyped | None = None, degree: Untyped | None = None, - ): ... - def __call__(self, x) -> Untyped: ... + ) -> None: ... + def __call__(self, x: Untyped) -> Untyped: ... diff --git a/scipy-stubs/interpolate/interpnd.pyi b/scipy-stubs/interpolate/interpnd.pyi index f5493752..6e7b2b43 100644 --- a/scipy-stubs/interpolate/interpnd.pyi +++ b/scipy-stubs/interpolate/interpnd.pyi @@ -2,7 +2,6 @@ from typing import Any from typing_extensions import override import numpy as np - import numpy.typing as npt import optype.numpy as onpt diff --git a/scipy-stubs/io/_fast_matrix_market/__init__.pyi b/scipy-stubs/io/_fast_matrix_market/__init__.pyi index 4cbf5a94..152153dc 100644 --- a/scipy-stubs/io/_fast_matrix_market/__init__.pyi +++ b/scipy-stubs/io/_fast_matrix_market/__init__.pyi @@ -1,30 +1,19 @@ import io - -import threadpoolctl +from typing_extensions import override from scipy._typing import Untyped +__all__ = ["mminfo", "mmread", "mmwrite"] + PARALLELISM: int ALWAYS_FIND_SYMMETRY: bool -class _FMMThreadPoolCtlController(threadpoolctl.LibController): - user_api: str - internal_api: str - filename_prefixes: Untyped - def get_num_threads(self) -> Untyped: ... - def set_num_threads(self, num_threads): ... - def get_version(self) -> Untyped: ... - def set_additional_attributes(self): ... - class _TextToBytesWrapper(io.BufferedReader): encoding: Untyped errors: Untyped def __init__(self, text_io_buffer, encoding: Untyped | None = None, errors: Untyped | None = None, **kwargs): ... - def __del__(self) -> None: ... - def read(self, size: int = -1) -> Untyped: ... - def read1(self, size: int = -1) -> Untyped: ... - def peek(self, size: int = -1) -> Untyped: ... - def seek(self, offset, whence: int = 0): ... + @override + def seek(self, offset: int, whence: int = 0, /) -> None: ... # type: ignore[override] def mmread(source) -> Untyped: ... def mmwrite( diff --git a/scipy-stubs/io/_harwell_boeing/hb.pyi b/scipy-stubs/io/_harwell_boeing/hb.pyi index 6ef46dd9..89ffeeae 100644 --- a/scipy-stubs/io/_harwell_boeing/hb.pyi +++ b/scipy-stubs/io/_harwell_boeing/hb.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse import csc_matrix as csc_matrix from ._fortran_format_parser import ExpFormat as ExpFormat, FortranFormatParser as FortranFormatParser, IntFormat as IntFormat diff --git a/scipy-stubs/io/_idl.pyi b/scipy-stubs/io/_idl.pyi index 61cc3a26..defb156d 100644 --- a/scipy-stubs/io/_idl.pyi +++ b/scipy-stubs/io/_idl.pyi @@ -1,27 +1,21 @@ -from scipy._typing import Untyped +from typing import Any -DTYPE_DICT: Untyped -RECTYPE_DICT: Untyped -STRUCT_DICT: Untyped +__all__ = ["readsav"] class Pointer: - index: Untyped - def __init__(self, index) -> None: ... + index: int + def __init__(self, index: int) -> None: ... class ObjectPointer(Pointer): ... -class AttrDict(dict): - def __init__(self, init: Untyped | None = None): ... - def __getitem__(self, name) -> Untyped: ... - def __setitem__(self, key, value) -> None: ... - def __getattr__(self, name) -> Untyped: ... - __setattr__ = __setitem__ - __call__ = __getitem__ +class AttrDict(dict[str, Any]): + def __init__(self, /, init: dict[str, Any] = ...) -> None: ... + def __call__(self, name: str, /) -> Any: ... def readsav( - file_name, - idict: Untyped | None = None, + file_name: str, + idict: dict[str, Any] | None = None, python_dict: bool = False, - uncompressed_file_name: Untyped | None = None, + uncompressed_file_name: str | None = None, verbose: bool = False, -) -> Untyped: ... +) -> dict[str, Any]: ... diff --git a/scipy-stubs/io/_mmio.pyi b/scipy-stubs/io/_mmio.pyi index f9bbd515..fab7ec4e 100644 --- a/scipy-stubs/io/_mmio.pyi +++ b/scipy-stubs/io/_mmio.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse import coo_matrix as coo_matrix, issparse as issparse def asstr(s) -> Untyped: ... @@ -44,7 +43,7 @@ class MMFile: @staticmethod def writer(): ... @classmethod - def info(self, source) -> Untyped: ... + def info(cls, /, source) -> Untyped: ... def __init__(self, **kwargs) -> None: ... def read(self, source) -> Untyped: ... def write( diff --git a/scipy-stubs/io/_netcdf.pyi b/scipy-stubs/io/_netcdf.pyi index 175df81d..ab62f980 100644 --- a/scipy-stubs/io/_netcdf.pyi +++ b/scipy-stubs/io/_netcdf.pyi @@ -48,6 +48,10 @@ class netcdf_variable: data: Untyped dimensions: Untyped maskandscale: Untyped + @property + def isrec(self) -> Untyped: ... + @property + def shape(self) -> Untyped: ... def __init__( self, data, @@ -59,10 +63,6 @@ class netcdf_variable: maskandscale: bool = False, ): ... def __setattr__(self, attr, value) -> None: ... - def isrec(self) -> Untyped: ... - isrec: Untyped - def shape(self) -> Untyped: ... - shape: Untyped def getValue(self) -> Untyped: ... def assignValue(self, value): ... def typecode(self) -> Untyped: ... diff --git a/scipy-stubs/io/matlab/_mio.pyi b/scipy-stubs/io/matlab/_mio.pyi index 0da17cc7..b4016220 100644 --- a/scipy-stubs/io/matlab/_mio.pyi +++ b/scipy-stubs/io/matlab/_mio.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._mio4 import MatFile4Reader as MatFile4Reader, MatFile4Writer as MatFile4Writer from ._mio5 import MatFile5Reader as MatFile5Reader, MatFile5Writer as MatFile5Writer from ._miobase import docfiller as docfiller diff --git a/scipy-stubs/io/matlab/_mio4.pyi b/scipy-stubs/io/matlab/_mio4.pyi index 70e647b2..66819375 100644 --- a/scipy-stubs/io/matlab/_mio4.pyi +++ b/scipy-stubs/io/matlab/_mio4.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._miobase import MatFileReader __all__ = [ diff --git a/scipy-stubs/io/matlab/_mio5.pyi b/scipy-stubs/io/matlab/_mio5.pyi index 095b423a..b4a43487 100644 --- a/scipy-stubs/io/matlab/_mio5.pyi +++ b/scipy-stubs/io/matlab/_mio5.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._byteordercodes import native_code as native_code, swapped_code as swapped_code from ._mio5_params import ( MDTYPES as MDTYPES, diff --git a/scipy-stubs/io/matlab/_mio5_params.pyi b/scipy-stubs/io/matlab/_mio5_params.pyi index f5ddfca8..c62d7fb6 100644 --- a/scipy-stubs/io/matlab/_mio5_params.pyi +++ b/scipy-stubs/io/matlab/_mio5_params.pyi @@ -1,8 +1,56 @@ -import numpy as np +from typing import Literal +from typing_extensions import Self, override -from scipy._typing import Untyped +import numpy as np +from scipy._typing import Untyped, UntypedDict -from ._miobase import convert_dtypes as convert_dtypes +__all__ = [ + "MDTYPES", + "NP_TO_MTYPES", + "NP_TO_MXTYPES", + "OPAQUE_DTYPE", + "MatlabFunction", + "MatlabObject", + "MatlabOpaque", + "codecs_template", + "mat_struct", + "mclass_dtypes_template", + "mclass_info", + "mdtypes_template", + "miCOMPRESSED", + "miDOUBLE", + "miINT8", + "miINT16", + "miINT32", + "miINT64", + "miMATRIX", + "miSINGLE", + "miUINT8", + "miUINT16", + "miUINT32", + "miUINT64", + "miUTF8", + "miUTF16", + "miUTF32", + "mxCELL_CLASS", + "mxCHAR_CLASS", + "mxDOUBLE_CLASS", + "mxFUNCTION_CLASS", + "mxINT8_CLASS", + "mxINT16_CLASS", + "mxINT32_CLASS", + "mxINT64_CLASS", + "mxOBJECT_CLASS", + "mxOBJECT_CLASS_FROM_MATRIX_H", + "mxOPAQUE_CLASS", + "mxSINGLE_CLASS", + "mxSPARSE_CLASS", + "mxSTRUCT_CLASS", + "mxUINT8_CLASS", + "mxUINT16_CLASS", + "mxUINT32_CLASS", + "mxUINT64_CLASS", +] miINT8: int miUINT8: int @@ -37,25 +85,27 @@ mxUINT64_CLASS: int mxFUNCTION_CLASS: int mxOPAQUE_CLASS: int mxOBJECT_CLASS_FROM_MATRIX_H: int -mdtypes_template: Untyped -mclass_dtypes_template: Untyped -mclass_info: Untyped -NP_TO_MTYPES: Untyped -NP_TO_MXTYPES: Untyped -codecs_template: Untyped -MDTYPES: Untyped +mdtypes_template: UntypedDict +mclass_dtypes_template: dict[int, str] +mclass_info: dict[int, str] +NP_TO_MTYPES: dict[str, int] +NP_TO_MXTYPES: dict[str, int] +codecs_template: dict[int, dict[str, str]] +MDTYPES: UntypedDict class mat_struct: ... -class MatlabObject(np.ndarray): - def __new__(cls, input_array, classname: Untyped | None = None) -> Untyped: ... - classname: Untyped - def __array_finalize__(self, obj): ... +class MatlabObject(np.ndarray[tuple[int, ...], np.dtype[np.void]]): + classname: str | None + + def __new__(cls, input_array: np.ndarray[tuple[int, ...], np.dtype[np.void]], classname: Untyped | None = None) -> Self: ... + @override + def __array_finalize__(self, obj: Self) -> None: ... # type: ignore[override] -class MatlabFunction(np.ndarray): - def __new__(cls, input_array) -> Untyped: ... +class MatlabFunction(np.ndarray[tuple[int, ...], np.dtype[np.void]]): + def __new__(cls, input_array: np.ndarray[tuple[int, ...], np.dtype[np.void]]) -> Self: ... -class MatlabOpaque(np.ndarray): - def __new__(cls, input_array) -> Untyped: ... +class MatlabOpaque(np.ndarray[tuple[int, ...], np.dtype[np.void]]): + def __new__(cls, input_array: np.ndarray[tuple[int, ...], np.dtype[np.void]]) -> Self: ... -OPAQUE_DTYPE: Untyped +OPAQUE_DTYPE: np.dtypes.VoidDType[Literal[32]] diff --git a/scipy-stubs/io/matlab/_miobase.pyi b/scipy-stubs/io/matlab/_miobase.pyi index 46637301..8394f7a0 100644 --- a/scipy-stubs/io/matlab/_miobase.pyi +++ b/scipy-stubs/io/matlab/_miobase.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib import doccer as doccer +from scipy._typing import Untyped class MatReadError(Exception): ... class MatWriteError(Exception): ... diff --git a/scipy-stubs/linalg/_basic.pyi b/scipy-stubs/linalg/_basic.pyi index 1df4062d..abb65c82 100644 --- a/scipy-stubs/linalg/_basic.pyi +++ b/scipy-stubs/linalg/_basic.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt import scipy._typing as spt diff --git a/scipy-stubs/linalg/_cythonized_array_utils.pyi b/scipy-stubs/linalg/_cythonized_array_utils.pyi index 120a0618..fe554468 100644 --- a/scipy-stubs/linalg/_cythonized_array_utils.pyi +++ b/scipy-stubs/linalg/_cythonized_array_utils.pyi @@ -1,7 +1,6 @@ from typing import TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["bandwidth", "ishermitian", "issymmetric"] diff --git a/scipy-stubs/linalg/_decomp.pyi b/scipy-stubs/linalg/_decomp.pyi index eae5cbc0..ef7a0f62 100644 --- a/scipy-stubs/linalg/_decomp.pyi +++ b/scipy-stubs/linalg/_decomp.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt import optype as op import scipy._typing as spt diff --git a/scipy-stubs/linalg/_decomp_cholesky.pyi b/scipy-stubs/linalg/_decomp_cholesky.pyi index fc808aa3..df4c3c95 100644 --- a/scipy-stubs/linalg/_decomp_cholesky.pyi +++ b/scipy-stubs/linalg/_decomp_cholesky.pyi @@ -1,7 +1,6 @@ from typing import TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["cho_factor", "cho_solve", "cho_solve_banded", "cholesky", "cholesky_banded"] diff --git a/scipy-stubs/linalg/_decomp_cossin.pyi b/scipy-stubs/linalg/_decomp_cossin.pyi index 5fc2ff3b..1fae89dc 100644 --- a/scipy-stubs/linalg/_decomp_cossin.pyi +++ b/scipy-stubs/linalg/_decomp_cossin.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt import optype as op diff --git a/scipy-stubs/linalg/_decomp_ldl.pyi b/scipy-stubs/linalg/_decomp_ldl.pyi index ea6907e3..abb2e7fd 100644 --- a/scipy-stubs/linalg/_decomp_ldl.pyi +++ b/scipy-stubs/linalg/_decomp_ldl.pyi @@ -1,7 +1,6 @@ from typing import TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["ldl"] diff --git a/scipy-stubs/linalg/_decomp_lu.pyi b/scipy-stubs/linalg/_decomp_lu.pyi index 8eb0ec06..72147f43 100644 --- a/scipy-stubs/linalg/_decomp_lu.pyi +++ b/scipy-stubs/linalg/_decomp_lu.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt __all__ = ["lu", "lu_factor", "lu_solve"] diff --git a/scipy-stubs/linalg/_decomp_lu_cython.pyi b/scipy-stubs/linalg/_decomp_lu_cython.pyi index da54a70a..e8a9edfa 100644 --- a/scipy-stubs/linalg/_decomp_lu_cython.pyi +++ b/scipy-stubs/linalg/_decomp_lu_cython.pyi @@ -1,7 +1,6 @@ from typing import TypeVar import numpy as np - import numpy.typing as npt __all__ = ["lu_decompose", "lu_dispatcher"] diff --git a/scipy-stubs/linalg/_decomp_polar.pyi b/scipy-stubs/linalg/_decomp_polar.pyi index 5e05a2b8..0729cd2b 100644 --- a/scipy-stubs/linalg/_decomp_polar.pyi +++ b/scipy-stubs/linalg/_decomp_polar.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["polar"] diff --git a/scipy-stubs/linalg/_decomp_qr.pyi b/scipy-stubs/linalg/_decomp_qr.pyi index b1687807..cd1ba237 100644 --- a/scipy-stubs/linalg/_decomp_qr.pyi +++ b/scipy-stubs/linalg/_decomp_qr.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt __all__ = ["qr", "qr_multiply", "rq"] diff --git a/scipy-stubs/linalg/_decomp_qz.pyi b/scipy-stubs/linalg/_decomp_qz.pyi index 0b2f0428..40353e52 100644 --- a/scipy-stubs/linalg/_decomp_qz.pyi +++ b/scipy-stubs/linalg/_decomp_qz.pyi @@ -2,7 +2,6 @@ from collections.abc import Callable from typing import Literal, TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["ordqz", "qz"] diff --git a/scipy-stubs/linalg/_decomp_schur.pyi b/scipy-stubs/linalg/_decomp_schur.pyi index 9fb59170..d3e80c99 100644 --- a/scipy-stubs/linalg/_decomp_schur.pyi +++ b/scipy-stubs/linalg/_decomp_schur.pyi @@ -2,7 +2,6 @@ from collections.abc import Callable from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt __all__ = ["rsf2csf", "schur"] diff --git a/scipy-stubs/linalg/_decomp_svd.pyi b/scipy-stubs/linalg/_decomp_svd.pyi index 2866ca33..1d61a949 100644 --- a/scipy-stubs/linalg/_decomp_svd.pyi +++ b/scipy-stubs/linalg/_decomp_svd.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt import scipy._typing as spt diff --git a/scipy-stubs/linalg/_decomp_update.pyi b/scipy-stubs/linalg/_decomp_update.pyi index 770c058b..e6c4eb54 100644 --- a/scipy-stubs/linalg/_decomp_update.pyi +++ b/scipy-stubs/linalg/_decomp_update.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["qr_delete", "qr_insert", "qr_update"] diff --git a/scipy-stubs/linalg/_expm_frechet.pyi b/scipy-stubs/linalg/_expm_frechet.pyi index 1773a6e5..d3c5f174 100644 --- a/scipy-stubs/linalg/_expm_frechet.pyi +++ b/scipy-stubs/linalg/_expm_frechet.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt __all__ = ["expm_cond", "expm_frechet"] diff --git a/scipy-stubs/linalg/_matfuncs.pyi b/scipy-stubs/linalg/_matfuncs.pyi index 2deeab6e..1594fe81 100644 --- a/scipy-stubs/linalg/_matfuncs.pyi +++ b/scipy-stubs/linalg/_matfuncs.pyi @@ -2,9 +2,7 @@ from collections.abc import Callable from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt - from ._expm_frechet import expm_cond, expm_frechet from ._matfuncs_sqrtm import sqrtm diff --git a/scipy-stubs/linalg/_matfuncs_expm.pyi b/scipy-stubs/linalg/_matfuncs_expm.pyi index 6f1e7b1f..56095fc3 100644 --- a/scipy-stubs/linalg/_matfuncs_expm.pyi +++ b/scipy-stubs/linalg/_matfuncs_expm.pyi @@ -1,5 +1,4 @@ import numpy as np - import numpy.typing as npt __all__ = ["pade_UV_calc", "pick_pade_structure"] diff --git a/scipy-stubs/linalg/_matfuncs_inv_ssq.pyi b/scipy-stubs/linalg/_matfuncs_inv_ssq.pyi index c3b4bb29..c579c169 100644 --- a/scipy-stubs/linalg/_matfuncs_inv_ssq.pyi +++ b/scipy-stubs/linalg/_matfuncs_inv_ssq.pyi @@ -1,7 +1,5 @@ import numpy as np - import numpy.typing as npt - from scipy.sparse.linalg._interface import LinearOperator class LogmRankWarning(UserWarning): ... diff --git a/scipy-stubs/linalg/_matfuncs_sqrtm.pyi b/scipy-stubs/linalg/_matfuncs_sqrtm.pyi index 3b8086c4..d66547dc 100644 --- a/scipy-stubs/linalg/_matfuncs_sqrtm.pyi +++ b/scipy-stubs/linalg/_matfuncs_sqrtm.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt __all__ = ["sqrtm"] diff --git a/scipy-stubs/linalg/_matfuncs_sqrtm_triu.pyi b/scipy-stubs/linalg/_matfuncs_sqrtm_triu.pyi index 07c7d330..a00cb03b 100644 --- a/scipy-stubs/linalg/_matfuncs_sqrtm_triu.pyi +++ b/scipy-stubs/linalg/_matfuncs_sqrtm_triu.pyi @@ -2,7 +2,6 @@ from collections.abc import Iterable from typing import overload import numpy as np - import numpy.typing as npt @overload diff --git a/scipy-stubs/linalg/_misc.pyi b/scipy-stubs/linalg/_misc.pyi index 37a9b55d..79e2aa6e 100644 --- a/scipy-stubs/linalg/_misc.pyi +++ b/scipy-stubs/linalg/_misc.pyi @@ -1,9 +1,8 @@ from typing import Literal import numpy as np -from numpy.linalg import LinAlgError # noqa: ICN003 - import numpy.typing as npt +from numpy.linalg import LinAlgError # noqa: ICN003 from scipy._typing import Untyped __all__ = ["LinAlgError", "LinAlgWarning", "norm"] diff --git a/scipy-stubs/linalg/_procrustes.pyi b/scipy-stubs/linalg/_procrustes.pyi index fc988ee5..9e7badcc 100644 --- a/scipy-stubs/linalg/_procrustes.pyi +++ b/scipy-stubs/linalg/_procrustes.pyi @@ -1,7 +1,6 @@ from typing import TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["orthogonal_procrustes"] diff --git a/scipy-stubs/linalg/_sketches.pyi b/scipy-stubs/linalg/_sketches.pyi index 69ce7977..fa9cacd9 100644 --- a/scipy-stubs/linalg/_sketches.pyi +++ b/scipy-stubs/linalg/_sketches.pyi @@ -1,8 +1,6 @@ import numpy as np - import numpy.typing as npt import scipy._typing as spt - from scipy.sparse import csc_matrix __all__ = ["clarkson_woodruff_transform"] diff --git a/scipy-stubs/linalg/_solve_toeplitz.pyi b/scipy-stubs/linalg/_solve_toeplitz.pyi index 3606fd1a..89c3df8e 100644 --- a/scipy-stubs/linalg/_solve_toeplitz.pyi +++ b/scipy-stubs/linalg/_solve_toeplitz.pyi @@ -1,7 +1,6 @@ from typing import TypeAlias import numpy as np - import numpy.typing as npt __all__ = ("levinson",) diff --git a/scipy-stubs/linalg/_solvers.pyi b/scipy-stubs/linalg/_solvers.pyi index 701df127..b68cf79d 100644 --- a/scipy-stubs/linalg/_solvers.pyi +++ b/scipy-stubs/linalg/_solvers.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias import numpy as np - import numpy.typing as npt __all__ = [ diff --git a/scipy-stubs/linalg/_special_matrices.pyi b/scipy-stubs/linalg/_special_matrices.pyi index 1f59ea73..d0cd9015 100644 --- a/scipy-stubs/linalg/_special_matrices.pyi +++ b/scipy-stubs/linalg/_special_matrices.pyi @@ -1,7 +1,6 @@ from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt import scipy._typing as spt diff --git a/scipy-stubs/linalg/blas.pyi b/scipy-stubs/linalg/blas.pyi index df505d06..86a5d475 100644 --- a/scipy-stubs/linalg/blas.pyi +++ b/scipy-stubs/linalg/blas.pyi @@ -2,7 +2,6 @@ from collections.abc import Iterable, Sequence from typing import Literal import numpy as np - import numpy.typing as npt import scipy._typing as spt diff --git a/scipy-stubs/linalg/interpolative.pyi b/scipy-stubs/linalg/interpolative.pyi index b0a34f1e..441b2d77 100644 --- a/scipy-stubs/linalg/interpolative.pyi +++ b/scipy-stubs/linalg/interpolative.pyi @@ -2,10 +2,8 @@ from typing import SupportsIndex, TypeAlias, TypeVar from typing_extensions import Never, deprecated import numpy as np - import numpy.typing as npt import scipy._typing as spt - from scipy.sparse.linalg import LinearOperator __all__ = [ diff --git a/scipy-stubs/linalg/lapack.pyi b/scipy-stubs/linalg/lapack.pyi index 441ccf65..c08dda71 100644 --- a/scipy-stubs/linalg/lapack.pyi +++ b/scipy-stubs/linalg/lapack.pyi @@ -2,7 +2,6 @@ from collections.abc import Iterable, Sequence from typing import Final, Literal import numpy as np - import numpy.typing as npt import scipy._typing as spt diff --git a/scipy-stubs/misc/__init__.pyi b/scipy-stubs/misc/__init__.pyi index 3ba03cad..157378c8 100644 --- a/scipy-stubs/misc/__init__.pyi +++ b/scipy-stubs/misc/__init__.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from . import common as common, doccer as doccer from ._common import * diff --git a/scipy-stubs/ndimage/__init__.pyi b/scipy-stubs/ndimage/__init__.pyi index e38e9215..030a5705 100644 --- a/scipy-stubs/ndimage/__init__.pyi +++ b/scipy-stubs/ndimage/__init__.pyi @@ -1,8 +1,6 @@ -from . import ( - filters as filters, - fourier as fourier, - interpolation as interpolation, - measurements as measurements, - morphology as morphology, -) -from ._support_alternative_backends import * +from . import filters, fourier, interpolation, measurements, morphology +from ._filters import * +from ._fourier import * +from ._interpolation import * +from ._measurements import * +from ._morphology import * diff --git a/scipy-stubs/ndimage/_dispatchers.pyi b/scipy-stubs/ndimage/_dispatchers.pyi index ca332249..b99cee16 100644 --- a/scipy-stubs/ndimage/_dispatchers.pyi +++ b/scipy-stubs/ndimage/_dispatchers.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._array_api import array_namespace as array_namespace +from scipy._typing import Untyped def affine_transform_dispatcher( input, matrix, offset: float = 0.0, output_shape: Untyped | None = None, output: Untyped | None = None, *args, **kwds diff --git a/scipy-stubs/ndimage/_filters.pyi b/scipy-stubs/ndimage/_filters.pyi index fc9a3512..5783af69 100644 --- a/scipy-stubs/ndimage/_filters.pyi +++ b/scipy-stubs/ndimage/_filters.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import normalize_axis_index as normalize_axis_index +from scipy._typing import Untyped def correlate1d( input, weights, axis: int = -1, output: Untyped | None = None, mode: str = "reflect", cval: float = 0.0, origin: int = 0 diff --git a/scipy-stubs/ndimage/_fourier.pyi b/scipy-stubs/ndimage/_fourier.pyi index 3121e1fe..99a002fb 100644 --- a/scipy-stubs/ndimage/_fourier.pyi +++ b/scipy-stubs/ndimage/_fourier.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import normalize_axis_index as normalize_axis_index +from scipy._typing import Untyped def fourier_gaussian(input, sigma, n: int = -1, axis: int = -1, output: Untyped | None = None) -> Untyped: ... def fourier_uniform(input, size, n: int = -1, axis: int = -1, output: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/ndimage/_interpolation.pyi b/scipy-stubs/ndimage/_interpolation.pyi index 9d94d284..d20acaac 100644 --- a/scipy-stubs/ndimage/_interpolation.pyi +++ b/scipy-stubs/ndimage/_interpolation.pyi @@ -1,7 +1,6 @@ -from scipy._typing import Untyped - from scipy import special as special from scipy._lib._util import normalize_axis_index as normalize_axis_index +from scipy._typing import Untyped from ._ni_docstrings import docfiller as docfiller def spline_filter1d(input, order: int = 3, axis: int = -1, output=..., mode: str = "mirror") -> Untyped: ... diff --git a/scipy-stubs/ndimage/_ni_docstrings.pyi b/scipy-stubs/ndimage/_ni_docstrings.pyi index 4adcb802..75832b76 100644 --- a/scipy-stubs/ndimage/_ni_docstrings.pyi +++ b/scipy-stubs/ndimage/_ni_docstrings.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib import doccer as doccer +from scipy._typing import Untyped docdict: Untyped docfiller: Untyped diff --git a/scipy-stubs/ndimage/_support_alternative_backends.pyi b/scipy-stubs/ndimage/_support_alternative_backends.pyi deleted file mode 100644 index 18804c74..00000000 --- a/scipy-stubs/ndimage/_support_alternative_backends.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from scipy._typing import Untyped - -from scipy._lib._array_api import ( - SCIPY_ARRAY_API as SCIPY_ARRAY_API, - is_cupy as is_cupy, - is_jax as is_jax, - scipy_namespace_for as scipy_namespace_for, -) -from ._ndimage_api import * - -MODULE_NAME: str - -def dispatch_xp(dispatcher, module_name) -> Untyped: ... - -bare_func: Untyped -dispatcher: Untyped -f: Untyped diff --git a/scipy-stubs/odr/_models.pyi b/scipy-stubs/odr/_models.pyi index da071c99..54d8e68a 100644 --- a/scipy-stubs/odr/_models.pyi +++ b/scipy-stubs/odr/_models.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.odr._odrpack import Model as Model class _MultilinearModel(Model): diff --git a/scipy-stubs/optimize/_basinhopping.pyi b/scipy-stubs/optimize/_basinhopping.pyi index 33a2bf5c..21cb10fc 100644 --- a/scipy-stubs/optimize/_basinhopping.pyi +++ b/scipy-stubs/optimize/_basinhopping.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import check_random_state as check_random_state +from scipy._typing import Untyped class Storage: def __init__(self, minres) -> None: ... diff --git a/scipy-stubs/optimize/_chandrupatla.pyi b/scipy-stubs/optimize/_chandrupatla.pyi index a5c4c623..f93c5705 100644 --- a/scipy-stubs/optimize/_chandrupatla.pyi +++ b/scipy-stubs/optimize/_chandrupatla.pyi @@ -1 +1 @@ -from scipy._lib._array_api import xp_copy as xp_copy, xp_sign as xp_sign, xp_take_along_axis as xp_take_along_axis +# nothing to see here diff --git a/scipy-stubs/optimize/_cobyla_py.pyi b/scipy-stubs/optimize/_cobyla_py.pyi index d20384ff..298ffc6b 100644 --- a/scipy-stubs/optimize/_cobyla_py.pyi +++ b/scipy-stubs/optimize/_cobyla_py.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._optimize import OptimizeResult as OptimizeResult izip = zip diff --git a/scipy-stubs/optimize/_constraints.pyi b/scipy-stubs/optimize/_constraints.pyi index 28f22d13..e0dc718a 100644 --- a/scipy-stubs/optimize/_constraints.pyi +++ b/scipy-stubs/optimize/_constraints.pyi @@ -1,13 +1,16 @@ from scipy._typing import Untyped -from scipy.sparse import issparse as issparse -from ._differentiable_functions import ( - IdentityVectorFunction as IdentityVectorFunction, - LinearVectorFunction as LinearVectorFunction, - VectorFunction as VectorFunction, +__all__ = ( + "Bounds", + "LinearConstraint", + "NonlinearConstraint", + "PreparedConstraint", + "new_bounds_to_old", + "new_constraint_to_old", + "old_bound_to_new", + "old_constraint_to_new", + "strict_bounds", ) -from ._hessian_update_strategy import BFGS as BFGS -from ._optimize import OptimizeWarning as OptimizeWarning class NonlinearConstraint: fun: Untyped diff --git a/scipy-stubs/optimize/_differentiable_functions.pyi b/scipy-stubs/optimize/_differentiable_functions.pyi index 3529738e..7b5724b0 100644 --- a/scipy-stubs/optimize/_differentiable_functions.pyi +++ b/scipy-stubs/optimize/_differentiable_functions.pyi @@ -1,11 +1,8 @@ -from scipy._typing import Untyped +from typing import Final -from scipy._lib._array_api import array_namespace as array_namespace, xp_atleast_nd as xp_atleast_nd -from scipy.sparse.linalg import LinearOperator as LinearOperator -from ._hessian_update_strategy import HessianUpdateStrategy as HessianUpdateStrategy -from ._numdiff import approx_derivative as approx_derivative, group_columns as group_columns +from scipy._typing import Untyped -FD_METHODS: Untyped +FD_METHODS: Final = ("2-point", "3-point", "cs") class ScalarFunction: xp: Untyped @@ -18,7 +15,17 @@ class ScalarFunction: H: Untyped x_prev: Untyped g_prev: Untyped - def __init__(self, fun, x0, args, grad, hess, finite_diff_rel_step, finite_diff_bounds, epsilon: Untyped | None = None): ... + def __init__( + self, + fun: Untyped, + x0: Untyped, + args: Untyped, + grad: Untyped, + hess: Untyped, + finite_diff_rel_step: Untyped, + finite_diff_bounds: Untyped, + epsilon: Untyped | None = None, + ): ... @property def nfev(self) -> Untyped: ... @property @@ -51,7 +58,15 @@ class VectorFunction: x_prev: Untyped J_prev: Untyped def __init__( - self, fun, x0, jac, hess, finite_diff_rel_step, finite_diff_jac_sparsity, finite_diff_bounds, sparse_jacobian + self, + fun: Untyped, + x0: Untyped, + jac: Untyped, + hess: Untyped, + finite_diff_rel_step: Untyped, + finite_diff_jac_sparsity: Untyped, + finite_diff_bounds: Untyped, + sparse_jacobian: Untyped, ) -> None: ... def fun(self, x) -> Untyped: ... def jac(self, x) -> Untyped: ... diff --git a/scipy-stubs/optimize/_differentialevolution.pyi b/scipy-stubs/optimize/_differentialevolution.pyi index abe210a3..6530d171 100644 --- a/scipy-stubs/optimize/_differentialevolution.pyi +++ b/scipy-stubs/optimize/_differentialevolution.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import MapWrapper as MapWrapper, check_random_state as check_random_state, rng_integers as rng_integers +from scipy._typing import Untyped from scipy.optimize import OptimizeResult as OptimizeResult, minimize as minimize from scipy.optimize._constraints import ( Bounds as Bounds, diff --git a/scipy-stubs/optimize/_direct_py.pyi b/scipy-stubs/optimize/_direct_py.pyi index d18e783d..083e0339 100644 --- a/scipy-stubs/optimize/_direct_py.pyi +++ b/scipy-stubs/optimize/_direct_py.pyi @@ -3,18 +3,19 @@ from typing import Any import numpy.typing as npt from scipy._typing import Untyped +from ._constraints import Bounds +from ._optimize import OptimizeResult -from scipy.optimize import OptimizeResult as OptimizeResult -from ._constraints import Bounds as Bounds, old_bound_to_new as old_bound_to_new +__all__ = ["direct"] -ERROR_MESSAGES: Untyped -SUCCESS_MESSAGES: Untyped +ERROR_MESSAGES: tuple[str, ...] +SUCCESS_MESSAGES: tuple[str, ...] def direct( func: Callable[[npt.ArrayLike, tuple[Any]], float], - bounds: Iterable | Bounds, + bounds: Iterable[float] | Bounds, *, - args: tuple = (), + args: tuple[Untyped, ...] = (), eps: float = 0.0001, maxfun: int | None = None, maxiter: int = 1000, diff --git a/scipy-stubs/optimize/_dual_annealing.pyi b/scipy-stubs/optimize/_dual_annealing.pyi index d9c190f3..51a30ea5 100644 --- a/scipy-stubs/optimize/_dual_annealing.pyi +++ b/scipy-stubs/optimize/_dual_annealing.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import check_random_state as check_random_state +from scipy._typing import Untyped from scipy.optimize import Bounds as Bounds, OptimizeResult as OptimizeResult, minimize as minimize from scipy.optimize._constraints import new_bounds_to_old as new_bounds_to_old from scipy.special import gammaln as gammaln diff --git a/scipy-stubs/optimize/_hessian_update_strategy.pyi b/scipy-stubs/optimize/_hessian_update_strategy.pyi index d5b09d6e..9176159d 100644 --- a/scipy-stubs/optimize/_hessian_update_strategy.pyi +++ b/scipy-stubs/optimize/_hessian_update_strategy.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.linalg import get_blas_funcs as get_blas_funcs, issymmetric as issymmetric class HessianUpdateStrategy: diff --git a/scipy-stubs/optimize/_isotonic.pyi b/scipy-stubs/optimize/_isotonic.pyi index 5f3b113b..5b96e048 100644 --- a/scipy-stubs/optimize/_isotonic.pyi +++ b/scipy-stubs/optimize/_isotonic.pyi @@ -1,5 +1,4 @@ import numpy.typing as npt - from ._optimize import OptimizeResult __all__ = ["isotonic_regression"] diff --git a/scipy-stubs/optimize/_lbfgsb_py.pyi b/scipy-stubs/optimize/_lbfgsb_py.pyi index 7b467621..81b7ca92 100644 --- a/scipy-stubs/optimize/_lbfgsb_py.pyi +++ b/scipy-stubs/optimize/_lbfgsb_py.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse.linalg import LinearOperator as LinearOperator from ._constraints import old_bound_to_new as old_bound_to_new from ._optimize import MemoizeJac as MemoizeJac, OptimizeResult as OptimizeResult diff --git a/scipy-stubs/optimize/_linesearch.pyi b/scipy-stubs/optimize/_linesearch.pyi index c5ce9b2b..fb4938d8 100644 --- a/scipy-stubs/optimize/_linesearch.pyi +++ b/scipy-stubs/optimize/_linesearch.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._dcsrch import DCSRCH as DCSRCH class LineSearchWarning(RuntimeWarning): ... diff --git a/scipy-stubs/optimize/_linprog.pyi b/scipy-stubs/optimize/_linprog.pyi index a58f0f40..5fc5f371 100644 --- a/scipy-stubs/optimize/_linprog.pyi +++ b/scipy-stubs/optimize/_linprog.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._optimize import OptimizeResult as OptimizeResult, OptimizeWarning as OptimizeWarning __docformat__: str diff --git a/scipy-stubs/optimize/_linprog_util.pyi b/scipy-stubs/optimize/_linprog_util.pyi index d65b3384..a31feb29 100644 --- a/scipy-stubs/optimize/_linprog_util.pyi +++ b/scipy-stubs/optimize/_linprog_util.pyi @@ -1,7 +1,6 @@ from typing import NamedTuple from scipy._typing import Untyped - from ._optimize import OptimizeWarning as OptimizeWarning class _LPProblem(NamedTuple): diff --git a/scipy-stubs/optimize/_lsq/bvls.pyi b/scipy-stubs/optimize/_lsq/bvls.pyi index 54fc3f32..e41e16fb 100644 --- a/scipy-stubs/optimize/_lsq/bvls.pyi +++ b/scipy-stubs/optimize/_lsq/bvls.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.optimize import OptimizeResult as OptimizeResult from .common import print_header_linear as print_header_linear, print_iteration_linear as print_iteration_linear diff --git a/scipy-stubs/optimize/_lsq/common.pyi b/scipy-stubs/optimize/_lsq/common.pyi index eedca494..549bc924 100644 --- a/scipy-stubs/optimize/_lsq/common.pyi +++ b/scipy-stubs/optimize/_lsq/common.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.linalg import LinAlgError as LinAlgError, cho_factor as cho_factor, cho_solve as cho_solve from scipy.sparse import issparse as issparse from scipy.sparse.linalg import LinearOperator as LinearOperator, aslinearoperator as aslinearoperator diff --git a/scipy-stubs/optimize/_lsq/dogbox.pyi b/scipy-stubs/optimize/_lsq/dogbox.pyi index bdeea9d7..5f9a5df9 100644 --- a/scipy-stubs/optimize/_lsq/dogbox.pyi +++ b/scipy-stubs/optimize/_lsq/dogbox.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.optimize import OptimizeResult as OptimizeResult from scipy.sparse.linalg import LinearOperator as LinearOperator, aslinearoperator as aslinearoperator, lsmr as lsmr from .common import ( diff --git a/scipy-stubs/optimize/_lsq/least_squares.pyi b/scipy-stubs/optimize/_lsq/least_squares.pyi index 6898d421..f60f4642 100644 --- a/scipy-stubs/optimize/_lsq/least_squares.pyi +++ b/scipy-stubs/optimize/_lsq/least_squares.pyi @@ -1,16 +1,9 @@ from scipy._typing import Untyped - -from scipy.optimize import OptimizeResult as OptimizeResult -from scipy.optimize._minimize import Bounds as Bounds -from scipy.optimize._numdiff import approx_derivative as approx_derivative, group_columns as group_columns -from scipy.sparse import issparse as issparse -from scipy.sparse.linalg import LinearOperator as LinearOperator -from .common import EPS as EPS, in_bounds as in_bounds, make_strictly_feasible as make_strictly_feasible -from .dogbox import dogbox as dogbox -from .trf import trf as trf +from scipy.optimize import OptimizeResult TERMINATION_MESSAGES: Untyped FROM_MINPACK_TO_COMMON: Untyped +IMPLEMENTED_LOSSES: Untyped def call_minpack(fun, x0, jac, ftol, xtol, gtol, max_nfev, x_scale, diff_step) -> Untyped: ... def prepare_bounds(bounds, n) -> Untyped: ... @@ -21,9 +14,6 @@ def huber(z, rho, cost_only): ... def soft_l1(z, rho, cost_only): ... def cauchy(z, rho, cost_only): ... def arctan(z, rho, cost_only): ... - -IMPLEMENTED_LOSSES: Untyped - def construct_loss_function(m, loss, f_scale) -> Untyped: ... def least_squares( fun, @@ -45,4 +35,4 @@ def least_squares( verbose: int = 0, args=(), kwargs: Untyped | None = None, -) -> Untyped: ... +) -> OptimizeResult: ... diff --git a/scipy-stubs/optimize/_lsq/lsq_linear.pyi b/scipy-stubs/optimize/_lsq/lsq_linear.pyi index a5a2f75a..f973b659 100644 --- a/scipy-stubs/optimize/_lsq/lsq_linear.pyi +++ b/scipy-stubs/optimize/_lsq/lsq_linear.pyi @@ -1,17 +1,11 @@ +from typing import Final + from scipy._typing import Untyped +from scipy.optimize import OptimizeResult -from scipy.optimize import OptimizeResult as OptimizeResult -from scipy.optimize._minimize import Bounds as Bounds -from scipy.sparse import csr_matrix as csr_matrix, issparse as issparse -from scipy.sparse.linalg import LinearOperator as LinearOperator, lsmr as lsmr -from .bvls import bvls as bvls -from .common import compute_grad as compute_grad, in_bounds as in_bounds -from .trf_linear import trf_linear as trf_linear +TERMINATION_MESSAGES: Final[dict[int, str]] def prepare_bounds(bounds, n) -> Untyped: ... - -TERMINATION_MESSAGES: Untyped - def lsq_linear( A, b, @@ -24,4 +18,4 @@ def lsq_linear( verbose: int = 0, *, lsmr_maxiter: Untyped | None = None, -) -> Untyped: ... +) -> OptimizeResult: ... diff --git a/scipy-stubs/optimize/_lsq/trf.pyi b/scipy-stubs/optimize/_lsq/trf.pyi index bb65f618..ee19d72e 100644 --- a/scipy-stubs/optimize/_lsq/trf.pyi +++ b/scipy-stubs/optimize/_lsq/trf.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.linalg import qr as qr, svd as svd from scipy.optimize import OptimizeResult as OptimizeResult from scipy.sparse.linalg import lsmr as lsmr diff --git a/scipy-stubs/optimize/_lsq/trf_linear.pyi b/scipy-stubs/optimize/_lsq/trf_linear.pyi index dc649716..5c7dc3c8 100644 --- a/scipy-stubs/optimize/_lsq/trf_linear.pyi +++ b/scipy-stubs/optimize/_lsq/trf_linear.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.optimize import OptimizeResult as OptimizeResult def regularized_lsq_with_qr( diff --git a/scipy-stubs/optimize/_milp.pyi b/scipy-stubs/optimize/_milp.pyi index 88dee844..854bf8a2 100644 --- a/scipy-stubs/optimize/_milp.pyi +++ b/scipy-stubs/optimize/_milp.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import VisibleDeprecationWarning as VisibleDeprecationWarning +from scipy._typing import Untyped from scipy.sparse import csc_array as csc_array, issparse as issparse, vstack as vstack from ._constraints import Bounds as Bounds, LinearConstraint as LinearConstraint from ._optimize import OptimizeResult as OptimizeResult diff --git a/scipy-stubs/optimize/_minimize.pyi b/scipy-stubs/optimize/_minimize.pyi index 0434307c..5d5712b9 100644 --- a/scipy-stubs/optimize/_minimize.pyi +++ b/scipy-stubs/optimize/_minimize.pyi @@ -1,21 +1,6 @@ from scipy._typing import Untyped -from ._constraints import ( - Bounds as Bounds, - LinearConstraint as LinearConstraint, - NonlinearConstraint as NonlinearConstraint, - PreparedConstraint as PreparedConstraint, - new_bounds_to_old as new_bounds_to_old, - new_constraint_to_old as new_constraint_to_old, - old_bound_to_new as old_bound_to_new, - old_constraint_to_new as old_constraint_to_new, -) -from ._differentiable_functions import FD_METHODS as FD_METHODS -from ._optimize import MemoizeJac as MemoizeJac, OptimizeResult as OptimizeResult - -MINIMIZE_METHODS: Untyped -MINIMIZE_METHODS_NEW_CB: Untyped -MINIMIZE_SCALAR_METHODS: Untyped +__all__ = ["minimize", "minimize_scalar"] def minimize( fun, diff --git a/scipy-stubs/optimize/_minpack_py.pyi b/scipy-stubs/optimize/_minpack_py.pyi index ea81da92..b6dbb557 100644 --- a/scipy-stubs/optimize/_minpack_py.pyi +++ b/scipy-stubs/optimize/_minpack_py.pyi @@ -1,11 +1,6 @@ from scipy._typing import Untyped -from scipy import linalg as linalg -from scipy.linalg import LinAlgError as LinAlgError, cholesky as cholesky, solve_triangular as solve_triangular, svd as svd -from scipy.optimize._minimize import Bounds as Bounds -from ._lsq import least_squares as least_squares -from ._lsq.least_squares import prepare_bounds as prepare_bounds -from ._optimize import OptimizeResult as OptimizeResult, OptimizeWarning as OptimizeWarning +__all__ = ["curve_fit", "fixed_point", "fsolve", "leastsq"] def fsolve( func, @@ -21,10 +16,6 @@ def fsolve( factor: int = 100, diag: Untyped | None = None, ) -> Untyped: ... - -LEASTSQ_SUCCESS: Untyped -LEASTSQ_FAILURE: Untyped - def leastsq( func, x0, diff --git a/scipy-stubs/optimize/_nonlin.pyi b/scipy-stubs/optimize/_nonlin.pyi index 25861b2e..1473a39c 100644 --- a/scipy-stubs/optimize/_nonlin.pyi +++ b/scipy-stubs/optimize/_nonlin.pyi @@ -1,16 +1,20 @@ +from typing_extensions import override + from scipy._typing import Untyped -from scipy._lib._util import copy_if_needed as copy_if_needed -from scipy.linalg import ( - LinAlgError as LinAlgError, - get_blas_funcs as get_blas_funcs, - inv as inv, - norm as norm, - qr as qr, - solve as solve, - svd as svd, -) -from ._linesearch import scalar_search_armijo as scalar_search_armijo, scalar_search_wolfe1 as scalar_search_wolfe1 +__all__ = [ + "BroydenFirst", + "InverseJacobian", + "KrylovJacobian", + "NoConvergence", + "anderson", + "broyden1", + "broyden2", + "diagbroyden", + "excitingmixing", + "linearmixing", + "newton_krylov", +] class NoConvergence(Exception): ... @@ -50,18 +54,20 @@ class TerminationCondition: x_rtol: Untyped | None = None, iter: Untyped | None = None, norm=..., - ): ... + ) -> None: ... def check(self, f, x, dx) -> Untyped: ... class Jacobian: + func: Untyped + @property + def shape(self) -> Untyped: ... + @property + def dtype(self) -> Untyped: ... def __init__(self, **kw) -> None: ... def aspreconditioner(self) -> Untyped: ... - def solve(self, v, tol: int = 0): ... - def update(self, x, F): ... - func: Untyped - shape: Untyped - dtype: Untyped - def setup(self, x, F, func): ... + def solve(self, v, /, tol: float = 0) -> Untyped: ... + def update(self, x, F) -> None: ... + def setup(self, x, F, func) -> None: ... class InverseJacobian: jacobian: Untyped @@ -81,8 +87,6 @@ class GenericBroyden(Jacobian): last_f: Untyped last_x: Untyped alpha: Untyped - def setup(self, x0, f0, func): ... - def update(self, x, f): ... class LowRankMatrix: alpha: Untyped @@ -94,8 +98,8 @@ class LowRankMatrix: def __init__(self, alpha, n, dtype) -> None: ... def matvec(self, v) -> Untyped: ... def rmatvec(self, v) -> Untyped: ... - def solve(self, v, tol: int = 0) -> Untyped: ... - def rsolve(self, v, tol: int = 0) -> Untyped: ... + def solve(self, v, tol: float = 0) -> Untyped: ... + def rsolve(self, v, tol: float = 0) -> Untyped: ... def append(self, c, d): ... def __array__(self, dtype: Untyped | None = None, copy: Untyped | None = None) -> Untyped: ... def collapse(self): ... @@ -108,11 +112,11 @@ class BroydenFirst(GenericBroyden): Gm: Untyped max_rank: Untyped def __init__(self, alpha: Untyped | None = None, reduction_method: str = "restart", max_rank: Untyped | None = None): ... - def setup(self, x, F, func): ... def todense(self) -> Untyped: ... - def solve(self, f, tol: int = 0) -> Untyped: ... + @override + def solve(self, f, /, tol: float = 0) -> Untyped: ... def matvec(self, f) -> Untyped: ... - def rsolve(self, f, tol: int = 0) -> Untyped: ... + def rsolve(self, f, tol: float = 0) -> Untyped: ... def rmatvec(self, f) -> Untyped: ... class BroydenSecond(BroydenFirst): ... @@ -125,26 +129,28 @@ class Anderson(GenericBroyden): gamma: Untyped w0: Untyped def __init__(self, alpha: Untyped | None = None, w0: float = 0.01, M: int = 5): ... - def solve(self, f, tol: int = 0) -> Untyped: ... + @override + def solve(self, f, tol: float = 0) -> Untyped: ... def matvec(self, f) -> Untyped: ... class DiagBroyden(GenericBroyden): alpha: Untyped - def __init__(self, alpha: Untyped | None = None): ... d: Untyped - def setup(self, x, F, func): ... - def solve(self, f, tol: int = 0) -> Untyped: ... + def __init__(self, alpha: Untyped | None = None) -> None: ... + @override + def solve(self, f, /, tol: float = 0) -> Untyped: ... def matvec(self, f) -> Untyped: ... - def rsolve(self, f, tol: int = 0) -> Untyped: ... + def rsolve(self, f, tol: float = 0) -> Untyped: ... def rmatvec(self, f) -> Untyped: ... def todense(self) -> Untyped: ... class LinearMixing(GenericBroyden): alpha: Untyped - def __init__(self, alpha: Untyped | None = None): ... - def solve(self, f, tol: int = 0) -> Untyped: ... + def __init__(self, alpha: Untyped | None = None) -> None: ... + @override + def solve(self, f, /, tol: float = 0) -> Untyped: ... def matvec(self, f) -> Untyped: ... - def rsolve(self, f, tol: int = 0) -> Untyped: ... + def rsolve(self, f, tol: float = 0) -> Untyped: ... def rmatvec(self, f) -> Untyped: ... def todense(self) -> Untyped: ... @@ -152,11 +158,11 @@ class ExcitingMixing(GenericBroyden): alpha: Untyped alphamax: Untyped beta: Untyped - def __init__(self, alpha: Untyped | None = None, alphamax: float = 1.0): ... - def setup(self, x, F, func): ... - def solve(self, f, tol: int = 0) -> Untyped: ... + def __init__(self, alpha: Untyped | None = None, alphamax: float = 1.0) -> None: ... + @override + def solve(self, f, /, tol: float = 0) -> Untyped: ... def matvec(self, f) -> Untyped: ... - def rsolve(self, f, tol: int = 0) -> Untyped: ... + def rsolve(self, f, tol: float = 0) -> Untyped: ... def rmatvec(self, f) -> Untyped: ... def todense(self) -> Untyped: ... @@ -165,6 +171,9 @@ class KrylovJacobian(Jacobian): rdiff: Untyped method: Untyped method_kw: Untyped + x0: Untyped + f0: Untyped + op: Untyped def __init__( self, rdiff: Untyped | None = None, @@ -173,14 +182,10 @@ class KrylovJacobian(Jacobian): inner_M: Untyped | None = None, outer_k: int = 10, **kw, - ): ... + ) -> None: ... def matvec(self, v) -> Untyped: ... - def solve(self, rhs, tol: int = 0) -> Untyped: ... - x0: Untyped - f0: Untyped - def update(self, x, f): ... - op: Untyped - def setup(self, x, f, func): ... + @override + def solve(self, rhs, /, tol: float = 0) -> Untyped: ... broyden1: Untyped broyden2: Untyped diff --git a/scipy-stubs/optimize/_numdiff.pyi b/scipy-stubs/optimize/_numdiff.pyi index f033a904..7d5ce02f 100644 --- a/scipy-stubs/optimize/_numdiff.pyi +++ b/scipy-stubs/optimize/_numdiff.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._group_columns import group_dense as group_dense, group_sparse as group_sparse def group_columns(A, order: int = 0) -> Untyped: ... diff --git a/scipy-stubs/optimize/_optimize.pyi b/scipy-stubs/optimize/_optimize.pyi index 667151f6..15b0ecee 100644 --- a/scipy-stubs/optimize/_optimize.pyi +++ b/scipy-stubs/optimize/_optimize.pyi @@ -1,17 +1,29 @@ +from scipy._lib._util import MapWrapper, _RichResult from scipy._typing import Untyped +from ._linesearch import line_search_wolfe2 as line_search -from scipy._lib._util import MapWrapper as MapWrapper, _RichResult, check_random_state as check_random_state -from scipy.linalg import LinAlgError as LinAlgError, cholesky as cholesky, issymmetric as issymmetric -from scipy.optimize._differentiable_functions import FD_METHODS as FD_METHODS, ScalarFunction as ScalarFunction -from scipy.sparse.linalg import LinearOperator as LinearOperator -from ._linesearch import ( - LineSearchWarning as LineSearchWarning, - line_search_wolfe1 as line_search_wolfe1, - line_search_wolfe2 as line_search_wolfe2, -) -from ._numdiff import approx_derivative as approx_derivative - -__docformat__: str +__all__ = [ + "OptimizeResult", + "OptimizeWarning", + "approx_fprime", + "bracket", + "brent", + "brute", + "check_grad", + "fmin", + "fmin_bfgs", + "fmin_cg", + "fmin_ncg", + "fmin_powell", + "fminbound", + "golden", + "line_search", + "rosen", + "rosen_der", + "rosen_hess", + "rosen_hess_prod", + "show_options", +] class MemoizeJac: fun: Untyped diff --git a/scipy-stubs/optimize/_qap.pyi b/scipy-stubs/optimize/_qap.pyi index 5a905430..4932059c 100644 --- a/scipy-stubs/optimize/_qap.pyi +++ b/scipy-stubs/optimize/_qap.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import check_random_state as check_random_state +from scipy._typing import Untyped from . import OptimizeResult as OptimizeResult, linear_sum_assignment as linear_sum_assignment QUADRATIC_ASSIGNMENT_METHODS: Untyped diff --git a/scipy-stubs/optimize/_remove_redundancy.pyi b/scipy-stubs/optimize/_remove_redundancy.pyi index e97dd307..19cf0599 100644 --- a/scipy-stubs/optimize/_remove_redundancy.pyi +++ b/scipy-stubs/optimize/_remove_redundancy.pyi @@ -1,7 +1,5 @@ from scipy._typing import Untyped -from scipy.linalg import svd as svd -from scipy.linalg.blas import dtrsm as dtrsm -from scipy.linalg.interpolative import interp_decomp as interp_decomp +__all__ = ["bg_update_dense"] -def bg_update_dense(plu, perm_r, v, j) -> Untyped: ... +def bg_update_dense(plu: Untyped, perm_r: Untyped, v: Untyped, j: Untyped) -> Untyped: ... diff --git a/scipy-stubs/optimize/_root.pyi b/scipy-stubs/optimize/_root.pyi index 55d6a613..7f1f6fe2 100644 --- a/scipy-stubs/optimize/_root.pyi +++ b/scipy-stubs/optimize/_root.pyi @@ -1,9 +1,7 @@ from scipy._typing import Untyped +from ._optimize import OptimizeResult -from ._minpack_py import leastsq as leastsq -from ._optimize import MemoizeJac as MemoizeJac, OptimizeResult as OptimizeResult - -ROOT_METHODS: Untyped +__all__ = ["root"] def root( fun, @@ -14,4 +12,4 @@ def root( tol: Untyped | None = None, callback: Untyped | None = None, options: Untyped | None = None, -) -> Untyped: ... +) -> OptimizeResult: ... diff --git a/scipy-stubs/optimize/_root_scalar.pyi b/scipy-stubs/optimize/_root_scalar.pyi index 918f901e..03eb148d 100644 --- a/scipy-stubs/optimize/_root_scalar.pyi +++ b/scipy-stubs/optimize/_root_scalar.pyi @@ -1,6 +1,6 @@ from scipy._typing import Untyped -from ._numdiff import approx_derivative as approx_derivative +__all__ = ["root_scalar"] ROOT_SCALAR_METHODS: Untyped diff --git a/scipy-stubs/optimize/_shgo.pyi b/scipy-stubs/optimize/_shgo.pyi index 63b2c52d..d1fd47aa 100644 --- a/scipy-stubs/optimize/_shgo.pyi +++ b/scipy-stubs/optimize/_shgo.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy import spatial as spatial +from scipy._typing import Untyped from scipy.optimize import Bounds as Bounds, OptimizeResult as OptimizeResult, minimize as minimize from scipy.optimize._constraints import new_bounds_to_old as new_bounds_to_old from scipy.optimize._minimize import standardize_constraints as standardize_constraints diff --git a/scipy-stubs/optimize/_shgo_lib/_complex.pyi b/scipy-stubs/optimize/_shgo_lib/_complex.pyi index baedeb44..225a663c 100644 --- a/scipy-stubs/optimize/_shgo_lib/_complex.pyi +++ b/scipy-stubs/optimize/_shgo_lib/_complex.pyi @@ -1,7 +1,6 @@ from collections.abc import Generator from scipy._typing import Untyped - from ._vertex import VertexCacheField as VertexCacheField, VertexCacheIndex as VertexCacheIndex class Complex: diff --git a/scipy-stubs/optimize/_shgo_lib/_vertex.pyi b/scipy-stubs/optimize/_shgo_lib/_vertex.pyi index b7a540b8..5da68ba2 100644 --- a/scipy-stubs/optimize/_shgo_lib/_vertex.pyi +++ b/scipy-stubs/optimize/_shgo_lib/_vertex.pyi @@ -1,21 +1,20 @@ -from abc import ABC, abstractmethod - -from scipy._typing import Untyped +import abc +from typing_extensions import override from scipy._lib._util import MapWrapper as MapWrapper +from scipy._typing import Untyped -class VertexBase(ABC): +class VertexBase(abc.ABC): x: Untyped hash: Untyped nn: Untyped index: Untyped def __init__(self, x, nn: Untyped | None = None, index: Untyped | None = None): ... - def __hash__(self) -> Untyped: ... x_a: Untyped def __getattr__(self, item) -> Untyped: ... - @abstractmethod + @abc.abstractmethod def connect(self, v) -> Untyped: ... - @abstractmethod + @abc.abstractmethod def disconnect(self, v) -> Untyped: ... st: Untyped def star(self) -> Untyped: ... @@ -33,12 +32,14 @@ class VertexScalarField(VertexBase): g_cons: Untyped | None = None, g_cons_args=(), ): ... - def connect(self, v): ... - def disconnect(self, v): ... + @override + def connect(self, v) -> Untyped: ... + @override + def disconnect(self, v) -> Untyped: ... def minimiser(self) -> Untyped: ... def maximiser(self) -> Untyped: ... -class VertexVectorField(VertexBase): +class VertexVectorField(VertexBase, metaclass=abc.ABCMeta): def __init__( self, x, @@ -63,8 +64,10 @@ class VertexCacheBase: class VertexCube(VertexBase): def __init__(self, x, nn: Untyped | None = None, index: Untyped | None = None): ... - def connect(self, v): ... - def disconnect(self, v): ... + @override + def connect(self, v) -> Untyped: ... + @override + def disconnect(self, v) -> Untyped: ... class VertexCacheIndex(VertexCacheBase): Vertex: Untyped diff --git a/scipy-stubs/optimize/_tnc.pyi b/scipy-stubs/optimize/_tnc.pyi index 3dfab7c3..017afe09 100644 --- a/scipy-stubs/optimize/_tnc.pyi +++ b/scipy-stubs/optimize/_tnc.pyi @@ -1,8 +1,6 @@ from scipy._typing import Untyped -from scipy._lib._array_api import array_namespace as array_namespace, xp_atleast_nd as xp_atleast_nd -from ._constraints import old_bound_to_new as old_bound_to_new -from ._optimize import MemoizeJac as MemoizeJac, OptimizeResult as OptimizeResult +__all__ = ["fmin_tnc"] MSG_NONE: int MSG_ITER: int diff --git a/scipy-stubs/optimize/_trlib/__init__.pyi b/scipy-stubs/optimize/_trlib/__init__.pyi index 6adb176d..b7082c8d 100644 --- a/scipy-stubs/optimize/_trlib/__init__.pyi +++ b/scipy-stubs/optimize/_trlib/__init__.pyi @@ -1,5 +1,6 @@ from scipy._typing import Untyped +from ._trlib import TRLIBQuadraticSubproblem -from ._trlib import TRLIBQuadraticSubproblem as TRLIBQuadraticSubproblem +__all__ = ["TRLIBQuadraticSubproblem", "get_trlib_quadratic_subproblem"] def get_trlib_quadratic_subproblem(tol_rel_i: float = -2.0, tol_rel_b: float = -3.0, disp: bool = False) -> Untyped: ... diff --git a/scipy-stubs/optimize/_trlib/_trlib.pyi b/scipy-stubs/optimize/_trlib/_trlib.pyi new file mode 100644 index 00000000..666f9a0c --- /dev/null +++ b/scipy-stubs/optimize/_trlib/_trlib.pyi @@ -0,0 +1,24 @@ +from typing_extensions import override + +import numpy as np +import numpy.typing as npt +from scipy._typing import UntypedCallable +from scipy.optimize._trustregion import BaseQuadraticSubproblem + +__all__ = ["TRLIBQuadraticSubproblem"] + +class TRLIBQuadraticSubproblem(BaseQuadraticSubproblem): + def __init__( + self, + /, + x, + fun: UntypedCallable, + jac: UntypedCallable, + hess: UntypedCallable | None, + hessp: UntypedCallable | None, + tol_rel_i: float = -2.0, + tol_rel_b: float = -3.0, + disp: bool = False, + ) -> None: ... + @override + def solve(self, trust_radius: float | np.float64) -> tuple[npt.NDArray[np.float64], bool]: ... diff --git a/scipy-stubs/optimize/_trustregion.pyi b/scipy-stubs/optimize/_trustregion.pyi index b26a0106..5e6351a4 100644 --- a/scipy-stubs/optimize/_trustregion.pyi +++ b/scipy-stubs/optimize/_trustregion.pyi @@ -1,8 +1,11 @@ -from scipy._typing import Untyped +import abc +import numpy as np +from scipy._typing import Untyped from scipy.optimize._differentiable_functions import FD_METHODS as FD_METHODS from scipy.optimize._hessian_update_strategy import HessianUpdateStrategy as HessianUpdateStrategy -from ._optimize import OptimizeResult as OptimizeResult + +__all__: list[str] = [] class BaseQuadraticSubproblem: def __init__(self, x, fun, jac, hess: Untyped | None = None, hessp: Untyped | None = None): ... @@ -17,4 +20,5 @@ class BaseQuadraticSubproblem: @property def jac_mag(self) -> Untyped: ... def get_boundaries_intersections(self, z, d, trust_radius) -> Untyped: ... - def solve(self, trust_radius): ... + @abc.abstractmethod + def solve(self, trust_radius: float | np.float64) -> Untyped: ... diff --git a/scipy-stubs/optimize/_trustregion_constr/equality_constrained_sqp.pyi b/scipy-stubs/optimize/_trustregion_constr/equality_constrained_sqp.pyi index 80bb0df2..fe490b25 100644 --- a/scipy-stubs/optimize/_trustregion_constr/equality_constrained_sqp.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/equality_constrained_sqp.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from .projections import projections as projections from .qp_subproblem import ( box_intersections as box_intersections, diff --git a/scipy-stubs/optimize/_trustregion_constr/minimize_trustregion_constr.pyi b/scipy-stubs/optimize/_trustregion_constr/minimize_trustregion_constr.pyi index 90309794..b13866da 100644 --- a/scipy-stubs/optimize/_trustregion_constr/minimize_trustregion_constr.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/minimize_trustregion_constr.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.optimize._constraints import ( Bounds as Bounds, LinearConstraint as LinearConstraint, diff --git a/scipy-stubs/optimize/_trustregion_constr/projections.pyi b/scipy-stubs/optimize/_trustregion_constr/projections.pyi index 10fd32c9..de8788d0 100644 --- a/scipy-stubs/optimize/_trustregion_constr/projections.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/projections.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse import bmat as bmat, csc_matrix as csc_matrix, eye as eye, issparse as issparse from scipy.sparse.linalg import LinearOperator as LinearOperator diff --git a/scipy-stubs/optimize/_trustregion_constr/qp_subproblem.pyi b/scipy-stubs/optimize/_trustregion_constr/qp_subproblem.pyi index bee75935..0b7fd5f6 100644 --- a/scipy-stubs/optimize/_trustregion_constr/qp_subproblem.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/qp_subproblem.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse import bmat as bmat, csc_matrix as csc_matrix, linalg as linalg def eqp_kktfact(H, c, A, b) -> Untyped: ... diff --git a/scipy-stubs/optimize/_trustregion_constr/report.pyi b/scipy-stubs/optimize/_trustregion_constr/report.pyi index 3ec31c00..750e564b 100644 --- a/scipy-stubs/optimize/_trustregion_constr/report.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/report.pyi @@ -1,27 +1,14 @@ -from scipy._typing import Untyped - class ReportBase: COLUMN_NAMES: list[str] COLUMN_WIDTHS: list[int] ITERATION_FORMATS: list[str] @classmethod - def print_header(cls): ... + def print_header(cls) -> None: ... @classmethod - def print_iteration(cls, *args): ... + def print_iteration(cls, *args) -> None: ... @classmethod - def print_footer(cls): ... - -class BasicReport(ReportBase): - COLUMN_NAMES: Untyped - COLUMN_WIDTHS: Untyped - ITERATION_FORMATS: Untyped - -class SQPReport(ReportBase): - COLUMN_NAMES: Untyped - COLUMN_WIDTHS: Untyped - ITERATION_FORMATS: Untyped + def print_footer(cls) -> None: ... -class IPReport(ReportBase): - COLUMN_NAMES: Untyped - COLUMN_WIDTHS: Untyped - ITERATION_FORMATS: Untyped +class BasicReport(ReportBase): ... +class SQPReport(ReportBase): ... +class IPReport(ReportBase): ... diff --git a/scipy-stubs/optimize/_trustregion_constr/tr_interior_point.pyi b/scipy-stubs/optimize/_trustregion_constr/tr_interior_point.pyi index ed8be678..f449e4e5 100644 --- a/scipy-stubs/optimize/_trustregion_constr/tr_interior_point.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/tr_interior_point.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse.linalg import LinearOperator as LinearOperator from .equality_constrained_sqp import equality_constrained_sqp as equality_constrained_sqp diff --git a/scipy-stubs/optimize/_trustregion_dogleg.pyi b/scipy-stubs/optimize/_trustregion_dogleg.pyi index 47133ebc..4a3c2dbf 100644 --- a/scipy-stubs/optimize/_trustregion_dogleg.pyi +++ b/scipy-stubs/optimize/_trustregion_dogleg.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._trustregion import BaseQuadraticSubproblem as BaseQuadraticSubproblem class DoglegSubproblem(BaseQuadraticSubproblem): diff --git a/scipy-stubs/optimize/_trustregion_exact.pyi b/scipy-stubs/optimize/_trustregion_exact.pyi index 6fab7836..464a303f 100644 --- a/scipy-stubs/optimize/_trustregion_exact.pyi +++ b/scipy-stubs/optimize/_trustregion_exact.pyi @@ -1,12 +1,9 @@ -from scipy._typing import Untyped +from typing_extensions import override -from scipy.linalg import ( - cho_solve as cho_solve, - get_lapack_funcs as get_lapack_funcs, - norm as norm, - solve_triangular as solve_triangular, -) -from ._trustregion import BaseQuadraticSubproblem as BaseQuadraticSubproblem +import numpy as np +import numpy.typing as npt +from scipy._typing import Untyped +from ._trustregion import BaseQuadraticSubproblem def estimate_smallest_singular_value(U) -> Untyped: ... def gershgorin_bounds(H) -> Untyped: ... @@ -24,6 +21,7 @@ class IterativeSubproblem(BaseQuadraticSubproblem): hess_inf: Untyped hess_fro: Untyped CLOSE_TO_ZERO: Untyped - def __init__(self, x, fun, jac, hess, hessp: Untyped | None = None, k_easy: float = 0.1, k_hard: float = 0.2): ... + def __init__(self, x, fun, jac, hess, hessp: Untyped | None = None, k_easy: float = 0.1, k_hard: float = 0.2) -> None: ... lambda_current: Untyped - def solve(self, tr_radius) -> Untyped: ... + @override + def solve(self, trust_radius: float | np.float64) -> tuple[npt.NDArray[np.float64], bool]: ... diff --git a/scipy-stubs/optimize/_trustregion_ncg.pyi b/scipy-stubs/optimize/_trustregion_ncg.pyi index 68110119..15085fb3 100644 --- a/scipy-stubs/optimize/_trustregion_ncg.pyi +++ b/scipy-stubs/optimize/_trustregion_ncg.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._trustregion import BaseQuadraticSubproblem as BaseQuadraticSubproblem class CGSteihaugSubproblem(BaseQuadraticSubproblem): diff --git a/scipy-stubs/optimize/_tstutils.pyi b/scipy-stubs/optimize/_tstutils.pyi index 4aad9801..984e5404 100644 --- a/scipy-stubs/optimize/_tstutils.pyi +++ b/scipy-stubs/optimize/_tstutils.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._array_api import array_namespace as array_namespace +from scipy._typing import Untyped description: str diff --git a/scipy-stubs/optimize/_zeros_py.pyi b/scipy-stubs/optimize/_zeros_py.pyi index 407a0076..66dbf2da 100644 --- a/scipy-stubs/optimize/_zeros_py.pyi +++ b/scipy-stubs/optimize/_zeros_py.pyi @@ -1,13 +1,16 @@ -from scipy._typing import Untyped +from typing import Final +from scipy._typing import Untyped from ._optimize import OptimizeResult as OptimizeResult -CONVERGED: str -SIGNERR: str -CONVERR: str -VALUEERR: str -INPROGRESS: str -flag_map: Untyped +__all__ = ["RootResults", "bisect", "brenth", "brentq", "newton", "ridder", "toms748"] + +CONVERGED: Final = "converged" +SIGNERR: Final = "sign error" +CONVERR: Final = "convergence error" +VALUEERR: Final = "value error" +INPROGRESS: Final = "No error" +flag_map: Final[dict[int, str]] class RootResults(OptimizeResult): root: Untyped @@ -62,5 +65,14 @@ class TOMS748Solver: def solve(self, f, a, b, args=(), xtol=..., rtol=..., k: int = 2, maxiter=..., disp: bool = True) -> Untyped: ... def toms748( - f, a, b, args=(), k: int = 1, xtol=..., rtol=..., maxiter=..., full_output: bool = False, disp: bool = True + f, + a, + b, + args=(), + k: int = 1, + xtol=..., + rtol=..., + maxiter=..., + full_output: bool = False, + disp: bool = True, ) -> Untyped: ... diff --git a/scipy-stubs/signal/_czt.pyi b/scipy-stubs/signal/_czt.pyi index 3a9bcacf..2f2a6d29 100644 --- a/scipy-stubs/signal/_czt.pyi +++ b/scipy-stubs/signal/_czt.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.fft import fft as fft, ifft as ifft, next_fast_len as next_fast_len def czt_points(m, w: Untyped | None = None, a: complex = ...) -> Untyped: ... diff --git a/scipy-stubs/signal/_filter_design.pyi b/scipy-stubs/signal/_filter_design.pyi index bfb4d70d..7f623a61 100644 --- a/scipy-stubs/signal/_filter_design.pyi +++ b/scipy-stubs/signal/_filter_design.pyi @@ -1,8 +1,6 @@ import numpy as np - -from scipy._typing import Untyped - from scipy._lib._util import float_factorial as float_factorial +from scipy._typing import Untyped from scipy.special import comb as comb class BadCoefficients(UserWarning): ... diff --git a/scipy-stubs/signal/_fir_filter_design.pyi b/scipy-stubs/signal/_fir_filter_design.pyi index 3d700380..2aad0e70 100644 --- a/scipy-stubs/signal/_fir_filter_design.pyi +++ b/scipy-stubs/signal/_fir_filter_design.pyi @@ -1,9 +1,7 @@ from typing import Literal import numpy as np - -from scipy._typing import Untyped - +from scipy._typing import Untyped, UntypedArray from scipy.linalg import ( LinAlgError as LinAlgError, LinAlgWarning as LinAlgWarning, @@ -50,5 +48,9 @@ def remez( ) -> Untyped: ... def firls(numtaps, bands, desired, *, weight: Untyped | None = None, fs: Untyped | None = None) -> Untyped: ... def minimum_phase( - h: np.ndarray, method: Literal["homomorphic", "hilbert"] = "homomorphic", n_fft: int | None = None, *, half: bool = True -) -> np.ndarray: ... + h: UntypedArray, + method: Literal["homomorphic", "hilbert"] = "homomorphic", + n_fft: int | None = None, + *, + half: bool = True, +) -> UntypedArray: ... diff --git a/scipy-stubs/signal/_lti_conversion.pyi b/scipy-stubs/signal/_lti_conversion.pyi index 2c198dd4..ec85dacf 100644 --- a/scipy-stubs/signal/_lti_conversion.pyi +++ b/scipy-stubs/signal/_lti_conversion.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy import linalg as linalg +from scipy._typing import Untyped from ._filter_design import normalize as normalize, tf2zpk as tf2zpk, zpk2tf as zpk2tf def tf2ss(num, den) -> Untyped: ... diff --git a/scipy-stubs/signal/_ltisys.pyi b/scipy-stubs/signal/_ltisys.pyi index c65fb9c6..d5bc3498 100644 --- a/scipy-stubs/signal/_ltisys.pyi +++ b/scipy-stubs/signal/_ltisys.pyi @@ -1,27 +1,28 @@ +from typing_extensions import Self, override + from scipy._typing import Untyped -from scipy import linalg as linalg -from scipy.interpolate import make_interp_spline as make_interp_spline -from ._filter_design import ( - freqs as freqs, - freqs_zpk as freqs_zpk, - freqz as freqz, - freqz_zpk as freqz_zpk, - normalize as normalize, - tf2zpk as tf2zpk, - zpk2tf as zpk2tf, -) -from ._lti_conversion import ( - abcd_normalize as abcd_normalize, - cont2discrete as cont2discrete, - ss2tf as ss2tf, - ss2zpk as ss2zpk, - tf2ss as tf2ss, - zpk2ss as zpk2ss, -) +__all__ = [ + "StateSpace", + "TransferFunction", + "ZerosPolesGain", + "bode", + "dbode", + "dfreqresp", + "dimpulse", + "dlsim", + "dlti", + "dstep", + "freqresp", + "impulse", + "lsim", + "lti", + "place_poles", + "step", +] class LinearTimeInvariant: - def __new__(cls, *system, **kwargs) -> Untyped: ... + def __new__(cls, *system, **kwargs) -> Self: ... inputs: Untyped outputs: Untyped def __init__(self) -> None: ... @@ -33,17 +34,17 @@ class LinearTimeInvariant: def poles(self) -> Untyped: ... class lti(LinearTimeInvariant): - def __new__(cls, *system) -> Untyped: ... + def __new__(cls, *system) -> Self: ... def __init__(self, *system) -> None: ... def impulse(self, X0: Untyped | None = None, T: Untyped | None = None, N: Untyped | None = None) -> Untyped: ... def step(self, X0: Untyped | None = None, T: Untyped | None = None, N: Untyped | None = None) -> Untyped: ... def output(self, U, T, X0: Untyped | None = None) -> Untyped: ... def bode(self, w: Untyped | None = None, n: int = 100) -> Untyped: ... def freqresp(self, w: Untyped | None = None, n: int = 10000) -> Untyped: ... - def to_discrete(self, dt, method: str = "zoh", alpha: Untyped | None = None): ... + def to_discrete(self, dt, method: str = "zoh", alpha: Untyped | None = None) -> Untyped: ... class dlti(LinearTimeInvariant): - def __new__(cls, *system, **kwargs) -> Untyped: ... + def __new__(cls, *system, **kwargs) -> Self: ... def __init__(self, *system, **kwargs) -> None: ... @property def dt(self) -> Untyped: ... @@ -56,14 +57,14 @@ class dlti(LinearTimeInvariant): def freqresp(self, w: Untyped | None = None, n: int = 10000, whole: bool = False) -> Untyped: ... class TransferFunction(LinearTimeInvariant): - def __new__(cls, *system, **kwargs) -> Untyped: ... + def __new__(cls, *system, **kwargs) -> Self: ... def __init__(self, *system, **kwargs) -> None: ... @property def num(self) -> Untyped: ... - outputs: int - inputs: int @num.setter def num(self, num): ... + outputs: int + inputs: int @property def den(self) -> Untyped: ... @den.setter @@ -73,17 +74,18 @@ class TransferFunction(LinearTimeInvariant): def to_ss(self) -> Untyped: ... class TransferFunctionContinuous(TransferFunction, lti): + @override def to_discrete(self, dt, method: str = "zoh", alpha: Untyped | None = None) -> Untyped: ... class TransferFunctionDiscrete(TransferFunction, dlti): ... class ZerosPolesGain(LinearTimeInvariant): - def __new__(cls, *system, **kwargs) -> Untyped: ... + inputs: int + outputs: int + def __new__(cls, *system, **kwargs) -> Self: ... def __init__(self, *system, **kwargs) -> None: ... @property def zeros(self) -> Untyped: ... - outputs: int - inputs: int @zeros.setter def zeros(self, zeros): ... @property @@ -106,7 +108,9 @@ class ZerosPolesGainDiscrete(ZerosPolesGain, dlti): ... class StateSpace(LinearTimeInvariant): __array_priority__: float __array_ufunc__: Untyped - def __new__(cls, *system, **kwargs) -> Untyped: ... + inputs: Untyped + outputs: Untyped + def __new__(cls, *system, **kwargs) -> Self: ... def __init__(self, *system, **kwargs) -> None: ... def __mul__(self, other) -> Untyped: ... def __rmul__(self, other) -> Untyped: ... @@ -122,12 +126,10 @@ class StateSpace(LinearTimeInvariant): def A(self, A): ... @property def B(self) -> Untyped: ... - inputs: Untyped @B.setter def B(self, B): ... @property def C(self) -> Untyped: ... - outputs: Untyped @C.setter def C(self, C): ... @property diff --git a/scipy-stubs/signal/_peak_finding.pyi b/scipy-stubs/signal/_peak_finding.pyi index f44fef14..81b7192c 100644 --- a/scipy-stubs/signal/_peak_finding.pyi +++ b/scipy-stubs/signal/_peak_finding.pyi @@ -1,16 +1,20 @@ from scipy._typing import Untyped -from scipy.stats import scoreatpercentile as scoreatpercentile +__all__ = ["argrelextrema", "argrelmax", "argrelmin", "find_peaks", "find_peaks_cwt", "peak_prominences", "peak_widths"] -def argrelmin(data, axis: int = 0, order: int = 1, mode: str = "clip") -> Untyped: ... -def argrelmax(data, axis: int = 0, order: int = 1, mode: str = "clip") -> Untyped: ... -def argrelextrema(data, comparator, axis: int = 0, order: int = 1, mode: str = "clip") -> Untyped: ... -def peak_prominences(x, peaks, wlen: Untyped | None = None) -> Untyped: ... +def argrelmin(data: Untyped, axis: int = 0, order: int = 1, mode: str = "clip") -> Untyped: ... +def argrelmax(data: Untyped, axis: int = 0, order: int = 1, mode: str = "clip") -> Untyped: ... +def argrelextrema(data: Untyped, comparator: Untyped, axis: int = 0, order: int = 1, mode: str = "clip") -> Untyped: ... +def peak_prominences(x: Untyped, peaks: Untyped, wlen: Untyped | None = None) -> Untyped: ... def peak_widths( - x, peaks, rel_height: float = 0.5, prominence_data: Untyped | None = None, wlen: Untyped | None = None + x: Untyped, + peaks: Untyped, + rel_height: float = 0.5, + prominence_data: Untyped | None = None, + wlen: Untyped | None = None, ) -> Untyped: ... def find_peaks( - x, + x: Untyped, height: Untyped | None = None, threshold: Untyped | None = None, distance: Untyped | None = None, @@ -21,8 +25,8 @@ def find_peaks( plateau_size: Untyped | None = None, ) -> Untyped: ... def find_peaks_cwt( - vector, - widths, + vector: Untyped, + widths: Untyped, wavelet: Untyped | None = None, max_distances: Untyped | None = None, gap_thresh: Untyped | None = None, diff --git a/scipy-stubs/signal/_savitzky_golay.pyi b/scipy-stubs/signal/_savitzky_golay.pyi index 98fa3098..b4584780 100644 --- a/scipy-stubs/signal/_savitzky_golay.pyi +++ b/scipy-stubs/signal/_savitzky_golay.pyi @@ -1,13 +1,20 @@ from scipy._typing import Untyped -from scipy._lib._util import float_factorial as float_factorial -from scipy.linalg import lstsq as lstsq -from scipy.ndimage import convolve1d as convolve1d -from ._arraytools import axis_slice as axis_slice - def savgol_coeffs( - window_length, polyorder, deriv: int = 0, delta: float = 1.0, pos: Untyped | None = None, use: str = "conv" + window_length, + polyorder, + deriv: int = 0, + delta: float = 1.0, + pos: Untyped | None = None, + use: str = "conv", ) -> Untyped: ... def savgol_filter( - x, window_length, polyorder, deriv: int = 0, delta: float = 1.0, axis: int = -1, mode: str = "interp", cval: float = 0.0 + x, + window_length, + polyorder, + deriv: int = 0, + delta: float = 1.0, + axis: int = -1, + mode: str = "interp", + cval: float = 0.0, ) -> Untyped: ... diff --git a/scipy-stubs/signal/_short_time_fft.pyi b/scipy-stubs/signal/_short_time_fft.pyi index 02ff0523..384150a2 100644 --- a/scipy-stubs/signal/_short_time_fft.pyi +++ b/scipy-stubs/signal/_short_time_fft.pyi @@ -1,33 +1,34 @@ from collections.abc import Callable -from typing import Literal +from typing import Any, Literal, TypeAlias +from typing_extensions import Self import numpy as np - +import numpy.typing as npt from scipy._typing import Untyped -from scipy.signal import detrend as detrend -from scipy.signal.windows import get_window as get_window +__all__ = ["ShortTimeFFT"] -PAD_TYPE: Untyped -FFT_MODE_TYPE: Untyped +# awkward naming, but this matches the "attempts at type-aliases" in the implementation +PAD_TYPE: TypeAlias = Literal["zeros", "edge", "even", "odd"] +FFT_MODE_TYPE: TypeAlias = Literal["twosided", "centered", "onesided", "onesided2X"] class ShortTimeFFT: def __init__( self, - win: np.ndarray, + win: npt.NDArray[np.inexact[Any]], hop: int, fs: float, *, fft_mode: FFT_MODE_TYPE = "onesided", mfft: int | None = None, - dual_win: np.ndarray | None = None, + dual_win: npt.NDArray[np.inexact[Any]] | None = None, scale_to: Literal["magnitude", "psd"] | None = None, phase_shift: int | None = 0, - ): ... + ) -> None: ... @classmethod def from_dual( cls, - dual_win: np.ndarray, + dual_win: npt.NDArray[np.inexact[Any]], hop: int, fs: float, *, @@ -35,11 +36,11 @@ class ShortTimeFFT: mfft: int | None = None, scale_to: Literal["magnitude", "psd"] | None = None, phase_shift: int | None = 0, - ): ... + ) -> Self: ... @classmethod def from_window( cls, - win_param: str | tuple | float, + win_param: str | tuple[Untyped, ...] | float, fs: float, nperseg: int, noverlap: int, @@ -49,72 +50,82 @@ class ShortTimeFFT: mfft: int | None = None, scale_to: Literal["magnitude", "psd"] | None = None, phase_shift: int | None = 0, - ): ... + ) -> Self: ... @property - def win(self) -> np.ndarray: ... + def win(self) -> npt.NDArray[np.inexact[Any]]: ... @property def hop(self) -> int: ... @property def T(self) -> float: ... @T.setter - def T(self, v: float): ... + def T(self, v: float) -> None: ... @property def fs(self) -> float: ... @fs.setter - def fs(self, v: float): ... + def fs(self, v: float) -> None: ... @property def fft_mode(self) -> FFT_MODE_TYPE: ... @fft_mode.setter - def fft_mode(self, t: FFT_MODE_TYPE): ... + def fft_mode(self, t: FFT_MODE_TYPE) -> None: ... @property def mfft(self) -> int: ... @mfft.setter - def mfft(self, n_: int): ... + def mfft(self, n_: int) -> None: ... @property def scaling(self) -> Literal["magnitude", "psd"] | None: ... - def scale_to(self, scaling: Literal["magnitude", "psd"]): ... + def scale_to(self, scaling: Literal["magnitude", "psd"]) -> None: ... @property def phase_shift(self) -> int | None: ... @phase_shift.setter - def phase_shift(self, v: int | None): ... + def phase_shift(self, v: int | None) -> None: ... def stft( self, - x: np.ndarray, + x: npt.NDArray[np.inexact[Any]], p0: int | None = None, p1: int | None = None, *, k_offset: int = 0, padding: PAD_TYPE = "zeros", axis: int = -1, - ) -> np.ndarray: ... + ) -> npt.NDArray[np.inexact[Any]]: ... def stft_detrend( self, - x: np.ndarray, - detr: Callable[[np.ndarray], np.ndarray] | Literal["linear", "constant"] | None, + x: npt.NDArray[np.inexact[Any]], + detr: Callable[[npt.NDArray[np.inexact[Any]]], npt.NDArray[np.inexact[Any]]] | Literal["linear", "constant"] | None, p0: int | None = None, p1: int | None = None, *, k_offset: int = 0, padding: PAD_TYPE = "zeros", axis: int = -1, - ) -> np.ndarray: ... + ) -> npt.NDArray[np.inexact[Any]]: ... def spectrogram( self, - x: np.ndarray, - y: np.ndarray | None = None, - detr: Callable[[np.ndarray], np.ndarray] | Literal["linear", "constant"] | None = None, + x: npt.NDArray[np.inexact[Any]], + y: npt.NDArray[np.inexact[Any]] | None = None, + detr: Callable[[npt.NDArray[np.inexact[Any]]], npt.NDArray[np.inexact[Any]]] + | Literal["linear", "constant"] + | None = None, *, p0: int | None = None, p1: int | None = None, k_offset: int = 0, padding: PAD_TYPE = "zeros", axis: int = -1, - ) -> np.ndarray: ... + ) -> npt.NDArray[np.inexact[Any]]: ... @property - def dual_win(self) -> np.ndarray: ... + def dual_win(self) -> npt.NDArray[np.inexact[Any]]: ... @property def invertible(self) -> bool: ... - def istft(self, S: np.ndarray, k0: int = 0, k1: int | None = None, *, f_axis: int = -2, t_axis: int = -1) -> np.ndarray: ... + def istft( + self, + S: npt.NDArray[np.inexact[Any]], + k0: int = 0, + k1: int | None = None, + *, + f_axis: int = -2, + t_axis: int = -1, + ) -> npt.NDArray[np.inexact[Any]]: ... @property def fac_magnitude(self) -> float: ... @property @@ -136,7 +147,7 @@ class ShortTimeFFT: @property def delta_t(self) -> float: ... def p_range(self, n: int, p0: int | None = None, p1: int | None = None) -> tuple[int, int]: ... - def t(self, n: int, p0: int | None = None, p1: int | None = None, k_offset: int = 0) -> np.ndarray: ... + def t(self, n: int, p0: int | None = None, p1: int | None = None, k_offset: int = 0) -> npt.NDArray[np.inexact[Any]]: ... def nearest_k_p(self, k: int, left: bool = True) -> int: ... @property def delta_f(self) -> float: ... @@ -145,7 +156,10 @@ class ShortTimeFFT: @property def onesided_fft(self) -> bool: ... @property - def f(self) -> np.ndarray: ... + def f(self) -> npt.NDArray[np.inexact[Any]]: ... def extent( - self, n: int, axes_seq: Literal["tf", "ft"] = "tf", center_bins: bool = False + self, + n: int, + axes_seq: Literal["tf", "ft"] = "tf", + center_bins: bool = False, ) -> tuple[float, float, float, float]: ... diff --git a/scipy-stubs/signal/_signaltools.pyi b/scipy-stubs/signal/_signaltools.pyi index f63060d2..ee519406 100644 --- a/scipy-stubs/signal/_signaltools.pyi +++ b/scipy-stubs/signal/_signaltools.pyi @@ -1,25 +1,44 @@ from typing import Literal import numpy as np -from numpy._typing import ArrayLike +import numpy.typing as npt +from scipy._typing import Untyped, UntypedArray -from scipy._typing import Untyped - -from scipy import linalg as linalg, ndimage as ndimage -from scipy.spatial import cKDTree as cKDTree -from scipy.special import lambertw as lambertw -from ._arraytools import ( - axis_reverse as axis_reverse, - axis_slice as axis_slice, - const_ext as const_ext, - even_ext as even_ext, - odd_ext as odd_ext, -) -from ._filter_design import cheby1 as cheby1, zpk2sos as zpk2sos -from ._fir_filter_design import firwin as firwin -from ._ltisys import dlti as dlti -from ._upfirdn import upfirdn as upfirdn -from .windows import get_window as get_window +__all__ = [ + "choose_conv_method", + "cmplx_sort", + "convolve", + "convolve2d", + "correlate", + "correlate2d", + "correlation_lags", + "decimate", + "deconvolve", + "detrend", + "fftconvolve", + "filtfilt", + "hilbert", + "hilbert2", + "invres", + "invresz", + "lfilter", + "lfilter_zi", + "lfiltic", + "medfilt", + "medfilt2d", + "oaconvolve", + "order_filter", + "resample", + "resample_poly", + "residue", + "residuez", + "sosfilt", + "sosfilt_zi", + "sosfiltfilt", + "unique_roots", + "vectorstrength", + "wiener", +] def correlate(in1, in2, mode: str = "full", method: str = "auto") -> Untyped: ... def correlation_lags(in1_len, in2_len, mode: str = "full") -> Untyped: ... @@ -49,12 +68,12 @@ def resample_poly( ) -> Untyped: ... def vectorstrength(events, period) -> Untyped: ... def detrend( - data: np.ndarray, + data: UntypedArray, axis: int = -1, type: Literal["linear", "constant"] = "linear", - bp: ArrayLike | int = 0, + bp: npt.ArrayLike | int = 0, overwrite_data: bool = False, -) -> np.ndarray: ... +) -> UntypedArray: ... def lfilter_zi(b, a) -> Untyped: ... def sosfilt_zi(sos) -> Untyped: ... def filtfilt( diff --git a/scipy-stubs/signal/_spectral_py.pyi b/scipy-stubs/signal/_spectral_py.pyi index 3d37026a..0853d5c6 100644 --- a/scipy-stubs/signal/_spectral_py.pyi +++ b/scipy-stubs/signal/_spectral_py.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._arraytools import const_ext as const_ext, even_ext as even_ext, odd_ext as odd_ext, zero_ext as zero_ext from .windows import get_window as get_window diff --git a/scipy-stubs/signal/_spline.pyi b/scipy-stubs/signal/_spline.pyi index d4723a17..db106ee5 100644 --- a/scipy-stubs/signal/_spline.pyi +++ b/scipy-stubs/signal/_spline.pyi @@ -1,12 +1,12 @@ -import typing +from typing import TypeAlias -from scipy._typing import Untyped +import numpy as np +import numpy.typing as npt -FloatingArray: Untyped -ComplexArray: Untyped -FloatingComplexArray: typing.TypeAlias = FloatingArray | ComplexArray +_Array_f: TypeAlias = npt.NDArray[np.float32 | np.float64] +_Array_fc: TypeAlias = npt.NDArray[np.float32 | np.float64 | np.complex64 | np.complex128] -def symiirorder1_ic(signal: FloatingComplexArray, c0: float, z1: float, precision: float) -> FloatingComplexArray: ... -def symiirorder2_ic_fwd(signal: FloatingArray, r: float, omega: float, precision: float) -> FloatingArray: ... -def symiirorder2_ic_bwd(signal: FloatingArray, r: float, omega: float, precision: float) -> FloatingArray: ... -def sepfir2d(input: FloatingComplexArray, hrow: FloatingComplexArray, hcol: FloatingComplexArray) -> FloatingComplexArray: ... +def symiirorder1_ic(signal: _Array_fc, c0: float, z1: float, precision: float) -> _Array_fc: ... +def symiirorder2_ic_fwd(signal: _Array_f, r: float, omega: float, precision: float) -> _Array_f: ... +def symiirorder2_ic_bwd(signal: _Array_f, r: float, omega: float, precision: float) -> _Array_f: ... +def sepfir2d(input: _Array_fc, hrow: _Array_fc, hcol: _Array_fc) -> _Array_fc: ... diff --git a/scipy-stubs/signal/_spline_filters.pyi b/scipy-stubs/signal/_spline_filters.pyi index 332e9e9a..41f4071f 100644 --- a/scipy-stubs/signal/_spline_filters.pyi +++ b/scipy-stubs/signal/_spline_filters.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import normalize_axis_index as normalize_axis_index +from scipy._typing import Untyped from scipy.interpolate import BSpline as BSpline from ._arraytools import axis_reverse as axis_reverse, axis_slice as axis_slice from ._signaltools import lfilter as lfilter, lfiltic as lfiltic, sosfilt as sosfilt diff --git a/scipy-stubs/signal/_upfirdn.pyi b/scipy-stubs/signal/_upfirdn.pyi index 28bbab98..291c5e3f 100644 --- a/scipy-stubs/signal/_upfirdn.pyi +++ b/scipy-stubs/signal/_upfirdn.pyi @@ -1,9 +1,33 @@ -from scipy._typing import Untyped +from typing import Any, Literal, TypeAlias -from ._upfirdn_apply import mode_enum as mode_enum +import numpy as np +import numpy.typing as npt +import optype.numpy as onpt + +__all__ = ["_output_len", "upfirdn"] + +_FIRMode: TypeAlias = Literal["constant", "symmetric", "reflect", "wrap"] +_int64_t: TypeAlias = int | np.int64 # noqa: PYI042 class _UpFIRDn: - def __init__(self, h, x_dtype, up, down) -> None: ... - def apply_filter(self, x, axis: int = -1, mode: str = "constant", cval: int = 0) -> Untyped: ... + def __init__(self, /, h: npt.NDArray[np.floating[Any]], x_dtype: np.dtype[np.floating[Any]], up: int, down: int) -> None: ... + def apply_filter( + self, + x: npt.NDArray[np.number[Any]], + axis: int = -1, + mode: _FIRMode = "constant", + cval: int = 0, + ) -> npt.NDArray[np.floating[Any]]: ... + +def upfirdn( + h: onpt.AnyFloatingArray, + x: onpt.AnyIntegerArray | onpt.AnyFloatingArray, + up: int = 1, + down: int = 1, + axis: int = -1, + mode: _FIRMode = "constant", + cval: float = 0, +) -> npt.NDArray[np.floating[Any]]: ... -def upfirdn(h, x, up: int = 1, down: int = 1, axis: int = -1, mode: str = "constant", cval: int = 0) -> Untyped: ... +# originally defined in `scipy/signal/_upfirdn_apply.pyx` (as `(((in_len - 1) * up + len_h) - 1) // down + 1`) +def _output_len(len_h: _int64_t, in_len: _int64_t, up: _int64_t, down: _int64_t) -> _int64_t: ... diff --git a/scipy-stubs/signal/windows/_windows.pyi b/scipy-stubs/signal/windows/_windows.pyi index 2245bfcb..3197b3cf 100644 --- a/scipy-stubs/signal/windows/_windows.pyi +++ b/scipy-stubs/signal/windows/_windows.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy import linalg as linalg, special as special +from scipy._typing import Untyped def general_cosine(M, a, sym: bool = True) -> Untyped: ... def boxcar(M, sym: bool = True) -> Untyped: ... diff --git a/scipy-stubs/sparse/_base.pyi b/scipy-stubs/sparse/_base.pyi index 5e983aa3..fcc64ca9 100644 --- a/scipy-stubs/sparse/_base.pyi +++ b/scipy-stubs/sparse/_base.pyi @@ -1,7 +1,6 @@ from typing_extensions import Self, override from scipy._typing import Untyped - from ._matrix import spmatrix as spmatrix __all__ = ["SparseEfficiencyWarning", "SparseWarning", "issparse", "isspmatrix", "sparray"] @@ -32,20 +31,19 @@ class _spbase: @property def format(self) -> str: ... @property - def T(self) -> Untyped: ... + def T(self) -> Self: ... @property - def real(self) -> Untyped: ... + def real(self) -> Self: ... @property - def imag(self) -> Untyped: ... + def imag(self) -> Self: ... def __bool__(self, /) -> bool: ... - __nonzero__ = __bool__ def __len__(self, /) -> int: ... def asformat(self, format: Untyped, copy: bool = False) -> Untyped: ... def multiply(self, other: Untyped) -> Untyped: ... def maximum(self, other: Untyped) -> Untyped: ... def minimum(self, other: Untyped) -> Untyped: ... def dot(self, other: Untyped) -> Untyped: ... - def power(self, n: Untyped, dtype: Untyped | None = None) -> Untyped: ... + def power(self, n: Untyped, dtype: Untyped | None = None) -> Self: ... @override def __eq__(self, other: Untyped, /) -> Untyped: ... # type: ignore[override] @override @@ -54,8 +52,8 @@ class _spbase: def __gt__(self, other: Untyped, /) -> Untyped: ... def __le__(self, other: Untyped, /) -> Untyped: ... def __ge__(self, other: Untyped, /) -> Untyped: ... - def __abs__(self) -> Untyped: ... - def __round__(self, ndigits: int = 0) -> Untyped: ... + def __abs__(self, /) -> Self: ... + def __round__(self, /, ndigits: int = 0) -> Self: ... def __add__(self, other: Untyped, /) -> Untyped: ... def __radd__(self, other: Untyped, /) -> Untyped: ... def __sub__(self, other: Untyped, /) -> Untyped: ... @@ -68,16 +66,17 @@ class _spbase: def __div__(self, other: Untyped, /) -> Untyped: ... def __rtruediv__(self, other: Untyped, /) -> Untyped: ... def __rdiv__(self, other: Untyped, /) -> Untyped: ... - def __neg__(self, /) -> Untyped: ... + def __neg__(self, /) -> Self: ... def __iadd__(self, other: Untyped, /) -> Self: ... def __isub__(self, other: Untyped, /) -> Self: ... def __imul__(self, other: Untyped, /) -> Self: ... def __idiv__(self, other: Untyped, /) -> Self: ... - def __itruediv__(self, other: Untyped) -> Self: ... - def __pow__(self, other: Untyped, /, *args: Untyped, **kwargs: Untyped) -> Untyped: ... - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - def conjugate(self, copy: bool = True) -> Untyped: ... - def conj(self, copy: bool = True) -> Untyped: ... + def __itruediv__(self, other: Untyped, /) -> Self: ... + # NOTE: The modulo was left out for simplicitiy, but might need to be put back in + def __pow__(self, other: Untyped, /) -> Untyped: ... + def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Self: ... + def conjugate(self, copy: bool = True) -> Self: ... + def conj(self, copy: bool = True) -> Self: ... def nonzero(self) -> Untyped: ... def todense(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... def toarray(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... @@ -88,7 +87,7 @@ class _spbase: def todia(self, copy: bool = False) -> Untyped: ... def tobsr(self, blocksize: Untyped | None = None, copy: bool = False) -> Untyped: ... def tocsc(self, copy: bool = False) -> Untyped: ... - def copy(self) -> Untyped: ... + def copy(self) -> Self: ... def sum(self, axis: Untyped | None = None, dtype: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... def mean(self, axis: Untyped | None = None, dtype: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... def diagonal(self, k: int = 0) -> Untyped: ... diff --git a/scipy-stubs/sparse/_bsr.pyi b/scipy-stubs/sparse/_bsr.pyi index 1a9e89d0..be0682b6 100644 --- a/scipy-stubs/sparse/_bsr.pyi +++ b/scipy-stubs/sparse/_bsr.pyi @@ -1,8 +1,9 @@ -from typing_extensions import override +from collections.abc import Sequence +import numpy.typing as npt +import scipy._typing as spt from scipy._typing import Untyped - -from ._base import issparse as issparse, sparray +from ._base import sparray from ._compressed import _cs_matrix from ._data import _minmax_mixin from ._matrix import spmatrix @@ -16,8 +17,8 @@ class _bsr_base(_cs_matrix, _minmax_mixin): def __init__( self, arg1: Untyped, - shape: Untyped | None = None, - dtype: Untyped | None = None, + shape: spt.AnyInt | Sequence[spt.AnyInt] | None = None, + dtype: npt.DTypeLike | None = None, copy: bool = False, blocksize: tuple[int, int] | None = None, *, @@ -25,24 +26,6 @@ class _bsr_base(_cs_matrix, _minmax_mixin): ) -> None: ... @property def blocksize(self) -> tuple[int, int]: ... - @override - def diagonal(self, k: int = 0) -> Untyped: ... - @override - def __getitem__(self, key: Untyped) -> Untyped: ... - @override - def __setitem__(self, key: Untyped, val: Untyped) -> None: ... - @override - def tobsr(self, blocksize: Untyped | None = None, copy: bool = False) -> Untyped: ... - @override - def tocsr(self, copy: bool = False) -> Untyped: ... - @override - def tocsc(self, copy: bool = False) -> Untyped: ... - @override - def tocoo(self, copy: bool = True) -> Untyped: ... - @override - def toarray(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - @override - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... class bsr_array(_bsr_base, sparray): ... class bsr_matrix(spmatrix, _bsr_base): ... diff --git a/scipy-stubs/sparse/_compressed.pyi b/scipy-stubs/sparse/_compressed.pyi index aae77531..d9c142f2 100644 --- a/scipy-stubs/sparse/_compressed.pyi +++ b/scipy-stubs/sparse/_compressed.pyi @@ -1,7 +1,6 @@ from typing_extensions import override from scipy._typing import Untyped - from ._data import _data_matrix, _minmax_mixin from ._index import IndexMixin @@ -23,32 +22,6 @@ class _cs_matrix(_data_matrix, _minmax_mixin, IndexMixin): @override def count_nonzero(self, axis: Untyped | None = None) -> int: ... def check_format(self, full_check: bool = True) -> Untyped: ... - @override - def __eq__(self, other: Untyped, /) -> Untyped: ... # type: ignore[override] - @override - def __ne__(self, other: Untyped, /) -> Untyped: ... # type: ignore[override] - @override - def __lt__(self, other: Untyped, /) -> Untyped: ... - @override - def __gt__(self, other: Untyped, /) -> Untyped: ... - @override - def __le__(self, other: Untyped, /) -> Untyped: ... - @override - def __ge__(self, other: Untyped, /) -> Untyped: ... - @override - def multiply(self, other: Untyped) -> Untyped: ... - @override - def diagonal(self, k: int = 0) -> Untyped: ... - @override - def maximum(self, other: Untyped) -> Untyped: ... - @override - def minimum(self, other: Untyped) -> Untyped: ... - @override - def sum(self, axis: Untyped | None = None, dtype: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - @override - def tocoo(self, copy: bool = True) -> Untyped: ... - @override - def toarray(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... def eliminate_zeros(self) -> Untyped: ... @property def has_canonical_format(self) -> bool: ... diff --git a/scipy-stubs/sparse/_coo.pyi b/scipy-stubs/sparse/_coo.pyi index 4adce516..7013a036 100644 --- a/scipy-stubs/sparse/_coo.pyi +++ b/scipy-stubs/sparse/_coo.pyi @@ -1,7 +1,6 @@ from typing_extensions import override from scipy._typing import Untyped - from ._base import sparray from ._data import _data_matrix, _minmax_mixin from ._matrix import spmatrix @@ -31,26 +30,6 @@ class _coo_base(_data_matrix, _minmax_mixin): def col(self, new_col: Untyped) -> None: ... @override def reshape(self, *args: Untyped, **kwargs: Untyped) -> Untyped: ... - @override - def count_nonzero(self, axis: Untyped | None = None) -> int: ... - @override - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - @override - def resize(self, *shape: int) -> None: ... # type: ignore[override] - @override - def toarray(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - @override - def tocsc(self, copy: bool = False) -> Untyped: ... - @override - def tocsr(self, copy: bool = False) -> Untyped: ... - @override - def tocoo(self, copy: bool = False) -> Untyped: ... - @override - def todia(self, copy: bool = False) -> Untyped: ... - @override - def todok(self, copy: bool = False) -> Untyped: ... - @override - def diagonal(self, k: int = 0) -> Untyped: ... def sum_duplicates(self) -> None: ... def eliminate_zeros(self) -> Untyped: ... diff --git a/scipy-stubs/sparse/_csc.pyi b/scipy-stubs/sparse/_csc.pyi index 58867a31..4866c5b0 100644 --- a/scipy-stubs/sparse/_csc.pyi +++ b/scipy-stubs/sparse/_csc.pyi @@ -1,25 +1,13 @@ from typing_extensions import override from scipy._typing import Untyped - from ._base import sparray from ._compressed import _cs_matrix from ._matrix import spmatrix __all__ = ["csc_array", "csc_matrix", "isspmatrix_csc"] -class _csc_base(_cs_matrix): - @override - def __iter__(self) -> Untyped: ... - @override - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - @override - def tocsc(self, copy: bool = False) -> Untyped: ... - @override - def tocsr(self, copy: bool = False) -> Untyped: ... - @override - def nonzero(self) -> Untyped: ... - +class _csc_base(_cs_matrix): ... class csc_array(_csc_base, sparray): ... class csc_matrix(spmatrix, _csc_base): ... diff --git a/scipy-stubs/sparse/_csr.pyi b/scipy-stubs/sparse/_csr.pyi index 0c2d4921..3e05c0d2 100644 --- a/scipy-stubs/sparse/_csr.pyi +++ b/scipy-stubs/sparse/_csr.pyi @@ -1,27 +1,13 @@ from typing_extensions import override from scipy._typing import Untyped - from ._base import sparray from ._compressed import _cs_matrix from ._matrix import spmatrix __all__ = ["csr_array", "csr_matrix", "isspmatrix_csr"] -class _csr_base(_cs_matrix): - @override - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - @override - def tolil(self, copy: bool = False) -> Untyped: ... - @override - def tocsr(self, copy: bool = False) -> Untyped: ... - @override - def tocsc(self, copy: bool = False) -> Untyped: ... - @override - def tobsr(self, blocksize: Untyped | None = None, copy: bool = True) -> Untyped: ... - @override - def __iter__(self) -> Untyped: ... - +class _csr_base(_cs_matrix): ... class csr_array(_csr_base, sparray): ... class csr_matrix(spmatrix, _csr_base): ... diff --git a/scipy-stubs/sparse/_data.pyi b/scipy-stubs/sparse/_data.pyi index 62c9df69..672b97f8 100644 --- a/scipy-stubs/sparse/_data.pyi +++ b/scipy-stubs/sparse/_data.pyi @@ -1,30 +1,16 @@ -from typing_extensions import Self - import numpy as np - import numpy.typing as npt from scipy._typing import Untyped +from ._base import _spbase -from ._base import _spbase, sparray as sparray -from ._sputils import isscalarlike as isscalarlike, validateaxis as validateaxis +__all__: list[str] = [] class _data_matrix(_spbase): - def __init__(self, arg1, *, maxprint: Untyped | None = None) -> None: ... + def __init__(self, arg1: Untyped, *, maxprint: Untyped | None = None) -> None: ... @property def dtype(self) -> np.dtype[np.generic]: ... @dtype.setter def dtype(self, newtype: npt.DTypeLike) -> None: ... - def __abs__(self) -> Untyped: ... - def __round__(self, ndigits: int = 0) -> Untyped: ... - def __neg__(self) -> Untyped: ... - def __imul__(self, other) -> Self: ... - def __itruediv__(self, other) -> Self: ... - def astype(self, dtype, casting: str = "unsafe", copy: bool = True) -> Untyped: ... - def conjugate(self, copy: bool = True) -> Untyped: ... - def copy(self) -> Untyped: ... - def power(self, n, dtype: Untyped | None = None) -> Untyped: ... - -name: Untyped class _minmax_mixin: def max(self, axis: Untyped | None = None, out: Untyped | None = None, *, explicit: bool = False) -> Untyped: ... diff --git a/scipy-stubs/sparse/_dia.pyi b/scipy-stubs/sparse/_dia.pyi index bbbce020..fc523bc1 100644 --- a/scipy-stubs/sparse/_dia.pyi +++ b/scipy-stubs/sparse/_dia.pyi @@ -1,7 +1,6 @@ from typing_extensions import override from scipy._typing import Untyped - from ._base import sparray, spmatrix from ._data import _data_matrix @@ -20,20 +19,6 @@ class _dia_base(_data_matrix): maxprint: Untyped | None = None, ) -> None: ... @override - def count_nonzero(self, axis: Untyped | None = None) -> int: ... - @override - def sum(self, axis: Untyped | None = None, dtype: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - @override - def todia(self, copy: bool = False) -> Untyped: ... - @override - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - @override - def diagonal(self, k: int = 0) -> Untyped: ... - @override - def tocsc(self, copy: bool = False) -> Untyped: ... - @override - def tocoo(self, copy: bool = False) -> Untyped: ... - @override def resize(self, *shape: int): ... # type: ignore[override] class dia_array(_dia_base, sparray): ... diff --git a/scipy-stubs/sparse/_dok.pyi b/scipy-stubs/sparse/_dok.pyi index 8ba9fcb0..6f3359ea 100644 --- a/scipy-stubs/sparse/_dok.pyi +++ b/scipy-stubs/sparse/_dok.pyi @@ -1,80 +1,51 @@ -from typing_extensions import Self +# pyright: reportUnnecessaryTypeIgnoreComment=false +from collections.abc import Iterable +from typing_extensions import Self, override from scipy._typing import Untyped +from ._base import _spbase, sparray +from ._index import IndexMixin +from ._matrix import spmatrix -from ._base import _spbase, issparse as issparse, sparray as sparray -from ._index import IndexMixin as IndexMixin -from ._matrix import spmatrix as spmatrix -from ._sputils import ( - check_shape as check_shape, - getdtype as getdtype, - isdense as isdense, - isintlike as isintlike, - isscalarlike as isscalarlike, - isshape as isshape, - upcast as upcast, - upcast_scalar as upcast_scalar, -) +__all__ = ["dok_array", "dok_matrix", "isspmatrix_dok"] -__docformat__: str - -class _dok_base(_spbase, IndexMixin, dict): +class _dok_base(_spbase, IndexMixin, dict[tuple[int, ...], Untyped]): # type: ignore[misc] dtype: Untyped def __init__( self, - arg1, + arg1: Untyped, shape: Untyped | None = None, dtype: Untyped | None = None, copy: bool = False, *, maxprint: Untyped | None = None, - ): ... - def update(self, val): ... - def count_nonzero(self, axis: Untyped | None = None) -> Untyped: ... - def __len__(self) -> int: ... - def __contains__(self, key) -> bool: ... - def setdefault(self, key, default: Untyped | None = None, /) -> Untyped: ... - def __delitem__(self, key) -> None: ... - def clear(self) -> Untyped: ... - def pop(self, /, *args) -> Untyped: ... - def __reversed__(self): ... - def __or__(self, other): ... - def __ror__(self, other): ... - def __ior__(self, other) -> Self: ... - def popitem(self) -> Untyped: ... - def items(self) -> Untyped: ... - def keys(self) -> Untyped: ... - def values(self) -> Untyped: ... - def get(self, key, default: float = 0.0) -> Untyped: ... - def __add__(self, other) -> Untyped: ... - def __radd__(self, other) -> Untyped: ... - def __neg__(self) -> Untyped: ... - def __imul__(self, other) -> Self: ... - def __truediv__(self, other) -> Untyped: ... - def __itruediv__(self, other) -> Self: ... - def __reduce__(self) -> Untyped: ... - def diagonal(self, k: int = 0) -> Untyped: ... - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... + ) -> None: ... + @override + def update(self, val: Untyped): ... # type: ignore[override] + @override + def setdefault(self, key: Untyped, default: Untyped | None = None, /) -> Untyped: ... + @override + def __delitem__(self, key: Untyped, /) -> None: ... + @override + def __or__(self, other: Untyped, /): ... # type: ignore[override] + @override + def __ror__(self, other: Untyped, /): ... # type: ignore[override] + @override + def __ior__(self, other: Untyped, /) -> Self: ... # type: ignore[override] + @override + def get(self, key, /, default: float = 0.0) -> Untyped: ... # type: ignore[override] def conjtransp(self) -> Untyped: ... - def copy(self) -> Untyped: ... @classmethod - def fromkeys(cls, iterable, value: int = 1, /) -> Untyped: ... - def tocoo(self, copy: bool = False) -> Untyped: ... - def todok(self, copy: bool = False) -> Untyped: ... - def tocsc(self, copy: bool = False) -> Untyped: ... - def resize(self, *shape): ... - def astype(self, dtype, casting: str = "unsafe", copy: bool = True) -> Untyped: ... + @override + def fromkeys(cls, iterable: Iterable[tuple[int, ...]], value: int = 1, /) -> Self: ... # type: ignore[override] -def isspmatrix_dok(x) -> Untyped: ... +class dok_array(_dok_base, sparray): ... # type: ignore[misc] -class dok_array(_dok_base, sparray): ... +class dok_matrix(spmatrix, _dok_base): # type: ignore[misc] + @property + @override + def shape(self) -> tuple[int, int]: ... + @override + def get_shape(self) -> tuple[int, int]: ... -class dok_matrix(spmatrix, _dok_base): - __dict__: Untyped - def set_shape(self, shape): ... - def get_shape(self) -> Untyped: ... - shape: Untyped - def __reversed__(self) -> Untyped: ... - def __or__(self, other) -> Untyped: ... - def __ror__(self, other) -> Untyped: ... - def __ior__(self, other) -> Self: ... +def isspmatrix_dok(x: Untyped) -> bool: ... diff --git a/scipy-stubs/sparse/_extract.pyi b/scipy-stubs/sparse/_extract.pyi index f3c2b6c7..e328ead0 100644 --- a/scipy-stubs/sparse/_extract.pyi +++ b/scipy-stubs/sparse/_extract.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._base import sparray as sparray from ._coo import coo_array as coo_array, coo_matrix as coo_matrix diff --git a/scipy-stubs/sparse/_index.pyi b/scipy-stubs/sparse/_index.pyi index fb23f84b..273155a7 100644 --- a/scipy-stubs/sparse/_index.pyi +++ b/scipy-stubs/sparse/_index.pyi @@ -1,10 +1,6 @@ +import optype.numpy as onpt from scipy._typing import Untyped -from ._base import issparse as issparse, sparray as sparray -from ._sputils import isintlike as isintlike - -INT_TYPES: Untyped - class IndexMixin: - def __getitem__(self, key) -> Untyped: ... - def __setitem__(self, key, x) -> None: ... + def __getitem__(self, key: onpt.AnyIntegerArray, /) -> Untyped: ... + def __setitem__(self, key: onpt.AnyIntegerArray, x: Untyped, /) -> None: ... diff --git a/scipy-stubs/sparse/_lil.pyi b/scipy-stubs/sparse/_lil.pyi index 5cf4dbc0..e07fbdb8 100644 --- a/scipy-stubs/sparse/_lil.pyi +++ b/scipy-stubs/sparse/_lil.pyi @@ -1,20 +1,11 @@ -from typing_extensions import Self +from typing_extensions import override from scipy._typing import Untyped +from ._base import _spbase, sparray +from ._index import IndexMixin +from ._matrix import spmatrix -from ._base import _spbase, issparse as issparse, sparray as sparray -from ._index import INT_TYPES as INT_TYPES, IndexMixin as IndexMixin -from ._matrix import spmatrix as spmatrix -from ._sputils import ( - check_reshape_kwargs as check_reshape_kwargs, - check_shape as check_shape, - getdtype as getdtype, - isscalarlike as isscalarlike, - isshape as isshape, - upcast_scalar as upcast_scalar, -) - -__docformat__: str +__all__ = ["isspmatrix_lil", "lil_array", "lil_matrix"] class _lil_base(_spbase, IndexMixin): dtype: Untyped @@ -22,30 +13,17 @@ class _lil_base(_spbase, IndexMixin): data: Untyped def __init__( self, - arg1, + arg1: Untyped, shape: Untyped | None = None, dtype: Untyped | None = None, copy: bool = False, *, maxprint: Untyped | None = None, - ): ... - def __iadd__(self, other) -> Self: ... - def __isub__(self, other) -> Self: ... - def __imul__(self, other) -> Self: ... - def __itruediv__(self, other) -> Self: ... - def count_nonzero(self, axis: Untyped | None = None) -> Untyped: ... + ) -> None: ... def getrowview(self, i) -> Untyped: ... def getrow(self, i) -> Untyped: ... - def __getitem__(self, key) -> Untyped: ... - def __setitem__(self, key, x) -> None: ... - def __truediv__(self, other) -> Untyped: ... - def copy(self) -> Untyped: ... - def reshape(self, *args, **kwargs) -> Untyped: ... - def resize(self, *shape): ... - def toarray(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - def tolil(self, copy: bool = False) -> Untyped: ... - def tocsr(self, copy: bool = False) -> Untyped: ... + @override + def resize(self, *shape: int): ... # type: ignore[override] def isspmatrix_lil(x) -> Untyped: ... diff --git a/scipy-stubs/sparse/_matrix.pyi b/scipy-stubs/sparse/_matrix.pyi index e8cd2b1e..aee27530 100644 --- a/scipy-stubs/sparse/_matrix.pyi +++ b/scipy-stubs/sparse/_matrix.pyi @@ -8,7 +8,7 @@ class spmatrix: def __mul__(self, other: Untyped, /) -> Untyped: ... def __rmul__(self, other: Untyped, /) -> Untyped: ... def __pow__(self, power: Untyped, /) -> Untyped: ... - def set_shape(self, shape: Untyped) -> Untyped: ... + def set_shape(self, shape: Untyped) -> None: ... def get_shape(self) -> tuple[int, ...]: ... def asfptype(self) -> Untyped: ... def getmaxprint(self) -> Untyped: ... diff --git a/scipy-stubs/sparse/_sputils.pyi b/scipy-stubs/sparse/_sputils.pyi index d02a9d23..9c1912c1 100644 --- a/scipy-stubs/sparse/_sputils.pyi +++ b/scipy-stubs/sparse/_sputils.pyi @@ -1,11 +1,9 @@ from typing import Any, Literal import numpy as np - -from scipy._typing import Untyped - import scipy.sparse as sp from scipy._lib._util import np_long as np_long, np_ulong as np_ulong +from scipy._typing import Untyped, UntypedArray supported_dtypes: Untyped @@ -15,9 +13,9 @@ def upcast_scalar(dtype, scalar) -> Untyped: ... def downcast_intp_index(arr) -> Untyped: ... def to_native(A) -> Untyped: ... def getdtype(dtype, a: Untyped | None = None, default: Untyped | None = None) -> Untyped: ... -def getdata(obj, dtype: Untyped | None = None, copy: bool = False) -> np.ndarray: ... +def getdata(obj, dtype: Untyped | None = None, copy: bool = False) -> UntypedArray: ... def get_index_dtype(arrays=(), maxval: Untyped | None = None, check_contents: bool = False) -> Untyped: ... -def get_sum_dtype(dtype: np.dtype) -> np.dtype: ... +def get_sum_dtype(dtype: np.dtype[np.generic]) -> np.dtype[np.generic]: ... def isscalarlike(x) -> bool: ... def isintlike(x) -> bool: ... def isshape(x, nonneg: bool = False, *, allow_1d: bool = False) -> bool: ... diff --git a/scipy-stubs/sparse/csgraph/_validation.pyi b/scipy-stubs/sparse/csgraph/_validation.pyi index eb9da3fe..5f308a1f 100644 --- a/scipy-stubs/sparse/csgraph/_validation.pyi +++ b/scipy-stubs/sparse/csgraph/_validation.pyi @@ -1,7 +1,6 @@ from typing import Final import numpy as np - import numpy.typing as npt from scipy._typing import Untyped diff --git a/scipy-stubs/sparse/linalg/_dsolve/_add_newdocs.pyi b/scipy-stubs/sparse/linalg/_dsolve/_add_newdocs.pyi deleted file mode 100644 index e69de29b..00000000 diff --git a/scipy-stubs/sparse/linalg/_dsolve/_superlu.pyi b/scipy-stubs/sparse/linalg/_dsolve/_superlu.pyi index c769f6a8..06fb3009 100644 --- a/scipy-stubs/sparse/linalg/_dsolve/_superlu.pyi +++ b/scipy-stubs/sparse/linalg/_dsolve/_superlu.pyi @@ -1,12 +1,9 @@ from typing import Any import numpy as np - import numpy.typing as npt import optype.numpy as onpt - from scipy.sparse import csc_matrix -from scipy.stats._levy_stable import np __all__ = ["SuperLU"] diff --git a/scipy-stubs/sparse/linalg/_eigen/__init__.pyi b/scipy-stubs/sparse/linalg/_eigen/__init__.pyi index c192ee35..a2e200b7 100644 --- a/scipy-stubs/sparse/linalg/_eigen/__init__.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/__init__.pyi @@ -1,4 +1,6 @@ -from . import arpack as arpack -from ._svds import svds as svds +from . import arpack +from ._svds import svds from .arpack import * from .lobpcg import * + +__all__ = ["ArpackError", "ArpackNoConvergence", "eigs", "eigsh", "lobpcg", "svds"] diff --git a/scipy-stubs/sparse/linalg/_eigen/_svds.pyi b/scipy-stubs/sparse/linalg/_eigen/_svds.pyi index 0682bf8d..c32b077b 100644 --- a/scipy-stubs/sparse/linalg/_eigen/_svds.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/_svds.pyi @@ -1,12 +1,11 @@ -from scipy._typing import Untyped - from scipy._lib._util import check_random_state as check_random_state +from scipy._typing import Untyped from scipy.linalg import svd as svd from scipy.sparse.linalg._eigen.lobpcg import lobpcg as lobpcg from scipy.sparse.linalg._interface import LinearOperator as LinearOperator, aslinearoperator as aslinearoperator from . import eigsh as eigsh -arpack_int: Untyped +__all__ = ["svds"] def svds( A, diff --git a/scipy-stubs/sparse/linalg/_eigen/arpack/arpack.pyi b/scipy-stubs/sparse/linalg/_eigen/arpack/arpack.pyi index 3ae77f86..f7e0a17f 100644 --- a/scipy-stubs/sparse/linalg/_eigen/arpack/arpack.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/arpack/arpack.pyi @@ -1,30 +1,22 @@ +from typing import Final + from scipy._typing import Untyped +from scipy.sparse.linalg._interface import LinearOperator -from scipy._lib._threadsafety import ReentrancyLock as ReentrancyLock -from scipy.linalg import eig as eig, eigh as eigh, lu_factor as lu_factor, lu_solve as lu_solve -from scipy.sparse import eye as eye, issparse as issparse -from scipy.sparse._sputils import ( - convert_pydata_sparse_to_scipy as convert_pydata_sparse_to_scipy, - is_pydata_spmatrix as is_pydata_spmatrix, - isdense as isdense, -) -from scipy.sparse.linalg import gmres as gmres, splu as splu -from scipy.sparse.linalg._interface import LinearOperator as LinearOperator, aslinearoperator as aslinearoperator +__all__ = ["ArpackError", "ArpackNoConvergence", "eigs", "eigsh"] -arpack_int: Untyped -__docformat__: str -DNAUPD_ERRORS: Untyped +DNAUPD_ERRORS: Final[dict[int, str]] SNAUPD_ERRORS = DNAUPD_ERRORS -ZNAUPD_ERRORS: Untyped +ZNAUPD_ERRORS: Final[dict[int, str]] CNAUPD_ERRORS = ZNAUPD_ERRORS -DSAUPD_ERRORS: Untyped +DSAUPD_ERRORS: Final[dict[int, str]] SSAUPD_ERRORS = DSAUPD_ERRORS -DNEUPD_ERRORS: Untyped -SNEUPD_ERRORS: Untyped -ZNEUPD_ERRORS: Untyped -CNEUPD_ERRORS: Untyped -DSEUPD_ERRORS: Untyped -SSEUPD_ERRORS: Untyped +DNEUPD_ERRORS: Final[dict[int, str]] +SNEUPD_ERRORS: Final[dict[int, str]] +ZNEUPD_ERRORS: Final[dict[int, str]] +CNEUPD_ERRORS: Final[dict[int, str]] +DSEUPD_ERRORS: Final[dict[int, str]] +SSEUPD_ERRORS: Final[dict[int, str]] class ArpackError(RuntimeError): def __init__(self, info, infodict=...) -> None: ... @@ -95,7 +87,6 @@ class _SymmetricArpackParams(_ArpackParams): tol: int = 0, ): ... converged: bool - def iterate(self): ... def extract(self, return_eigenvectors) -> Untyped: ... class _UnsymmetricArpackParams(_ArpackParams): @@ -128,28 +119,21 @@ class _UnsymmetricArpackParams(_ArpackParams): tol: int = 0, ): ... converged: bool - def iterate(self): ... def extract(self, return_eigenvectors) -> Untyped: ... class SpLuInv(LinearOperator): M_lu: Untyped - shape: Untyped - dtype: Untyped isreal: Untyped def __init__(self, M) -> None: ... class LuInv(LinearOperator): M_lu: Untyped - shape: Untyped - dtype: Untyped def __init__(self, M) -> None: ... def gmres_loose(A, b, tol) -> Untyped: ... class IterInv(LinearOperator): M: Untyped - dtype: Untyped - shape: Untyped ifunc: Untyped tol: Untyped def __init__(self, M, ifunc=..., tol: int = 0): ... @@ -159,12 +143,9 @@ class IterOpInv(LinearOperator): M: Untyped sigma: Untyped OP: Untyped - shape: Untyped ifunc: Untyped tol: Untyped def __init__(self, A, M, sigma, ifunc=..., tol: int = 0): ... - @property - def dtype(self) -> Untyped: ... def get_inv_matvec(M, hermitian: bool = False, tol: int = 0) -> Untyped: ... def get_OPinv_matvec(A, M, sigma, hermitian: bool = False, tol: int = 0) -> Untyped: ... diff --git a/scipy-stubs/sparse/linalg/_eigen/arpack/tests/__init__.pyi b/scipy-stubs/sparse/linalg/_eigen/arpack/tests/__init__.pyi deleted file mode 100644 index e69de29b..00000000 diff --git a/scipy-stubs/sparse/linalg/_eigen/arpack/tests/test_arpack.pyi b/scipy-stubs/sparse/linalg/_eigen/arpack/tests/test_arpack.pyi deleted file mode 100644 index 349b5740..00000000 --- a/scipy-stubs/sparse/linalg/_eigen/arpack/tests/test_arpack.pyi +++ /dev/null @@ -1,77 +0,0 @@ -from scipy._typing import Untyped - -from scipy._lib._gcutils import IS_PYPY as IS_PYPY, assert_deallocated as assert_deallocated -from scipy.linalg import eig as eig, eigh as eigh -from scipy.sparse import csc_matrix as csc_matrix, csr_matrix as csr_matrix, diags as diags, rand as rand -from scipy.sparse.linalg import LinearOperator as LinearOperator, aslinearoperator as aslinearoperator -from scipy.sparse.linalg._eigen.arpack import ( - ArpackNoConvergence as ArpackNoConvergence, - arpack as arpack, - eigs as eigs, - eigsh as eigsh, -) - -__usage__: str - -def generate_matrix( - N, complex_: bool = False, hermitian: bool = False, pos_definite: bool = False, sparse: bool = False -) -> Untyped: ... -def generate_matrix_symmetric(N, pos_definite: bool = False, sparse: bool = False) -> Untyped: ... -def assert_allclose_cc(actual, desired, **kw): ... -def argsort_which( - eigenvalues, typ, k, which, sigma: Untyped | None = None, OPpart: Untyped | None = None, mode: Untyped | None = None -) -> Untyped: ... -def eval_evec( - symmetric, - d, - typ, - k, - which, - v0: Untyped | None = None, - sigma: Untyped | None = None, - mattype=..., - OPpart: Untyped | None = None, - mode: str = "normal", -): ... - -class DictWithRepr(dict): - name: Untyped - def __init__(self, name) -> None: ... - -class SymmetricParams: - eigs: Untyped - which: Untyped - mattypes: Untyped - sigmas_modes: Untyped - real_test_cases: Untyped - complex_test_cases: Untyped - def __init__(self) -> None: ... - -class NonSymmetricParams: - eigs: Untyped - which: Untyped - mattypes: Untyped - sigmas_OPparts: Untyped - real_test_cases: Untyped - complex_test_cases: Untyped - def __init__(self) -> None: ... - -def test_symmetric_modes(): ... -def test_hermitian_modes(): ... -def test_symmetric_starting_vector(): ... -def test_symmetric_no_convergence(): ... -def test_real_nonsymmetric_modes(): ... -def test_complex_nonsymmetric_modes(): ... -def test_standard_nonsymmetric_starting_vector(): ... -def test_general_nonsymmetric_starting_vector(): ... -def test_standard_nonsymmetric_no_convergence(): ... -def test_eigen_bad_shapes(): ... -def test_eigen_bad_kwargs(): ... -def test_ticket_1459_arpack_crash(): ... -def test_linearoperator_deallocation() -> Untyped: ... -def test_parallel_threads(): ... -def test_reentering() -> Untyped: ... -def test_regression_arpackng_1315(): ... -def test_eigs_for_k_greater(): ... -def test_eigsh_for_k_greater(): ... -def test_real_eigs_real_k_subset(): ... diff --git a/scipy-stubs/sparse/linalg/_eigen/lobpcg/__init__.pyi b/scipy-stubs/sparse/linalg/_eigen/lobpcg/__init__.pyi index 812ce0de..a705a0ba 100644 --- a/scipy-stubs/sparse/linalg/_eigen/lobpcg/__init__.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/lobpcg/__init__.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._testutils import PytestTester as PytestTester +from scipy._typing import Untyped from .lobpcg import * test: Untyped diff --git a/scipy-stubs/sparse/linalg/_eigen/lobpcg/lobpcg.pyi b/scipy-stubs/sparse/linalg/_eigen/lobpcg/lobpcg.pyi index 66632321..16f944e6 100644 --- a/scipy-stubs/sparse/linalg/_eigen/lobpcg/lobpcg.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/lobpcg/lobpcg.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.linalg import ( LinAlgError as LinAlgError, cho_factor as cho_factor, diff --git a/scipy-stubs/sparse/linalg/_eigen/lobpcg/tests/__init__.pyi b/scipy-stubs/sparse/linalg/_eigen/lobpcg/tests/__init__.pyi deleted file mode 100644 index e69de29b..00000000 diff --git a/scipy-stubs/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.pyi b/scipy-stubs/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.pyi deleted file mode 100644 index 8185bbe3..00000000 --- a/scipy-stubs/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.pyi +++ /dev/null @@ -1,38 +0,0 @@ -from scipy._typing import Untyped - -from scipy import sparse as sparse -from scipy._lib._util import np_long as np_long, np_ulong as np_ulong -from scipy.linalg import eig as eig, eigh as eigh, orth as orth, toeplitz as toeplitz -from scipy.sparse import csr_matrix as csr_matrix, diags as diags, eye as eye, spdiags as spdiags -from scipy.sparse.linalg import LinearOperator as LinearOperator, eigs as eigs -from scipy.sparse.linalg._eigen.lobpcg import lobpcg as lobpcg - -INT_DTYPES: Untyped -REAL_DTYPES: Untyped -COMPLEX_DTYPES: Untyped -INEXECTDTYPES: Untyped -ALLDTYPES: Untyped - -def sign_align(A, B) -> Untyped: ... -def ElasticRod(n) -> Untyped: ... -def MikotaPair(n) -> Untyped: ... -def compare_solutions(A, B, m): ... -def test_Small(): ... -def test_ElasticRod(): ... -def test_MikotaPair(): ... -def test_b_orthonormalize(n, m, Vdtype, Bdtype, BVdtype) -> Untyped: ... -def test_nonhermitian_warning(capsys): ... -def test_regression(): ... -def test_diagonal(n, m, m_excluded) -> Untyped: ... -def test_fiedler_small_8(): ... -def test_fiedler_large_12(): ... -def test_failure_to_run_iterations(): ... -def test_failure_to_run_iterations_nonsymmetric(): ... -def test_hermitian(): ... -def test_eigs_consistency(n, atol): ... -def test_verbosity(): ... -def test_tolerance_float32(): ... -def test_dtypes(vdtype, mdtype, arr_type): ... -def test_inplace_warning(): ... -def test_maxit(): ... -def test_diagonal_data_types(n, m) -> Untyped: ... diff --git a/scipy-stubs/sparse/linalg/_expm_multiply.pyi b/scipy-stubs/sparse/linalg/_expm_multiply.pyi index ad43f39a..b9d75ba1 100644 --- a/scipy-stubs/sparse/linalg/_expm_multiply.pyi +++ b/scipy-stubs/sparse/linalg/_expm_multiply.pyi @@ -1,10 +1,6 @@ from scipy._typing import Untyped -from scipy.linalg._decomp_qr import qr as qr -from scipy.sparse._sputils import is_pydata_spmatrix as is_pydata_spmatrix -from scipy.sparse.linalg import aslinearoperator as aslinearoperator -from scipy.sparse.linalg._interface import IdentityOperator as IdentityOperator -from scipy.sparse.linalg._onenormest import onenormest as onenormest +__all__ = ["expm_multiply"] def traceest(A, m3, seed: Untyped | None = None) -> Untyped: ... def expm_multiply( diff --git a/scipy-stubs/sparse/linalg/_interface.pyi b/scipy-stubs/sparse/linalg/_interface.pyi index f17f068c..920e33f5 100644 --- a/scipy-stubs/sparse/linalg/_interface.pyi +++ b/scipy-stubs/sparse/linalg/_interface.pyi @@ -1,39 +1,52 @@ -from scipy._typing import Untyped +from collections.abc import Sequence +from typing import ClassVar, Final, Literal -from scipy.sparse import issparse as issparse -from scipy.sparse._sputils import ( - asmatrix as asmatrix, - is_pydata_spmatrix as is_pydata_spmatrix, - isintlike as isintlike, - isshape as isshape, -) +import numpy as np +import numpy.typing as npt +import optype.numpy as onpt +import scipy._typing as spt +from scipy._typing import Untyped, UntypedArray +__all__ = ["LinearOperator", "aslinearoperator"] + +# TODO: make these all generic class LinearOperator: - ndim: int - __array_ufunc__: Untyped - def __new__(cls, *args, **kwargs) -> Untyped: ... - dtype: Untyped - shape: Untyped - def __init__(self, dtype, shape) -> None: ... - def matvec(self, x) -> Untyped: ... - def rmatvec(self, x) -> Untyped: ... - def matmat(self, X) -> Untyped: ... - def rmatmat(self, X) -> Untyped: ... - def __call__(self, x) -> Untyped: ... - def __mul__(self, x) -> Untyped: ... - def __truediv__(self, other) -> Untyped: ... - def dot(self, x) -> Untyped: ... - def __matmul__(self, other) -> Untyped: ... - def __rmatmul__(self, other) -> Untyped: ... - def __rmul__(self, x) -> Untyped: ... - def __pow__(self, p) -> Untyped: ... - def __add__(self, x) -> Untyped: ... - def __neg__(self) -> Untyped: ... - def __sub__(self, x) -> Untyped: ... - def adjoint(self) -> Untyped: ... - H: Untyped - def transpose(self) -> Untyped: ... - T: Untyped + __array_ufunc__: ClassVar[None] + + shape: tuple[int] | tuple[int, int] + ndim: Literal[1, 2] + @property + def dtype(self) -> np.dtype[np.generic]: ... + def __init__(self, dtype: npt.DTypeLike, shape: spt.AnyInt | Sequence[spt.AnyInt]) -> None: ... + def matvec(self, x: npt.ArrayLike, /) -> UntypedArray: ... + def rmatvec(self, x: npt.ArrayLike, /) -> UntypedArray: ... + def matmat(self, X: npt.ArrayLike, /) -> UntypedArray: ... + def rmatmat(self, X: npt.ArrayLike, /) -> UntypedArray: ... + def __call__(self, x: npt.ArrayLike | LinearOperator, /) -> _ProductLinearOperator | _ScaledLinearOperator | UntypedArray: ... + def __mul__(self, x: LinearOperator | npt.ArrayLike, /) -> _ProductLinearOperator | _ScaledLinearOperator | UntypedArray: ... + def __truediv__(self, other: spt.AnyScalar, /) -> _ScaledLinearOperator: ... + def dot(self, x: LinearOperator | npt.ArrayLike, /) -> _ProductLinearOperator | _ScaledLinearOperator | UntypedArray: ... + def __matmul__( + self, + other: LinearOperator | onpt.CanArray[tuple[int, ...], np.dtype[np.generic]], + /, + ) -> _ScaledLinearOperator | UntypedArray: ... + def __rmatmul__( + self, + other: LinearOperator | onpt.CanArray[tuple[int, ...], np.dtype[np.generic]], + /, + ) -> _ScaledLinearOperator | UntypedArray: ... + def __rmul__(self, x: LinearOperator | npt.ArrayLike, /) -> Untyped: ... + def __pow__(self, p: spt.AnyScalar, /) -> _PowerLinearOperator: ... + def __add__(self, x: LinearOperator, /) -> _SumLinearOperator: ... + def __neg__(self, /) -> _ScaledLinearOperator: ... + def __sub__(self, x: LinearOperator, /) -> _SumLinearOperator: ... + def adjoint(self) -> _AdjointLinearOperator: ... + @property + def H(self) -> _AdjointLinearOperator: ... + def transpose(self) -> _TransposedLinearOperator: ... + @property + def T(self) -> _TransposedLinearOperator: ... class _CustomLinearOperator(LinearOperator): args: Untyped @@ -48,43 +61,41 @@ class _CustomLinearOperator(LinearOperator): ): ... class _AdjointLinearOperator(LinearOperator): - A: Untyped - args: Untyped - def __init__(self, A) -> None: ... + A: LinearOperator + args: tuple[LinearOperator] + def __init__(self, A: LinearOperator) -> None: ... class _TransposedLinearOperator(LinearOperator): - A: Untyped - args: Untyped - def __init__(self, A) -> None: ... + A: LinearOperator + args: tuple[LinearOperator] + def __init__(self, A: LinearOperator) -> None: ... class _SumLinearOperator(LinearOperator): - args: Untyped - def __init__(self, A, B) -> None: ... + args: tuple[LinearOperator, LinearOperator] + def __init__(self, A: LinearOperator, B: LinearOperator) -> None: ... class _ProductLinearOperator(LinearOperator): - args: Untyped - def __init__(self, A, B) -> None: ... + args: tuple[LinearOperator, LinearOperator] + def __init__(self, A: LinearOperator, B: LinearOperator) -> None: ... class _ScaledLinearOperator(LinearOperator): - args: Untyped - def __init__(self, A, alpha) -> None: ... + args: tuple[LinearOperator, spt.AnyScalar] + def __init__(self, A: LinearOperator, alpha: spt.AnyScalar) -> None: ... class _PowerLinearOperator(LinearOperator): - args: Untyped - def __init__(self, A, p) -> None: ... + args: tuple[LinearOperator, spt.AnyInt] + def __init__(self, A: LinearOperator, p: spt.AnyInt) -> None: ... class MatrixLinearOperator(LinearOperator): - A: Untyped - args: Untyped - def __init__(self, A) -> None: ... + A: LinearOperator + args: tuple[LinearOperator] + def __init__(self, A: LinearOperator) -> None: ... class _AdjointMatrixOperator(MatrixLinearOperator): - A: Untyped - args: Untyped - shape: Untyped - def __init__(self, adjoint) -> None: ... - @property - def dtype(self) -> Untyped: ... + A: LinearOperator + args: tuple[LinearOperator] + shape: tuple[int, int] + def __init__(self, adjoint: LinearOperator) -> None: ... class IdentityOperator(LinearOperator): def __init__(self, shape, dtype: Untyped | None = None): ... diff --git a/scipy-stubs/sparse/linalg/_isolve/_gcrotmk.pyi b/scipy-stubs/sparse/linalg/_isolve/_gcrotmk.pyi index 1fd97414..9001e831 100644 --- a/scipy-stubs/sparse/linalg/_isolve/_gcrotmk.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/_gcrotmk.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.linalg import ( get_blas_funcs as get_blas_funcs, lstsq as lstsq, diff --git a/scipy-stubs/sparse/linalg/_isolve/iterative.pyi b/scipy-stubs/sparse/linalg/_isolve/iterative.pyi index 7615036b..eb9c1bf9 100644 --- a/scipy-stubs/sparse/linalg/_isolve/iterative.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/iterative.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.linalg import get_lapack_funcs as get_lapack_funcs from scipy.sparse.linalg._interface import LinearOperator as LinearOperator from .utils import make_system as make_system diff --git a/scipy-stubs/sparse/linalg/_isolve/lgmres.pyi b/scipy-stubs/sparse/linalg/_isolve/lgmres.pyi index a779f2e6..9ebee379 100644 --- a/scipy-stubs/sparse/linalg/_isolve/lgmres.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/lgmres.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.linalg import get_blas_funcs as get_blas_funcs from .utils import make_system as make_system diff --git a/scipy-stubs/sparse/linalg/_isolve/lsmr.pyi b/scipy-stubs/sparse/linalg/_isolve/lsmr.pyi index 4ef60c2b..0d27aa74 100644 --- a/scipy-stubs/sparse/linalg/_isolve/lsmr.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/lsmr.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse.linalg._interface import aslinearoperator as aslinearoperator def lsmr( diff --git a/scipy-stubs/sparse/linalg/_isolve/lsqr.pyi b/scipy-stubs/sparse/linalg/_isolve/lsqr.pyi index 19ab402a..ac0510d7 100644 --- a/scipy-stubs/sparse/linalg/_isolve/lsqr.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/lsqr.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse._sputils import convert_pydata_sparse_to_scipy as convert_pydata_sparse_to_scipy from scipy.sparse.linalg._interface import aslinearoperator as aslinearoperator diff --git a/scipy-stubs/sparse/linalg/_isolve/minres.pyi b/scipy-stubs/sparse/linalg/_isolve/minres.pyi index 5fc13895..683bf473 100644 --- a/scipy-stubs/sparse/linalg/_isolve/minres.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/minres.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from .utils import make_system as make_system def minres( diff --git a/scipy-stubs/sparse/linalg/_isolve/tfqmr.pyi b/scipy-stubs/sparse/linalg/_isolve/tfqmr.pyi index eb9b6d64..26c1bb36 100644 --- a/scipy-stubs/sparse/linalg/_isolve/tfqmr.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/tfqmr.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from .utils import make_system as make_system def tfqmr( diff --git a/scipy-stubs/sparse/linalg/_isolve/utils.pyi b/scipy-stubs/sparse/linalg/_isolve/utils.pyi index 34800740..fc85bdf3 100644 --- a/scipy-stubs/sparse/linalg/_isolve/utils.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/utils.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse.linalg._interface import ( IdentityOperator as IdentityOperator, LinearOperator as LinearOperator, diff --git a/scipy-stubs/sparse/linalg/_matfuncs.pyi b/scipy-stubs/sparse/linalg/_matfuncs.pyi index cf913739..481ce62d 100644 --- a/scipy-stubs/sparse/linalg/_matfuncs.pyi +++ b/scipy-stubs/sparse/linalg/_matfuncs.pyi @@ -1,31 +1,19 @@ +from typing import Final + from scipy._typing import Untyped +from scipy.sparse.linalg._interface import LinearOperator -from scipy.linalg._basic import solve as solve, solve_triangular as solve_triangular -from scipy.sparse._base import issparse as issparse -from scipy.sparse._construct import eye as eye -from scipy.sparse._sputils import is_pydata_spmatrix as is_pydata_spmatrix, isintlike as isintlike -from scipy.sparse.linalg import spsolve as spsolve -from scipy.sparse.linalg._interface import LinearOperator as LinearOperator +__all__ = ["expm", "inv", "matrix_power"] -UPPER_TRIANGULAR: str +UPPER_TRIANGULAR: Final = "upper_triangular" def inv(A) -> Untyped: ... class MatrixPowerOperator(LinearOperator): - dtype: Untyped - ndim: Untyped - shape: Untyped def __init__(self, A, p, structure: Untyped | None = None): ... - @property - def T(self) -> Untyped: ... class ProductOperator(LinearOperator): - shape: Untyped - ndim: Untyped - dtype: Untyped def __init__(self, *args, **kwargs) -> None: ... - @property - def T(self) -> Untyped: ... class _ExpmPadeHelper: A: Untyped diff --git a/scipy-stubs/sparse/linalg/_norm.pyi b/scipy-stubs/sparse/linalg/_norm.pyi index 3ebcefa6..510ddec7 100644 --- a/scipy-stubs/sparse/linalg/_norm.pyi +++ b/scipy-stubs/sparse/linalg/_norm.pyi @@ -1,7 +1,5 @@ from scipy._typing import Untyped -from scipy.sparse import issparse as issparse -from scipy.sparse._sputils import convert_pydata_sparse_to_scipy as convert_pydata_sparse_to_scipy -from scipy.sparse.linalg import svds as svds +__all__ = ["norm"] def norm(x, ord: Untyped | None = None, axis: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/sparse/linalg/_onenormest.pyi b/scipy-stubs/sparse/linalg/_onenormest.pyi index 98a33ea0..049a3484 100644 --- a/scipy-stubs/sparse/linalg/_onenormest.pyi +++ b/scipy-stubs/sparse/linalg/_onenormest.pyi @@ -1,6 +1,6 @@ from scipy._typing import Untyped -from scipy.sparse.linalg import aslinearoperator as aslinearoperator +__all__ = ["onenormest"] def onenormest(A, t: int = 2, itmax: int = 5, compute_v: bool = False, compute_w: bool = False) -> Untyped: ... def sign_round_up(X) -> Untyped: ... diff --git a/scipy-stubs/sparse/linalg/_special_sparse_arrays.pyi b/scipy-stubs/sparse/linalg/_special_sparse_arrays.pyi index 0aeef1a7..7025ea5b 100644 --- a/scipy-stubs/sparse/linalg/_special_sparse_arrays.pyi +++ b/scipy-stubs/sparse/linalg/_special_sparse_arrays.pyi @@ -1,7 +1,7 @@ from scipy._typing import Untyped +from scipy.sparse.linalg import LinearOperator -from scipy.sparse import dia_array as dia_array, eye as eye, kron as kron -from scipy.sparse.linalg import LinearOperator as LinearOperator +__all__ = ["LaplacianNd"] class LaplacianNd(LinearOperator): grid_shape: Untyped @@ -14,7 +14,6 @@ class LaplacianNd(LinearOperator): class Sakurai(LinearOperator): n: Untyped - dtype: Untyped def __init__(self, n, dtype=...) -> None: ... def eigenvalues(self, m: Untyped | None = None) -> Untyped: ... def tobanded(self) -> Untyped: ... @@ -22,16 +21,12 @@ class Sakurai(LinearOperator): def toarray(self) -> Untyped: ... class MikotaM(LinearOperator): - shape: Untyped - dtype: Untyped def __init__(self, shape, dtype=...) -> None: ... def tobanded(self) -> Untyped: ... def tosparse(self) -> Untyped: ... def toarray(self) -> Untyped: ... class MikotaK(LinearOperator): - shape: Untyped - dtype: Untyped def __init__(self, shape, dtype=...) -> None: ... def tobanded(self) -> Untyped: ... def tosparse(self) -> Untyped: ... diff --git a/scipy-stubs/sparse/linalg/_svdp.pyi b/scipy-stubs/sparse/linalg/_svdp.pyi index e4264c78..a2fa779d 100644 --- a/scipy-stubs/sparse/linalg/_svdp.pyi +++ b/scipy-stubs/sparse/linalg/_svdp.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import check_random_state as check_random_state +from scipy._typing import Untyped from scipy.linalg import LinAlgError as LinAlgError from scipy.sparse.linalg import aslinearoperator as aslinearoperator diff --git a/scipy-stubs/spatial/__init__.pyi b/scipy-stubs/spatial/__init__.pyi index 9611d765..7b902e35 100644 --- a/scipy-stubs/spatial/__init__.pyi +++ b/scipy-stubs/spatial/__init__.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._testutils import PytestTester as PytestTester +from scipy._typing import Untyped from . import ckdtree as ckdtree, distance as distance, kdtree as kdtree, qhull as qhull, transform as transform from ._ckdtree import * from ._geometric_slerp import geometric_slerp as geometric_slerp diff --git a/scipy-stubs/spatial/_ckdtree.pyi b/scipy-stubs/spatial/_ckdtree.pyi index 7db485a3..fa084fc2 100644 --- a/scipy-stubs/spatial/_ckdtree.pyi +++ b/scipy-stubs/spatial/_ckdtree.pyi @@ -1,15 +1,16 @@ +# NOTE: There are alteady inline stubs for this module, so this won't be used (which is unfortunate, because the inline +# annotations are wrong in several places, although it's still pretty good overall). from typing import Any, Generic, Literal, TypeAlias, TypeVar, overload import numpy as np - import numpy.typing as npt from scipy._typing import AnyScalar - from scipy.sparse import coo_matrix, dok_matrix __all__ = ["cKDTree"] _Weights: TypeAlias = npt.ArrayLike | tuple[npt.ArrayLike, npt.ArrayLike] +_BoxT = TypeVar("_BoxT", bound=npt.NDArray[np.float64] | None) class cKDTreeNode: @property @@ -35,8 +36,6 @@ class cKDTreeNode: @property def greater(self) -> cKDTreeNode | None: ... -_BoxT = TypeVar("_BoxT", bound=npt.NDArray[np.float64] | None) - class cKDTree(Generic[_BoxT]): @property def n(self) -> int: ... @@ -158,7 +157,7 @@ class cKDTree(Generic[_BoxT]): p: float = ..., weights: None | tuple[None, None] = ..., cumulative: bool = ..., - ) -> np.intp | npt.NDArray[np.intp]: ... + ) -> np.float64 | np.intp | npt.NDArray[np.intp]: ... @overload def count_neighbors( self, @@ -167,7 +166,7 @@ class cKDTree(Generic[_BoxT]): p: float = ..., weights: _Weights = ..., cumulative: bool = ..., - ) -> np.float64 | npt.NDArray[np.float64]: ... + ) -> np.intp | np.float64 | npt.NDArray[np.float64]: ... @overload def sparse_distance_matrix( self, diff --git a/scipy-stubs/spatial/_geometric_slerp.pyi b/scipy-stubs/spatial/_geometric_slerp.pyi index ede39a42..e244a4f3 100644 --- a/scipy-stubs/spatial/_geometric_slerp.pyi +++ b/scipy-stubs/spatial/_geometric_slerp.pyi @@ -1,7 +1,6 @@ -import numpy as np - import numpy.typing as npt +import scipy._typing as spt -from scipy.spatial.distance import euclidean as euclidean +__all__ = ["geometric_slerp"] -def geometric_slerp(start: npt.ArrayLike, end: npt.ArrayLike, t: npt.ArrayLike, tol: float = 1e-07) -> np.ndarray: ... +def geometric_slerp(start: npt.ArrayLike, end: npt.ArrayLike, t: npt.ArrayLike, tol: float = 1e-07) -> spt.UntypedArray: ... diff --git a/scipy-stubs/spatial/_kdtree.pyi b/scipy-stubs/spatial/_kdtree.pyi index a1546ab8..6d30994a 100644 --- a/scipy-stubs/spatial/_kdtree.pyi +++ b/scipy-stubs/spatial/_kdtree.pyi @@ -1,16 +1,14 @@ from typing import TypeVar +from typing_extensions import override import numpy as np - import numpy.typing as npt from scipy._typing import Untyped - -from ._ckdtree import cKDTree as cKDTree, cKDTreeNode as cKDTreeNode +from ._ckdtree import cKDTree, cKDTreeNode __all__ = ["KDTree", "Rectangle", "distance_matrix", "minkowski_distance", "minkowski_distance_p"] -def minkowski_distance_p(x, y, p: int = 2) -> Untyped: ... -def minkowski_distance(x, y, p: int = 2) -> Untyped: ... +_BoxT = TypeVar("_BoxT", bound=npt.NDArray[np.float64] | None) class Rectangle: maxes: Untyped @@ -23,16 +21,15 @@ class Rectangle: def min_distance_rectangle(self, other: Rectangle, p: float = 2.0) -> Untyped: ... def max_distance_rectangle(self, other: Rectangle, p: float = 2.0) -> Untyped: ... -_BoxT = TypeVar("_BoxT", bound=npt.NDArray[np.float64] | None) - class KDTree(cKDTree[_BoxT]): class node: - def __init__(self, ckdtree_node: Untyped | None = None): ... - def __lt__(self, other: node) -> Untyped: ... - def __gt__(self, other: node) -> Untyped: ... - def __le__(self, other: node) -> Untyped: ... - def __ge__(self, other: node) -> Untyped: ... - def __eq__(self, other: node) -> Untyped: ... + def __init__(self, ckdtree_node: Untyped | None = None) -> None: ... + @override + def __eq__(self, other: object, /) -> bool: ... + def __lt__(self, other: object, /) -> bool: ... + def __gt__(self, other: object, /) -> bool: ... + def __le__(self, other: object, /) -> bool: ... + def __ge__(self, other: object, /) -> bool: ... class leafnode(node): @property @@ -43,7 +40,7 @@ class KDTree(cKDTree[_BoxT]): class innernode(node): less: Untyped greater: Untyped - def __init__(self, ckdtreenode) -> None: ... + def __init__(self, ckdtreenode: cKDTreeNode) -> None: ... @property def split_dim(self) -> Untyped: ... @property @@ -51,4 +48,6 @@ class KDTree(cKDTree[_BoxT]): @property def children(self) -> Untyped: ... -def distance_matrix(x, y, p: int = 2, threshold: int = 1000000) -> Untyped: ... +def minkowski_distance_p(x: npt.ArrayLike, y: npt.ArrayLike, p: int = 2) -> Untyped: ... +def minkowski_distance(x: npt.ArrayLike, y: npt.ArrayLike, p: int = 2) -> Untyped: ... +def distance_matrix(x: npt.ArrayLike, y: npt.ArrayLike, p: int = 2, threshold: int = 1000000) -> Untyped: ... diff --git a/scipy-stubs/spatial/_procrustes.pyi b/scipy-stubs/spatial/_procrustes.pyi index 710bc82c..d8003350 100644 --- a/scipy-stubs/spatial/_procrustes.pyi +++ b/scipy-stubs/spatial/_procrustes.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.linalg import orthogonal_procrustes as orthogonal_procrustes def procrustes(data1, data2) -> Untyped: ... diff --git a/scipy-stubs/spatial/_qhull.pyi b/scipy-stubs/spatial/_qhull.pyi index f3842cf8..641e6222 100644 --- a/scipy-stubs/spatial/_qhull.pyi +++ b/scipy-stubs/spatial/_qhull.pyi @@ -2,7 +2,6 @@ from typing import Any, TypeAlias from typing_extensions import final import numpy as np - import numpy.typing as npt __all__ = ["ConvexHull", "Delaunay", "HalfspaceIntersection", "QhullError", "Voronoi", "tsearch"] diff --git a/scipy-stubs/spatial/_spherical_voronoi.pyi b/scipy-stubs/spatial/_spherical_voronoi.pyi index 72f84df1..2e218d3d 100644 --- a/scipy-stubs/spatial/_spherical_voronoi.pyi +++ b/scipy-stubs/spatial/_spherical_voronoi.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.spatial import cKDTree as cKDTree def calculate_solid_angles(R) -> Untyped: ... diff --git a/scipy-stubs/spatial/_voronoi.pyi b/scipy-stubs/spatial/_voronoi.pyi index 329eaac8..2b9d8e27 100644 --- a/scipy-stubs/spatial/_voronoi.pyi +++ b/scipy-stubs/spatial/_voronoi.pyi @@ -1,5 +1,4 @@ import numpy as np - import numpy.typing as npt __all__ = ["sort_vertices_of_regions"] diff --git a/scipy-stubs/spatial/distance.pyi b/scipy-stubs/spatial/distance.pyi index e1472f29..87a05206 100644 --- a/scipy-stubs/spatial/distance.pyi +++ b/scipy-stubs/spatial/distance.pyi @@ -1,7 +1,6 @@ from typing import Any, Literal, Protocol, SupportsFloat, SupportsIndex, TypeAlias, overload, type_check_only import numpy as np - import numpy.typing as npt __all__ = [ diff --git a/scipy-stubs/spatial/transform/_rotation.pyi b/scipy-stubs/spatial/transform/_rotation.pyi index f35b1f8f..83bb7cce 100644 --- a/scipy-stubs/spatial/transform/_rotation.pyi +++ b/scipy-stubs/spatial/transform/_rotation.pyi @@ -2,7 +2,6 @@ from collections.abc import Sequence from typing import Any, TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["Rotation", "Slerp"] diff --git a/scipy-stubs/spatial/transform/_rotation_spline.pyi b/scipy-stubs/spatial/transform/_rotation_spline.pyi index ba51057e..cc86cbd5 100644 --- a/scipy-stubs/spatial/transform/_rotation_spline.pyi +++ b/scipy-stubs/spatial/transform/_rotation_spline.pyi @@ -1,7 +1,5 @@ import numpy as np - import numpy.typing as npt - from scipy.interpolate import PPoly from ._rotation import Rotation diff --git a/scipy-stubs/special/_basic.pyi b/scipy-stubs/special/_basic.pyi index b7944aae..12328e30 100644 --- a/scipy-stubs/special/_basic.pyi +++ b/scipy-stubs/special/_basic.pyi @@ -1,11 +1,9 @@ from typing import Literal import numpy as np -from numpy import sinc # noqa: ICN003 - import numpy.typing as npt +from numpy import sinc # noqa: ICN003 from scipy._typing import Untyped - from ._ufuncs import psi as digamma __all__ = [ diff --git a/scipy-stubs/special/_ellip_harm.pyi b/scipy-stubs/special/_ellip_harm.pyi index 3aafe563..723da99c 100644 --- a/scipy-stubs/special/_ellip_harm.pyi +++ b/scipy-stubs/special/_ellip_harm.pyi @@ -1,7 +1,6 @@ from typing import Literal import numpy as np - import scipy._typing as spt __all__ = ["ellip_harm", "ellip_harm_2", "ellip_normal"] diff --git a/scipy-stubs/special/_lambertw.pyi b/scipy-stubs/special/_lambertw.pyi index c27ee1a1..74db161b 100644 --- a/scipy-stubs/special/_lambertw.pyi +++ b/scipy-stubs/special/_lambertw.pyi @@ -1,5 +1,4 @@ import numpy as np - import numpy.typing as npt __all__ = ["lambertw"] diff --git a/scipy-stubs/special/_logsumexp.pyi b/scipy-stubs/special/_logsumexp.pyi index 5c14296a..ea791761 100644 --- a/scipy-stubs/special/_logsumexp.pyi +++ b/scipy-stubs/special/_logsumexp.pyi @@ -1,5 +1,4 @@ import numpy as np - import numpy.typing as npt __all__ = ["log_softmax", "logsumexp", "softmax"] diff --git a/scipy-stubs/special/_orthogonal.pyi b/scipy-stubs/special/_orthogonal.pyi index d161cbdb..adc946d6 100644 --- a/scipy-stubs/special/_orthogonal.pyi +++ b/scipy-stubs/special/_orthogonal.pyi @@ -2,7 +2,6 @@ from collections.abc import Callable from typing import Literal, TypeAlias, overload import numpy as np - import numpy.typing as npt import scipy._typing as spt diff --git a/scipy-stubs/special/_spfun_stats.pyi b/scipy-stubs/special/_spfun_stats.pyi index ad83e097..4280fb8a 100644 --- a/scipy-stubs/special/_spfun_stats.pyi +++ b/scipy-stubs/special/_spfun_stats.pyi @@ -1,5 +1,4 @@ import numpy as np - import numpy.typing as npt __all__ = ["multigammaln"] diff --git a/scipy-stubs/special/_spherical_bessel.pyi b/scipy-stubs/special/_spherical_bessel.pyi index 18d834be..a273fcfa 100644 --- a/scipy-stubs/special/_spherical_bessel.pyi +++ b/scipy-stubs/special/_spherical_bessel.pyi @@ -1,7 +1,6 @@ from typing import TypeAlias import numpy as np - import numpy.typing as npt __all__ = ["spherical_in", "spherical_jn", "spherical_kn", "spherical_yn"] diff --git a/scipy-stubs/stats/_binned_statistic.pyi b/scipy-stubs/stats/_binned_statistic.pyi index 581bcb38..b17e70d0 100644 --- a/scipy-stubs/stats/_binned_statistic.pyi +++ b/scipy-stubs/stats/_binned_statistic.pyi @@ -2,7 +2,6 @@ from collections.abc import Callable, Sequence from typing import Literal, NamedTuple, TypeAlias import numpy as np - import numpy.typing as npt from scipy._typing import Untyped diff --git a/scipy-stubs/stats/_bws_test.pyi b/scipy-stubs/stats/_bws_test.pyi index d0173807..fe3637e6 100644 --- a/scipy-stubs/stats/_bws_test.pyi +++ b/scipy-stubs/stats/_bws_test.pyi @@ -1,7 +1,6 @@ from typing import Literal import numpy.typing as npt - from ._resampling import PermutationMethod, PermutationTestResult __all__ = ["bws_test"] diff --git a/scipy-stubs/stats/_covariance.pyi b/scipy-stubs/stats/_covariance.pyi index ae0672cc..2aae1422 100644 --- a/scipy-stubs/stats/_covariance.pyi +++ b/scipy-stubs/stats/_covariance.pyi @@ -3,7 +3,6 @@ from typing import Any, Final, Generic, Protocol, TypeAlias, overload, type_chec from typing_extensions import TypeVar import numpy as np - import numpy.typing as npt import optype.numpy as onpt diff --git a/scipy-stubs/stats/_crosstab.pyi b/scipy-stubs/stats/_crosstab.pyi index eeb0ac6f..227a0239 100644 --- a/scipy-stubs/stats/_crosstab.pyi +++ b/scipy-stubs/stats/_crosstab.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.sparse import coo_matrix as coo_matrix CrosstabResult: Untyped diff --git a/scipy-stubs/stats/_distn_infrastructure.pyi b/scipy-stubs/stats/_distn_infrastructure.pyi index f887b347..94d63c26 100644 --- a/scipy-stubs/stats/_distn_infrastructure.pyi +++ b/scipy-stubs/stats/_distn_infrastructure.pyi @@ -1,11 +1,9 @@ import abc - from collections.abc import Callable, Iterable, Sequence from typing import Any, Final, Generic, Literal, TypeAlias, overload, type_check_only from typing_extensions import LiteralString, Self, TypeVar, Unpack, override import numpy as np - import numpy.typing as npt import optype.numpy as onpt import scipy._typing as spt diff --git a/scipy-stubs/stats/_entropy.pyi b/scipy-stubs/stats/_entropy.pyi index f2c9ec54..cbca04d4 100644 --- a/scipy-stubs/stats/_entropy.pyi +++ b/scipy-stubs/stats/_entropy.pyi @@ -4,7 +4,6 @@ from typing import Any, Literal import numpy as np - import numpy.typing as npt __all__ = ["differential_entropy", "entropy"] diff --git a/scipy-stubs/stats/_fit.pyi b/scipy-stubs/stats/_fit.pyi index 7c82658b..ce6950a6 100644 --- a/scipy-stubs/stats/_fit.pyi +++ b/scipy-stubs/stats/_fit.pyi @@ -1,9 +1,8 @@ from typing import NamedTuple -from scipy._typing import Untyped - from scipy import optimize as optimize, stats as stats from scipy._lib._util import check_random_state as check_random_state +from scipy._typing import Untyped class FitResult: discrete: Untyped diff --git a/scipy-stubs/stats/_hypotests.pyi b/scipy-stubs/stats/_hypotests.pyi index d590c002..38e1a53c 100644 --- a/scipy-stubs/stats/_hypotests.pyi +++ b/scipy-stubs/stats/_hypotests.pyi @@ -1,56 +1,59 @@ from dataclasses import dataclass - from typing import NamedTuple import numpy as np - -from scipy._typing import Untyped - -from scipy.fft import ifft as ifft -from scipy.optimize import shgo as shgo -from scipy.special import gamma as gamma, gammaln as gammaln, kv as kv +from scipy._typing import Untyped, UntypedArray from . import distributions as distributions from ._common import ConfidenceInterval as ConfidenceInterval from ._continuous_distns import norm as norm -class Epps_Singleton_2sampResult(NamedTuple): - statistic: Untyped - pvalue: Untyped +__all__ = [ + "barnard_exact", + "boschloo_exact", + "cramervonmises", + "cramervonmises_2samp", + "epps_singleton_2samp", + "poisson_means_test", + "somersd", + "tukey_hsd", +] -def epps_singleton_2samp(x, y, t=(0.4, 0.8)) -> Untyped: ... -def poisson_means_test(k1, n1, k2, n2, *, diff: int = 0, alternative: str = "two-sided") -> Untyped: ... - -class CramerVonMisesResult: +class Epps_Singleton_2sampResult(NamedTuple): statistic: Untyped pvalue: Untyped - def __init__(self, statistic, pvalue) -> None: ... -def cramervonmises(rvs, cdf, args=()) -> Untyped: ... @dataclass class SomersDResult: statistic: float pvalue: float - table: np.ndarray + table: UntypedArray -def somersd(x, y: Untyped | None = None, alternative: str = "two-sided") -> Untyped: ... @dataclass class BarnardExactResult: statistic: float pvalue: float -def barnard_exact(table, alternative: str = "two-sided", pooled: bool = True, n: int = 32) -> Untyped: ... @dataclass class BoschlooExactResult: statistic: float pvalue: float -def boschloo_exact(table, alternative: str = "two-sided", n: int = 32) -> Untyped: ... -def cramervonmises_2samp(x, y, method: str = "auto") -> Untyped: ... - class TukeyHSDResult: statistic: Untyped pvalue: Untyped def __init__(self, statistic, pvalue, _nobs, _ntreatments, _stand_err) -> None: ... def confidence_interval(self, confidence_level: float = 0.95) -> Untyped: ... +class CramerVonMisesResult: + statistic: Untyped + pvalue: Untyped + def __init__(self, statistic, pvalue) -> None: ... + +def epps_singleton_2samp(x, y, t=(0.4, 0.8)) -> Untyped: ... +def poisson_means_test(k1, n1, k2, n2, *, diff: int = 0, alternative: str = "two-sided") -> Untyped: ... +def cramervonmises(rvs, cdf, args=()) -> Untyped: ... +def somersd(x, y: Untyped | None = None, alternative: str = "two-sided") -> Untyped: ... +def barnard_exact(table, alternative: str = "two-sided", pooled: bool = True, n: int = 32) -> Untyped: ... +def boschloo_exact(table, alternative: str = "two-sided", n: int = 32) -> Untyped: ... +def cramervonmises_2samp(x, y, method: str = "auto") -> Untyped: ... def tukey_hsd(*args) -> Untyped: ... diff --git a/scipy-stubs/stats/_levy_stable.pyi b/scipy-stubs/stats/_levy_stable.pyi index 969023d3..43d97022 100644 --- a/scipy-stubs/stats/_levy_stable.pyi +++ b/scipy-stubs/stats/_levy_stable.pyi @@ -2,9 +2,7 @@ from collections.abc import Callable from typing import Final import numpy as np - import numpy.typing as npt - from ._distn_infrastructure import rv_continuous __all__ = ["levy_stable", "levy_stable_gen", "pdf_from_cf_with_fft"] diff --git a/scipy-stubs/stats/_mannwhitneyu.pyi b/scipy-stubs/stats/_mannwhitneyu.pyi index 96687ad3..a16945e1 100644 --- a/scipy-stubs/stats/_mannwhitneyu.pyi +++ b/scipy-stubs/stats/_mannwhitneyu.pyi @@ -1,8 +1,7 @@ from typing import NamedTuple -from scipy._typing import Untyped - from scipy import special as special, stats as stats +from scipy._typing import Untyped class _MWU: def __init__(self, n1, n2) -> None: ... diff --git a/scipy-stubs/stats/_mgc.pyi b/scipy-stubs/stats/_mgc.pyi index b2eece33..2d7a516a 100644 --- a/scipy-stubs/stats/_mgc.pyi +++ b/scipy-stubs/stats/_mgc.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy._lib._util import MapWrapper as MapWrapper, check_random_state as check_random_state, rng_integers as rng_integers +from scipy._typing import Untyped from scipy.spatial.distance import cdist as cdist from . import distributions as distributions diff --git a/scipy-stubs/stats/_mstats_basic.pyi b/scipy-stubs/stats/_mstats_basic.pyi index b72a636b..9af1ce10 100644 --- a/scipy-stubs/stats/_mstats_basic.pyi +++ b/scipy-stubs/stats/_mstats_basic.pyi @@ -1,7 +1,6 @@ from typing import NamedTuple from scipy._typing import Untyped - from . import distributions as distributions def argstoarray(*args) -> Untyped: ... @@ -11,7 +10,7 @@ def rankdata(data, axis: Untyped | None = None, use_missing: bool = False) -> Un class ModeResult(NamedTuple): mode: Untyped - count: Untyped + count: Untyped # type: ignore[assignment] def mode(a, axis: int = 0) -> Untyped: ... def msign(x) -> Untyped: ... @@ -25,7 +24,12 @@ def spearmanr( alternative: str = "two-sided", ) -> Untyped: ... def kendalltau( - x, y, use_ties: bool = True, use_missing: bool = False, method: str = "auto", alternative: str = "two-sided" + x, + y, + use_ties: bool = True, + use_missing: bool = False, + method: str = "auto", + alternative: str = "two-sided", ) -> Untyped: ... def kendalltau_seasonal(x) -> Untyped: ... @@ -88,21 +92,39 @@ def trimr(a, limits: Untyped | None = None, inclusive=(True, True), axis: Untype trimdoc: str def trim( - a, limits: Untyped | None = None, inclusive=(True, True), relative: bool = False, axis: Untyped | None = None + a, + limits: Untyped | None = None, + inclusive=(True, True), + relative: bool = False, + axis: Untyped | None = None, ) -> Untyped: ... def trimboth(data, proportiontocut: float = 0.2, inclusive=(True, True), axis: Untyped | None = None) -> Untyped: ... def trimtail( - data, proportiontocut: float = 0.2, tail: str = "left", inclusive=(True, True), axis: Untyped | None = None + data, + proportiontocut: float = 0.2, + tail: str = "left", + inclusive=(True, True), + axis: Untyped | None = None, ) -> Untyped: ... trim1 = trimtail def trimmed_mean(a, limits=(0.1, 0.1), inclusive=(1, 1), relative: bool = True, axis: Untyped | None = None) -> Untyped: ... def trimmed_var( - a, limits=(0.1, 0.1), inclusive=(1, 1), relative: bool = True, axis: Untyped | None = None, ddof: int = 0 + a, + limits=(0.1, 0.1), + inclusive=(1, 1), + relative: bool = True, + axis: Untyped | None = None, + ddof: int = 0, ) -> Untyped: ... def trimmed_std( - a, limits=(0.1, 0.1), inclusive=(1, 1), relative: bool = True, axis: Untyped | None = None, ddof: int = 0 + a, + limits=(0.1, 0.1), + inclusive=(1, 1), + relative: bool = True, + axis: Untyped | None = None, + ddof: int = 0, ) -> Untyped: ... def trimmed_stde(a, limits=(0.1, 0.1), inclusive=(1, 1), axis: Untyped | None = None) -> Untyped: ... def tmean(a, limits: Untyped | None = None, inclusive=(True, True), axis: Untyped | None = None) -> Untyped: ... @@ -152,7 +174,12 @@ class NormaltestResult(NamedTuple): def normaltest(a, axis: int = 0) -> Untyped: ... def mquantiles( - a, prob=(0.25, 0.5, 0.75), alphap: float = 0.4, betap: float = 0.4, axis: Untyped | None = None, limit=() + a, + prob=(0.25, 0.5, 0.75), + alphap: float = 0.4, + betap: float = 0.4, + axis: Untyped | None = None, + limit=(), ) -> Untyped: ... def scoreatpercentile(data, per, limit=(), alphap: float = 0.4, betap: float = 0.4) -> Untyped: ... def plotting_positions(data, alpha: float = 0.4, beta: float = 0.4) -> Untyped: ... diff --git a/scipy-stubs/stats/_mstats_extras.pyi b/scipy-stubs/stats/_mstats_extras.pyi index 5b3d8e7e..e3645fe8 100644 --- a/scipy-stubs/stats/_mstats_extras.pyi +++ b/scipy-stubs/stats/_mstats_extras.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.stats.distributions import beta as beta, binom as binom, norm as norm, t as t def hdquantiles(data, prob=(0.25, 0.5, 0.75), axis: Untyped | None = None, var: bool = False) -> Untyped: ... diff --git a/scipy-stubs/stats/_multicomp.pyi b/scipy-stubs/stats/_multicomp.pyi index 2406c4b1..a9d23150 100644 --- a/scipy-stubs/stats/_multicomp.pyi +++ b/scipy-stubs/stats/_multicomp.pyi @@ -1,21 +1,18 @@ from dataclasses import dataclass - from typing import Literal import numpy as np - import numpy.typing as npt - from scipy import stats as stats from scipy._lib._util import DecimalNumber as DecimalNumber, SeedType as SeedType -from scipy.optimize import minimize_scalar as minimize_scalar from scipy.stats._common import ConfidenceInterval as ConfidenceInterval -from scipy.stats._qmc import check_random_state as check_random_state + +__all__ = ["dunnett"] @dataclass class DunnettResult: - statistic: np.ndarray - pvalue: np.ndarray + statistic: npt.NDArray[np.float64] + pvalue: npt.NDArray[np.float64] def confidence_interval(self, confidence_level: DecimalNumber = 0.95) -> ConfidenceInterval: ... def dunnett( diff --git a/scipy-stubs/stats/_multivariate.pyi b/scipy-stubs/stats/_multivariate.pyi index 1893cbaa..27c77fe2 100644 --- a/scipy-stubs/stats/_multivariate.pyi +++ b/scipy-stubs/stats/_multivariate.pyi @@ -1,16 +1,13 @@ import abc - from collections.abc import Sequence from typing import Any, Final, Generic, Literal, TypeAlias, overload, type_check_only from typing_extensions import Self, TypeVar, override import numpy as np - import numpy.typing as npt import optype as op import optype.numpy as onpt import scipy._typing as spt - from scipy.stats import _covariance from ._covariance import Covariance from ._distn_infrastructure import _RNG, _Seed diff --git a/scipy-stubs/stats/_odds_ratio.pyi b/scipy-stubs/stats/_odds_ratio.pyi index 7e986b91..8f07b20a 100644 --- a/scipy-stubs/stats/_odds_ratio.pyi +++ b/scipy-stubs/stats/_odds_ratio.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.optimize import brentq as brentq from scipy.special import ndtri as ndtri from ._common import ConfidenceInterval as ConfidenceInterval diff --git a/scipy-stubs/stats/_page_trend_test.pyi b/scipy-stubs/stats/_page_trend_test.pyi index b4aa0d64..9dd17060 100644 --- a/scipy-stubs/stats/_page_trend_test.pyi +++ b/scipy-stubs/stats/_page_trend_test.pyi @@ -1,7 +1,6 @@ from dataclasses import dataclass from scipy._typing import Untyped - from ._continuous_distns import norm as norm @dataclass diff --git a/scipy-stubs/stats/_qmc.pyi b/scipy-stubs/stats/_qmc.pyi index 3abbde87..57d02ab6 100644 --- a/scipy-stubs/stats/_qmc.pyi +++ b/scipy-stubs/stats/_qmc.pyi @@ -1,36 +1,46 @@ from abc import ABC, abstractmethod - -from typing import ClassVar, Literal, overload +from typing import ClassVar, Literal, TypeVar, overload import numpy as np - import numpy.typing as npt -from scipy._typing import Untyped +from scipy._lib._util import DecimalNumber, IntNumber, SeedType +from scipy._typing import Untyped, UntypedArray + +__all__ = [ + "Halton", + "LatinHypercube", + "MultinomialQMC", + "MultivariateNormalQMC", + "PoissonDisk", + "QMCEngine", + "Sobol", + "discrepancy", + "geometric_discrepancy", + "scale", + "update_discrepancy", +] -from scipy._lib._util import ( - DecimalNumber as DecimalNumber, - GeneratorType as GeneratorType, - IntNumber as IntNumber, - SeedType as SeedType, - rng_integers as rng_integers, -) -from scipy.sparse.csgraph import minimum_spanning_tree as minimum_spanning_tree -from scipy.spatial import Voronoi as Voronoi, distance as distance -from scipy.special import gammainc as gammainc +_RNGT = TypeVar("_RNGT", bound=np.random.Generator | np.random.RandomState) @overload def check_random_state(seed: IntNumber | None = ...) -> np.random.Generator: ... @overload -def check_random_state(seed: GeneratorType) -> GeneratorType: ... -def scale(sample: npt.ArrayLike, l_bounds: npt.ArrayLike, u_bounds: npt.ArrayLike, *, reverse: bool = False) -> np.ndarray: ... +def check_random_state(seed: _RNGT) -> _RNGT: ... +def scale(sample: npt.ArrayLike, l_bounds: npt.ArrayLike, u_bounds: npt.ArrayLike, *, reverse: bool = False) -> UntypedArray: ... def discrepancy( - sample: npt.ArrayLike, *, iterative: bool = False, method: Literal["CD", "WD", "MD", "L2-star"] = "CD", workers: IntNumber = 1 + sample: npt.ArrayLike, + *, + iterative: bool = False, + method: Literal["CD", "WD", "MD", "L2-star"] = "CD", + workers: IntNumber = 1, ) -> float: ... def geometric_discrepancy( - sample: npt.ArrayLike, method: Literal["mindist", "mst"] = "mindist", metric: str = "euclidean" + sample: npt.ArrayLike, + method: Literal["mindist", "mst"] = "mindist", + metric: str = "euclidean", ) -> float: ... def update_discrepancy(x_new: npt.ArrayLike, sample: npt.ArrayLike, initial_disc: DecimalNumber) -> float: ... -def primes_from_2_to(n: int) -> np.ndarray: ... +def primes_from_2_to(n: int) -> UntypedArray: ... def n_primes(n: IntNumber) -> list[int]: ... def van_der_corput( n: IntNumber, @@ -41,7 +51,7 @@ def van_der_corput( permutations: npt.ArrayLike | None = None, seed: SeedType = None, workers: IntNumber = 1, -) -> np.ndarray: ... +) -> UntypedArray: ... class QMCEngine(ABC): d: Untyped @@ -51,9 +61,13 @@ class QMCEngine(ABC): optimization_method: Untyped @abstractmethod def __init__( - self, d: IntNumber, *, optimization: Literal["random-cd", "lloyd"] | None = None, seed: SeedType = None - ) -> Untyped: ... - def random(self, n: IntNumber = 1, *, workers: IntNumber = 1) -> np.ndarray: ... + self, + d: IntNumber, + *, + optimization: Literal["random-cd", "lloyd"] | None = None, + seed: SeedType = None, + ) -> None: ... + def random(self, n: IntNumber = 1, *, workers: IntNumber = 1) -> UntypedArray: ... def integers( self, l_bounds: npt.ArrayLike, @@ -62,7 +76,7 @@ class QMCEngine(ABC): n: IntNumber = 1, endpoint: bool = False, workers: IntNumber = 1, - ) -> np.ndarray: ... + ) -> UntypedArray: ... def reset(self) -> QMCEngine: ... def fast_forward(self, n: IntNumber) -> QMCEngine: ... @@ -106,7 +120,7 @@ class Sobol(QMCEngine): seed: SeedType = None, optimization: Literal["random-cd", "lloyd"] | None = None, ): ... - def random_base2(self, m: IntNumber) -> np.ndarray: ... + def random_base2(self, m: IntNumber) -> UntypedArray: ... def reset(self) -> Sobol: ... def fast_forward(self, n: IntNumber) -> Sobol: ... @@ -130,7 +144,7 @@ class PoissonDisk(QMCEngine): l_bounds: npt.ArrayLike | None = None, u_bounds: npt.ArrayLike | None = None, ): ... - def fill_space(self) -> np.ndarray: ... + def fill_space(self) -> UntypedArray: ... def reset(self) -> PoissonDisk: ... class MultivariateNormalQMC: @@ -145,11 +159,11 @@ class MultivariateNormalQMC: engine: QMCEngine | None = None, seed: SeedType = None, ): ... - def random(self, n: IntNumber = 1) -> np.ndarray: ... + def random(self, n: IntNumber = 1) -> UntypedArray: ... class MultinomialQMC: pvals: Untyped n_trials: Untyped engine: Untyped def __init__(self, pvals: npt.ArrayLike, n_trials: IntNumber, *, engine: QMCEngine | None = None, seed: SeedType = None): ... - def random(self, n: IntNumber = 1) -> np.ndarray: ... + def random(self, n: IntNumber = 1) -> UntypedArray: ... diff --git a/scipy-stubs/stats/_relative_risk.pyi b/scipy-stubs/stats/_relative_risk.pyi index 190b8f3f..4afd0153 100644 --- a/scipy-stubs/stats/_relative_risk.pyi +++ b/scipy-stubs/stats/_relative_risk.pyi @@ -1,7 +1,6 @@ from dataclasses import dataclass from scipy._typing import Untyped - from scipy.special import ndtri as ndtri from ._common import ConfidenceInterval as ConfidenceInterval diff --git a/scipy-stubs/stats/_resampling.pyi b/scipy-stubs/stats/_resampling.pyi index 73d4ffab..66790838 100644 --- a/scipy-stubs/stats/_resampling.pyi +++ b/scipy-stubs/stats/_resampling.pyi @@ -1,24 +1,50 @@ from dataclasses import dataclass -import numpy as np +from scipy._typing import Untyped, UntypedArray +from ._common import ConfidenceInterval -from scipy._typing import Untyped - -from scipy._lib._array_api import ( - array_namespace as array_namespace, - is_numpy as is_numpy, - xp_moveaxis_to_end as xp_moveaxis_to_end, -) -from scipy._lib._util import check_random_state as check_random_state, rng_integers as rng_integers -from scipy.special import comb as comb, factorial as factorial, ndtr as ndtr, ndtri as ndtri -from ._common import ConfidenceInterval as ConfidenceInterval -from ._warnings_errors import DegenerateDataWarning as DegenerateDataWarning +__all__ = ["bootstrap", "monte_carlo_test", "permutation_test"] @dataclass class BootstrapResult: confidence_interval: ConfidenceInterval - bootstrap_distribution: np.ndarray - standard_error: float | np.ndarray + bootstrap_distribution: UntypedArray + standard_error: float | UntypedArray + +@dataclass +class MonteCarloTestResult: + statistic: float | UntypedArray + pvalue: float | UntypedArray + null_distribution: UntypedArray + +@dataclass +class PowerResult: + power: float | UntypedArray + pvalues: float | UntypedArray + +@dataclass +class PermutationTestResult: + statistic: float | UntypedArray + pvalue: float | UntypedArray + null_distribution: UntypedArray + +@dataclass +class ResamplingMethod: + n_resamples: int = ... + batch: int = ... + +@dataclass +class MonteCarloMethod(ResamplingMethod): + rvs: Untyped = ... + +@dataclass +class PermutationMethod(ResamplingMethod): + random_state: Untyped = ... + +@dataclass +class BootstrapMethod(ResamplingMethod): + random_state: Untyped = ... + method: str = ... def bootstrap( data, @@ -35,12 +61,6 @@ def bootstrap( bootstrap_result: Untyped | None = None, random_state: Untyped | None = None, ) -> Untyped: ... -@dataclass -class MonteCarloTestResult: - statistic: float | np.ndarray - pvalue: float | np.ndarray - null_distribution: np.ndarray - def monte_carlo_test( data, rvs, @@ -52,11 +72,6 @@ def monte_carlo_test( alternative: str = "two-sided", axis: int = 0, ) -> Untyped: ... -@dataclass -class PowerResult: - power: float | np.ndarray - pvalues: float | np.ndarray - def power( test, rvs, @@ -68,12 +83,6 @@ def power( batch: Untyped | None = None, kwargs: Untyped | None = None, ) -> Untyped: ... -@dataclass -class PermutationTestResult: - statistic: float | np.ndarray - pvalue: float | np.ndarray - null_distribution: np.ndarray - def permutation_test( data, statistic, @@ -86,20 +95,3 @@ def permutation_test( axis: int = 0, random_state: Untyped | None = None, ) -> Untyped: ... -@dataclass -class ResamplingMethod: - n_resamples: int = ... - batch: int = ... - -@dataclass -class MonteCarloMethod(ResamplingMethod): - rvs: object = ... - -@dataclass -class PermutationMethod(ResamplingMethod): - random_state: object = ... - -@dataclass -class BootstrapMethod(ResamplingMethod): - random_state: object = ... - method: str = ... diff --git a/scipy-stubs/stats/_sampling.pyi b/scipy-stubs/stats/_sampling.pyi index a4180711..98b3901d 100644 --- a/scipy-stubs/stats/_sampling.pyi +++ b/scipy-stubs/stats/_sampling.pyi @@ -1,7 +1,6 @@ -from scipy._typing import Untyped - from scipy import stats as stats from scipy._lib._util import check_random_state as check_random_state +from scipy._typing import Untyped from ._qmc import Halton as Halton, QMCEngine as QMCEngine __all__ = ["FastGeneratorInversion", "RatioUniforms"] diff --git a/scipy-stubs/stats/_sensitivity_analysis.pyi b/scipy-stubs/stats/_sensitivity_analysis.pyi index 5756a8c9..d7367fe2 100644 --- a/scipy-stubs/stats/_sensitivity_analysis.pyi +++ b/scipy-stubs/stats/_sensitivity_analysis.pyi @@ -1,22 +1,26 @@ from dataclasses import dataclass - from collections.abc import Callable -from typing import Literal, Protocol +from typing import Any, Literal, Protocol, TypeAlias import numpy as np - import numpy.typing as npt - -from scipy._lib._util import DecimalNumber as DecimalNumber, IntNumber as IntNumber, SeedType as SeedType -from scipy.stats import bootstrap as bootstrap, qmc as qmc -from scipy.stats._common import ConfidenceInterval as ConfidenceInterval -from scipy.stats._qmc import check_random_state as check_random_state +import scipy._typing as spt from scipy.stats._resampling import BootstrapResult as BootstrapResult -def f_ishigami(x: npt.ArrayLike) -> np.ndarray: ... -def sample_A_B(n: IntNumber, dists: list[PPFDist], random_state: SeedType = None) -> np.ndarray: ... -def sample_AB(A: np.ndarray, B: np.ndarray) -> np.ndarray: ... -def saltelli_2010(f_A: np.ndarray, f_B: np.ndarray, f_AB: np.ndarray) -> tuple[np.ndarray, np.ndarray]: ... +__all__ = ["sobol_indices"] + +def f_ishigami(x: npt.ArrayLike) -> spt.UntypedArray: ... +def sample_A_B( + n: spt.AnyInt, + dists: list[PPFDist], + random_state: int | np.random.RandomState | np.random.Generator | None = None, +) -> spt.UntypedArray: ... +def sample_AB(A: spt.UntypedArray, B: spt.UntypedArray) -> spt.UntypedArray: ... +def saltelli_2010( + f_A: spt.UntypedArray, + f_B: spt.UntypedArray, + f_AB: spt.UntypedArray, +) -> tuple[spt.UntypedArray, spt.UntypedArray]: ... @dataclass class BootstrapSobolResult: first_order: BootstrapResult @@ -24,19 +28,21 @@ class BootstrapSobolResult: @dataclass class SobolResult: - first_order: np.ndarray - total_order: np.ndarray - def bootstrap(self, confidence_level: DecimalNumber = 0.95, n_resamples: IntNumber = 999) -> BootstrapSobolResult: ... + first_order: spt.UntypedArray + total_order: spt.UntypedArray + def bootstrap(self, confidence_level: spt.AnyReal = 0.95, n_resamples: spt.AnyInt = 999) -> BootstrapSobolResult: ... class PPFDist(Protocol): @property def ppf(self) -> Callable[..., float]: ... +_SobolKey: TypeAlias = Literal["f_A", "f_B", "f_AB"] + def sobol_indices( *, - func: Callable[[np.ndarray], npt.ArrayLike] | dict[Literal["f_A", "f_B", "f_AB"], np.ndarray], - n: IntNumber, + func: Callable[[npt.NDArray[np.number[Any]]], npt.ArrayLike] | dict[_SobolKey, npt.NDArray[np.number[Any]]], + n: spt.AnyInt, dists: list[PPFDist] | None = None, - method: Callable | Literal["saltelli_2010"] = "saltelli_2010", - random_state: SeedType = None, + method: Callable[..., spt.Untyped] | Literal["saltelli_2010"] = "saltelli_2010", + random_state: int | np.random.RandomState | np.random.Generator | None = None, ) -> SobolResult: ... diff --git a/scipy-stubs/stats/_stats_mstats_common.pyi b/scipy-stubs/stats/_stats_mstats_common.pyi index 44759994..df13816c 100644 --- a/scipy-stubs/stats/_stats_mstats_common.pyi +++ b/scipy-stubs/stats/_stats_mstats_common.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from . import distributions as distributions TheilslopesResult: Untyped diff --git a/scipy-stubs/stats/_stats_py.pyi b/scipy-stubs/stats/_stats_py.pyi index 3d44f2b1..f022984b 100644 --- a/scipy-stubs/stats/_stats_py.pyi +++ b/scipy-stubs/stats/_stats_py.pyi @@ -1,43 +1,78 @@ from dataclasses import dataclass - from typing import NamedTuple from scipy._typing import Untyped - -from scipy import linalg as linalg, sparse as sparse, stats as stats -from scipy._lib._array_api import ( - array_namespace as array_namespace, - is_numpy as is_numpy, - xp_atleast_nd as xp_atleast_nd, - xp_moveaxis_to_end as xp_moveaxis_to_end, - xp_sign as xp_sign, - xp_size as xp_size, - xp_vector_norm as xp_vector_norm, -) -from scipy._lib._util import ( - AxisError as AxisError, - check_random_state as check_random_state, - normalize_axis_index as normalize_axis_index, -) -from scipy.optimize import LinearConstraint as LinearConstraint, milp as milp, root_scalar as root_scalar -from scipy.spatial import distance_matrix as distance_matrix -from . import distributions as distributions -from ._axis_nan_policy import ( - SmallSampleWarning as SmallSampleWarning, - too_small_1d_not_omit as too_small_1d_not_omit, - too_small_1d_omit as too_small_1d_omit, - too_small_nd_not_omit as too_small_nd_not_omit, - too_small_nd_omit as too_small_nd_omit, -) -from ._resampling import ( - BootstrapMethod as BootstrapMethod, - MonteCarloMethod as MonteCarloMethod, - PermutationMethod as PermutationMethod, - bootstrap as bootstrap, - monte_carlo_test as monte_carlo_test, - permutation_test as permutation_test, -) -from ._stats_mstats_common import siegelslopes as siegelslopes, theilslopes as theilslopes +from ._stats_mstats_common import siegelslopes, theilslopes + +__all__ = [ + "alexandergovern", + "brunnermunzel", + "chisquare", + "combine_pvalues", + "cumfreq", + "describe", + "energy_distance", + "expectile", + "f_oneway", + "find_repeats", + "fisher_exact", + "friedmanchisquare", + "gmean", + "gstd", + "gzscore", + "hmean", + "iqr", + "jarque_bera", + "kendalltau", + "kruskal", + "ks_1samp", + "ks_2samp", + "kstest", + "kurtosis", + "kurtosistest", + "linregress", + "median_abs_deviation", + "mode", + "moment", + "normaltest", + "obrientransform", + "pearsonr", + "percentileofscore", + "pmean", + "pointbiserialr", + "power_divergence", + "quantile_test", + "rankdata", + "ranksums", + "relfreq", + "scoreatpercentile", + "sem", + "siegelslopes", + "sigmaclip", + "skew", + "skewtest", + "spearmanr", + "theilslopes", + "tiecorrect", + "tmax", + "tmean", + "tmin", + "trim1", + "trim_mean", + "trimboth", + "tsem", + "tstd", + "ttest_1samp", + "ttest_ind", + "ttest_ind_from_stats", + "ttest_rel", + "tvar", + "wasserstein_distance", + "wasserstein_distance_nd", + "weightedtau", + "zmap", + "zscore", +] SignificanceResult: Untyped @@ -47,16 +82,24 @@ def pmean(a, p, *, axis: int = 0, dtype: Untyped | None = None, weights: Untyped class ModeResult(NamedTuple): mode: Untyped - count: Untyped + count: Untyped # type: ignore[assignment] def mode(a, axis: int = 0, nan_policy: str = "propagate", keepdims: bool = False) -> Untyped: ... def tmean(a, limits: Untyped | None = None, inclusive=(True, True), axis: Untyped | None = None) -> Untyped: ... def tvar(a, limits: Untyped | None = None, inclusive=(True, True), axis: int = 0, ddof: int = 1) -> Untyped: ... def tmin( - a, lowerlimit: Untyped | None = None, axis: int = 0, inclusive: bool = True, nan_policy: str = "propagate" + a, + lowerlimit: Untyped | None = None, + axis: int = 0, + inclusive: bool = True, + nan_policy: str = "propagate", ) -> Untyped: ... def tmax( - a, upperlimit: Untyped | None = None, axis: int = 0, inclusive: bool = True, nan_policy: str = "propagate" + a, + upperlimit: Untyped | None = None, + axis: int = 0, + inclusive: bool = True, + nan_policy: str = "propagate", ) -> Untyped: ... def tstd(a, limits: Untyped | None = None, inclusive=(True, True), axis: int = 0, ddof: int = 1) -> Untyped: ... def tsem(a, limits: Untyped | None = None, inclusive=(True, True), axis: int = 0, ddof: int = 1) -> Untyped: ... @@ -96,7 +139,7 @@ def scoreatpercentile(a, per, limit=(), interpolation_method: str = "fraction", def percentileofscore(a, score, kind: str = "rank", nan_policy: str = "propagate") -> Untyped: ... class HistogramResult(NamedTuple): - count: Untyped + count: Untyped # type: ignore[assignment] lowerlimit: Untyped binsize: Untyped extrapoints: Untyped @@ -159,7 +202,9 @@ class ConfidenceInterval(NamedTuple): low: Untyped high: Untyped -PearsonRResultBase: Untyped +class PearsonRResultBase(NamedTuple): + statistic: Untyped + pvalue: Untyped class PearsonRResult(PearsonRResultBase): correlation: Untyped @@ -169,15 +214,29 @@ class PearsonRResult(PearsonRResultBase): def pearsonr(x, y, *, alternative: str = "two-sided", method: Untyped | None = None, axis: int = 0) -> Untyped: ... def fisher_exact(table, alternative: str = "two-sided") -> Untyped: ... def spearmanr( - a, b: Untyped | None = None, axis: int = 0, nan_policy: str = "propagate", alternative: str = "two-sided" + a, + b: Untyped | None = None, + axis: int = 0, + nan_policy: str = "propagate", + alternative: str = "two-sided", ) -> Untyped: ... def pointbiserialr(x, y) -> Untyped: ... def kendalltau( - x, y, *, nan_policy: str = "propagate", method: str = "auto", variant: str = "b", alternative: str = "two-sided" + x, + y, + *, + nan_policy: str = "propagate", + method: str = "auto", + variant: str = "b", + alternative: str = "two-sided", ) -> Untyped: ... def weightedtau(x, y, rank: bool = True, weigher: Untyped | None = None, additive: bool = True) -> Untyped: ... -TtestResultBase: Untyped +class TtestResultBase(NamedTuple): + statistic: Untyped + pvalue: Untyped + @property + def df(self) -> Untyped: ... class TtestResult(TtestResultBase): def __init__( @@ -202,7 +261,14 @@ class Ttest_indResult(NamedTuple): pvalue: Untyped def ttest_ind_from_stats( - mean1, std1, nobs1, mean2, std2, nobs2, equal_var: bool = True, alternative: str = "two-sided" + mean1, + std1, + nobs1, + mean2, + std2, + nobs2, + equal_var: bool = True, + alternative: str = "two-sided", ) -> Untyped: ... def ttest_ind( a, @@ -222,7 +288,11 @@ class Power_divergenceResult(NamedTuple): pvalue: Untyped def power_divergence( - f_obs, f_exp: Untyped | None = None, ddof: int = 0, axis: int = 0, lambda_: Untyped | None = None + f_obs, + f_exp: Untyped | None = None, + ddof: int = 0, + axis: int = 0, + lambda_: Untyped | None = None, ) -> Untyped: ... def chisquare(f_obs, f_exp: Untyped | None = None, ddof: int = 0, axis: int = 0) -> Untyped: ... @@ -270,7 +340,10 @@ class QuantileTestResult: def quantile_test_iv(x, q, p, alternative) -> Untyped: ... def quantile_test(x, *, q: int = 0, p: float = 0.5, alternative: str = "two-sided") -> Untyped: ... def wasserstein_distance_nd( - u_values, v_values, u_weights: Untyped | None = None, v_weights: Untyped | None = None + u_values, + v_values, + u_weights: Untyped | None = None, + v_weights: Untyped | None = None, ) -> Untyped: ... def wasserstein_distance(u_values, v_values, u_weights: Untyped | None = None, v_weights: Untyped | None = None) -> Untyped: ... def energy_distance(u_values, v_values, u_weights: Untyped | None = None, v_weights: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/stats/_survival.pyi b/scipy-stubs/stats/_survival.pyi index 2cb4ef2c..fee40ff9 100644 --- a/scipy-stubs/stats/_survival.pyi +++ b/scipy-stubs/stats/_survival.pyi @@ -1,23 +1,20 @@ from dataclasses import dataclass - from typing import Literal import numpy as np - import numpy.typing as npt -from scipy._typing import Untyped - from scipy import interpolate as interpolate, special as special, stats as stats +from scipy._typing import Untyped from scipy.stats._censored_data import CensoredData as CensoredData from scipy.stats._common import ConfidenceInterval as ConfidenceInterval @dataclass class EmpiricalDistributionFunction: - quantiles: np.ndarray - probabilities: np.ndarray + quantiles: npt.NDArray[np.float64] + probabilities: npt.NDArray[np.float64] def __init__(self, q, p, n, d, kind) -> None: ... def evaluate(self, x) -> Untyped: ... - def plot(self, ax: Untyped | None = None, **matplotlib_kwargs) -> Untyped: ... + def plot(self, ax: Untyped | None = None, **matplotlib_kwargs: Untyped) -> Untyped: ... def confidence_interval(self, confidence_level: float = 0.95, *, method: str = "linear") -> Untyped: ... @dataclass @@ -29,8 +26,8 @@ class ECDFResult: def ecdf(sample: npt.ArrayLike | CensoredData) -> ECDFResult: ... @dataclass class LogRankResult: - statistic: np.ndarray - pvalue: np.ndarray + statistic: npt.NDArray[np.float64] + pvalue: npt.NDArray[np.float64] def logrank( x: npt.ArrayLike | CensoredData, diff --git a/scipy-stubs/stats/_tukeylambda_stats.pyi b/scipy-stubs/stats/_tukeylambda_stats.pyi index 2f46fb63..f99c449b 100644 --- a/scipy-stubs/stats/_tukeylambda_stats.pyi +++ b/scipy-stubs/stats/_tukeylambda_stats.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from scipy.special import beta as beta def tukeylambda_variance(lam) -> Untyped: ... diff --git a/scipy-stubs/stats/_variation.pyi b/scipy-stubs/stats/_variation.pyi index 50f0be50..4234eb0d 100644 --- a/scipy-stubs/stats/_variation.pyi +++ b/scipy-stubs/stats/_variation.pyi @@ -1,5 +1,3 @@ from scipy._typing import Untyped -from scipy._lib._array_api import array_namespace as array_namespace, xp_copysign as xp_copysign - def variation(a, axis: int = 0, nan_policy: str = "propagate", ddof: int = 0, *, keepdims: bool = False) -> Untyped: ... diff --git a/scipy-stubs/stats/_warnings_errors.pyi b/scipy-stubs/stats/_warnings_errors.pyi index 9e00ed25..cbe2fe02 100644 --- a/scipy-stubs/stats/_warnings_errors.pyi +++ b/scipy-stubs/stats/_warnings_errors.pyi @@ -1,17 +1,7 @@ -from scipy._typing import Untyped - class DegenerateDataWarning(RuntimeWarning): - args: Untyped - def __init__(self, msg: Untyped | None = None): ... - -class ConstantInputWarning(DegenerateDataWarning): - args: Untyped - def __init__(self, msg: Untyped | None = None): ... - -class NearConstantInputWarning(DegenerateDataWarning): - args: Untyped - def __init__(self, msg: Untyped | None = None): ... + args: tuple[str | None] + def __init__(self, msg: str | None = None) -> None: ... -class FitError(RuntimeError): - args: Untyped - def __init__(self, msg: Untyped | None = None): ... +class ConstantInputWarning(DegenerateDataWarning): ... +class NearConstantInputWarning(DegenerateDataWarning): ... +class FitError(RuntimeError): ... diff --git a/scipy-stubs/stats/_wilcoxon.pyi b/scipy-stubs/stats/_wilcoxon.pyi index 1637ac94..b3f5cc78 100644 --- a/scipy-stubs/stats/_wilcoxon.pyi +++ b/scipy-stubs/stats/_wilcoxon.pyi @@ -1,6 +1,5 @@ -from scipy._typing import Untyped - from scipy import stats as stats +from scipy._typing import Untyped class WilcoxonDistribution: n: Untyped diff --git a/scipy-stubs/stats/contingency.pyi b/scipy-stubs/stats/contingency.pyi index 910a03e3..f1d66c9f 100644 --- a/scipy-stubs/stats/contingency.pyi +++ b/scipy-stubs/stats/contingency.pyi @@ -1,5 +1,4 @@ from scipy._typing import Untyped - from ._crosstab import crosstab as crosstab from ._odds_ratio import odds_ratio as odds_ratio from ._relative_risk import relative_risk as relative_risk