diff --git a/.editorconfig b/.editorconfig index c2ed0b51..3480f065 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,9 +11,9 @@ indent_style = space trim_trailing_whitespace = true # 4 space indentation -[*.{py, pyi, .md}] +[*.{py,pyi,md}] indent_size = 4 # 2 space indentation -[*.{json, jsonc, yml, yaml}] +[*.{json,jsonc,yml,yaml,toml}] indent_size = 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..455a0c6a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +jobs: + lint: + timeout-minutes: 5 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: markdownlint + uses: DavidAnson/markdownlint-cli2-action@v16 + with: + config: ".markdownlint.yaml" + globs: "**/*.md" + + - name: install poetry + run: | + pipx install poetry + poetry config virtualenvs.create true --local + poetry config virtualenvs.in-project true --local + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: poetry + + - name: poetry install + run: poetry install + + - name: ruff check + run: poetry run ruff check --output-format=github + + - name: basedpyright --verifytypes + run: poetry run basedpyright --ignoreexternal --verifytypes scipy-stubs + + # TODO: don't continue on error + - name: basedmypy stubtest + run: poetry run stubtest --concise --mypy-config-file=pyproject.toml scipy + continue-on-error: true + + # TODO: don't continue on error + - name: basedpyright --verifytypes + run: poetry run basedpyright --verifytypes scipy-stubs + continue-on-error: true + + # TODO + # - uses: scientific-python/repo-review@v0.11.2 + # with: + # plugins: sp-repo-review diff --git a/.vscode/settings.json b/.vscode/settings.json index dd6fef46..d9c27ee4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,14 @@ "[markdown]": { "editor.rulers": [88] }, + "[toml]": { + "editor.rulers": [88], + "editor.tabSize": 4 + }, "git.branchProtection": ["master"], - "mypy-type-checker.args": ["--config-file=pyproject.toml"] + "mypy-type-checker.args": [ + "--config-file=pyproject.toml" + ], + "yaml.format.printWidth": 88, + "prettier.printWidth": 88 } diff --git a/README.md b/README.md index 25f3f17e..95b1cdf3 100644 --- a/README.md +++ b/README.md @@ -83,32 +83,33 @@ pip install scipy-stubs | Module | Stubs status | |---------------------------------- |---------------- | | `scipy` | 1: skeleton | -| `scipy._lib` | 1: skeleton | -| `scipy._lib._uarray` | 0: missing | +| `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 fc8d224a..2d0e89c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,74 +1,72 @@ [build-system] -requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" - +requires = ["poetry-core"] [tool.poetry] -name = "scipy-stubs" -version = "1.4.1.dev0" -description = "" authors = ["Joren Hammudoglu "] -license = "BSD-3-Clause" -readme = "README.md" -packages = [{include = "scipy-stubs"}] classifiers = [ - "Development Status :: 3 - Alpha", - "Operating System :: OS Independent", - "Topic :: Scientific/Engineering", - "Typing :: Stubs Only", - "Typing :: Typed", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", + "Development Status :: 3 - Alpha", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering", + "Typing :: Stubs Only", + "Typing :: Typed", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] -repository = "https://github.com/jorenham/scipy-stubs/" +description = "" documentation = "https://github.com/jorenham/scipy-stubs?tab=readme-ov-file#scipy-stubs" +license = "BSD-3-Clause" +name = "scipy-stubs" +packages = [{include = "scipy-stubs"}] +readme = "README.md" +repository = "https://github.com/jorenham/scipy-stubs/" +version = "1.4.1.dev0" [tool.poetry.urls] "Bug Tracker" = "https://github.com/jorenham/scipy-stubs/issues" "Changelog" = "https://github.com/jorenham/scipy-stubs/releases" [tool.poetry.dependencies] -python = "^3.10.1" optype = "^0.6.1" +python = "^3.10.1" scipy = "^1.14.1" [tool.poetry.group.lint.dependencies] -ruff = "^0.6.2" basedmypy = "^2.6.0" basedpyright = "^1.17.1" +ruff = "^0.6.2" [tool.poetry.group.dev.dependencies] -pre-commit = "^3.8.0" poethepoet = "^0.27.0" - +pre-commit = "^3.8.0" [tool.mypy] -warn_unused_ignores = true -disallow_any_explicit = false # no other way to type e.g. `np.float64 <: np.number[Any]` disable_bytearray_promotion = true disable_memoryview_promotion = true - +disallow_any_explicit = false # no other way to type e.g. `float64 <: number[Any]` +disallow_untyped_defs = false # TODO +disallow_incomplete_defs = false # TODO +warn_unused_ignores = true [tool.pyright] include = ["scipy-stubs"] -stubPath = "." -venvPath = "." -venv = ".venv" -pythonVersion = "3.10" pythonPlatform = "All" +pythonVersion = "3.10" +stubPath = "." typeCheckingMode = "strict" +venv = ".venv" +venvPath = "." deprecateTypingAliases = true -reportPrivateUsage = false reportIgnoreCommentWithoutRule = true reportImplicitRelativeImport = true reportInvalidCast = true +reportPrivateUsage = false reportUnnecessaryTypeIgnoreComment = true reportUnsafeMultipleInheritance = true - [tool.ruff] builtins = ["reveal_locals", "reveal_type"] exclude = ["scipy-pyright", ".venv"] @@ -82,26 +80,88 @@ src = ["scipy-stubs"] line-ending = "lf" skip-magic-trailing-comma = false - [tool.ruff.lint] +ignore = [ + "E741", + "COM812", # ruff format compat + "ANN", # TODO +] preview = true -select = ["E", "W", "I", "UP", "ANN", "COM", "EXE", "ICN", "INP", "PYI", "Q", "TID", "TCH", "ERA", "PGH", "RUF"] -extend-select = [ - "PLC0105", "PLC0131", "PLC0132", "PLC0414", - "PLE0303", "PLE0304", "PLE0305", "PLE0307", "PLE0308", "PLE0309", - "PLE0604", "PLE0605", "PLE1132" +select = [ + "E", + "W", + "I", + "UP", + "ANN", + "COM", + "EXE", + "ICN", + "INP", + "PYI", + "Q", + "TID", + "TCH", + "ERA", + "PGH", + "RUF", + "PLC0105", + "PLC0131", + "PLC0132", + "PLC0414", + "PLE0303", + "PLE0304", + "PLE0305", + "PLE0307", + "PLE0308", + "PLE0309", + "PLE0604", + "PLE0605", + "PLE1132", ] -ignore = [ - "E741", - "COM812", # ruff format compat - "ANN", # TODO + +[tool.ruff.lint.flake8-import-conventions] +banned-from = [ + "numpy", + "numpy.dtypes", + "numpy.exceptions", + "numpy.emath", + "numpy.fft", + "numpy.linalg", + "numpy.ma", + "numpy.polynomial", + "numpy.random", + "numpy.rec", + "numpy.typing", + "numpy.strings", + "optype", + "optype.numpy", + "optype.typing", ] +[tool.ruff.lint.flake8-import-conventions.extend-aliases] +"numpy" = "np" +"numpy.polynomial" = "npp" +"numpy.typing" = "npt" +"optype" = "op" +"optype.numpy" = "onpt" +"scipy" = "sp" +"scipy._typing" = "spt" [tool.ruff.lint.isort] combine-as-imports = true -known-local-folder = ["scipy"] +known-first-party = ["scipy"] +no-lines-before = ["typing", "first-party", "local-folder"] +section-order = [ + "standard-library", + "typing", + "third-party", + "first-party", + "local-folder", +] split-on-trailing-comma = true +[tool.ruff.lint.isort.sections] +typing = ["collections.abc", "types", "typing", "typing_extensions"] + [tool.ruff.lint.flake8-annotations] allow-star-arg-any = true mypy-init-return = true diff --git a/scipy-stubs/_lib/_array_api.pyi b/scipy-stubs/_lib/_array_api.pyi index 4a750c0c..1834c690 100644 --- a/scipy-stubs/_lib/_array_api.pyi +++ b/scipy-stubs/_lib/_array_api.pyi @@ -1,75 +1,19 @@ from types import ModuleType -from typing import Any, TypeAlias +from typing import Any, Literal -from scipy._lib import array_api_compat as array_api_compat -from scipy._lib.array_api_compat import is_array_api_obj as is_array_api_obj +from scipy._lib.array_api_compat import device, size from scipy._typing import Untyped -SCIPY_ARRAY_API: str | bool -SCIPY_DEVICE: Untyped -Array: TypeAlias = Any -ArrayLike: Untyped +__all__ = ["_asarray", "array_namespace", "device", "size"] -def array_namespace(*arrays: Array) -> ModuleType: ... -def xp_atleast_nd(x: Array, *, ndim: int, xp: ModuleType | None = None) -> Array: ... -def xp_copy(x: Array, *, xp: ModuleType | None = None) -> Array: ... -def is_numpy(xp: ModuleType) -> bool: ... -def is_cupy(xp: ModuleType) -> bool: ... -def is_torch(xp: ModuleType) -> bool: ... -def is_jax(xp) -> Untyped: ... -def is_array_api_strict(xp) -> Untyped: ... -def xp_assert_equal( - actual, - desired, - check_namespace: bool = True, - check_dtype: bool = True, - check_shape: bool = True, - allow_0d: bool = False, - err_msg: str = "", - xp: Untyped | None = None, -) -> Untyped: ... -def xp_assert_close( - actual, - desired, - rtol: Untyped | None = None, - atol: int = 0, - check_namespace: bool = True, - check_dtype: bool = True, - check_shape: bool = True, - allow_0d: bool = False, - err_msg: str = "", - xp: Untyped | None = None, -) -> Untyped: ... -def xp_assert_less( - actual, - desired, - check_namespace: bool = True, - check_dtype: bool = True, - check_shape: bool = True, - allow_0d: bool = False, - err_msg: str = "", - verbose: bool = True, - xp: Untyped | None = None, -) -> Untyped: ... -def assert_array_almost_equal(actual, desired, decimal: int = 6, *args, **kwds) -> Untyped: ... -def assert_almost_equal(actual, desired, decimal: int = 7, *args, **kwds) -> Untyped: ... -def xp_cov(x: Array, *, xp: ModuleType | None = None) -> Array: ... -def xp_unsupported_param_msg(param: Any) -> str: ... -def is_complex(x: Array, xp: ModuleType) -> bool: ... -def get_xp_devices(xp: ModuleType) -> list[str] | list[None]: ... -def scipy_namespace_for(xp: ModuleType) -> ModuleType | None: ... -def xp_moveaxis_to_end(x: Array, source: int, /, *, xp: ModuleType | None = None) -> Array: ... -def xp_copysign(x1: Array, x2: Array, /, *, xp: ModuleType | None = None) -> Array: ... -def xp_sign(x: Array, /, *, xp: ModuleType | None = None) -> Array: ... -def xp_vector_norm( - x: Array, - /, +def _asarray( + array: Untyped, + dtype: Any = None, + order: Literal["K", "A", "C", "F"] | None = None, + copy: bool | None = None, *, - axis: int | tuple[int] | None = None, - keepdims: bool = False, - ord: int | float = 2, xp: ModuleType | None = None, -) -> Array: ... -def xp_ravel(x: Array, /, *, xp: ModuleType | None = None) -> Array: ... -def xp_real(x: Array, /, *, xp: ModuleType | None = None) -> Array: ... -def xp_take_along_axis(arr: Array, indices: Array, /, *, axis: int = -1, xp: ModuleType | None = None) -> Array: ... + check_finite: bool = False, + subok: bool = False, +) -> Untyped: ... +def array_namespace(*arrays: Untyped) -> ModuleType: ... diff --git a/scipy-stubs/_lib/_ccallback.pyi b/scipy-stubs/_lib/_ccallback.pyi index 22dc0a03..0256c5e3 100644 --- a/scipy-stubs/_lib/_ccallback.pyi +++ b/scipy-stubs/_lib/_ccallback.pyi @@ -1,18 +1,49 @@ +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 + from scipy._typing import Untyped -PyCFuncPtr: Untyped -ffi: Untyped +__all__ = ["LowLevelCallable"] + +# TODO: add `types-cffi` as dependency +CFFIFuncP: TypeAlias = Untyped +CFFIVoidP: TypeAlias = Untyped +ffi: Literal[False] | None class CData: ... -class LowLevelCallable(tuple): - def __new__(cls, function, user_data: Untyped | None = None, signature: Untyped | None = None) -> Untyped: ... +_Function: TypeAlias = CapsuleType | PyCFuncPtr | CFFIFuncP | CData +_UserData: TypeAlias = CapsuleType | ct.c_void_p | CFFIVoidP + +_FuncT_co = TypeVar("_FuncT_co", bound=_Function, covariant=True, default=_Function) +_DataT_co = TypeVar("_DataT_co", bound=_UserData | None, covariant=True, default=None) + +class LowLevelCallable(tuple[CapsuleType, _FuncT_co, _DataT_co], Generic[_FuncT_co, _DataT_co]): + # NOTE: __getitem__ will raise a ValueError + __getitem__: ClassVar[None] # type: ignore[assignment] + + def __new__( + cls, + /, + function: _FuncT_co | LowLevelCallable[_FuncT_co, _DataT_co], + user_data: Untyped | None = None, + signature: str | None = None, + ) -> Self: ... @property - def function(self) -> Untyped: ... + def function(self, /) -> _FuncT_co: ... @property - def user_data(self) -> Untyped: ... + def user_data(self, /) -> _DataT_co: ... @property - def signature(self) -> Untyped: ... - def __getitem__(self, idx): ... + def signature(self, /) -> str: ... @classmethod - def from_cython(cls, module, name, user_data: Untyped | None = None, signature: Untyped | None = None) -> Untyped: ... + def from_cython( + cls, + /, + module: ModuleType, + name: str, + user_data: _UserData | None = None, + signature: str | None = None, + ) -> Untyped: ... diff --git a/scipy-stubs/_lib/_docscrape.pyi b/scipy-stubs/_lib/_docscrape.pyi index 58047403..acfd642c 100644 --- a/scipy-stubs/_lib/_docscrape.pyi +++ b/scipy-stubs/_lib/_docscrape.pyi @@ -1,63 +1,86 @@ -from collections.abc import Mapping -from typing import NamedTuple +from collections.abc import Callable, Mapping, Sequence +from types import ModuleType +from typing import Any, ClassVar, Final, Literal, NamedTuple, TypeAlias +from typing_extensions import LiteralString, override -from scipy._typing import Untyped +import optype as op +from scipy._typing import Untyped, UntypedCallable -def strip_blank_lines(l) -> Untyped: ... +_SectionKey: TypeAlias = LiteralString +_SectionValue: TypeAlias = str | list[str] | dict[str, list[str]] class Reader: - def __init__(self, data) -> None: ... - def __getitem__(self, n) -> Untyped: ... - def reset(self): ... - def read(self) -> Untyped: ... - def seek_next_non_empty_line(self): ... - def eof(self) -> Untyped: ... - def read_to_condition(self, condition_func) -> Untyped: ... - def read_to_next_empty_line(self) -> Untyped: ... - def read_to_next_unindented_line(self) -> Untyped: ... - def peek(self, n: int = 0) -> Untyped: ... - def is_empty(self) -> Untyped: ... + def __init__(self, /, data: str | list[str]) -> None: ... + def __getitem__(self, n: op.CanIndex, /) -> str: ... + def reset(self) -> None: ... + def read(self) -> str: ... + def seek_next_non_empty_line(self) -> None: ... + def eof(self) -> bool: ... + def read_to_condition(self, condition_func: Callable[[str], object]) -> list[str]: ... + def read_to_next_empty_line(self) -> list[str]: ... + def read_to_next_unindented_line(self) -> list[str]: ... + def peek(self, n: int = 0) -> str: ... + def is_empty(self) -> bool: ... class ParseError(Exception): ... class Parameter(NamedTuple): - name: Untyped - type: Untyped - desc: Untyped + name: str + type: str + desc: str -class NumpyDocString(Mapping): - sections: Untyped - def __init__(self, docstring, config: Untyped | None = None): ... - def __getitem__(self, key) -> Untyped: ... - def __setitem__(self, key, val) -> None: ... - def __iter__(self) -> Untyped: ... - def __len__(self) -> int: ... - empty_description: str - -def dedent_lines(lines) -> Untyped: ... +class NumpyDocString(Mapping[_SectionKey, _SectionValue]): + empty_description: ClassVar[str] = ".." + sections: ClassVar[dict[_SectionKey, _SectionValue]] + def __init__(self, /, docstring: str, config: dict[str, Any] | None = None) -> None: ... + @override + def __getitem__(self, key: _SectionKey, /) -> _SectionValue: ... + def __setitem__(self, key: _SectionKey, val: _SectionValue, /) -> None: ... + @override + def __iter__(self, /) -> op.CanIterSelf[_SectionKey]: ... + @override + def __len__(self, /) -> int: ... class FunctionDoc(NumpyDocString): - def __init__(self, func, role: str = "func", doc: Untyped | None = None, config: Untyped | None = None): ... - def get_func(self) -> Untyped: ... + def __init__( + self, + /, + func: UntypedCallable, + role: Literal["func", "meth"] = "func", + doc: str | None = None, + config: dict[str, Any] | None = None, + ) -> None: ... + def get_func(self) -> UntypedCallable: ... class ObjDoc(NumpyDocString): - def __init__(self, obj, doc: Untyped | None = None, config: Untyped | None = None): ... + def __init__(self, /, obj: object, doc: str | None = None, config: dict[str, Any] | None = None) -> None: ... class ClassDoc(NumpyDocString): - extra_public_methods: Untyped - show_inherited_members: Untyped - def __init__(self, cls, doc: Untyped | None = None, modulename: str = "", func_doc=..., config: Untyped | None = None): ... + extra_public_methods: ClassVar[Sequence[str]] + show_inherited_members: Final[bool] + + def __init__( + self, + /, + cls: type, + doc: str | None = None, + modulename: str = "", + func_doc: type[FunctionDoc] = ..., + config: Untyped | None = None, + ) -> None: ... @property - def methods(self) -> Untyped: ... + def methods(self) -> list[str]: ... @property - def properties(self) -> Untyped: ... + def properties(self) -> list[str]: ... +def strip_blank_lines(l: list[str]) -> list[str]: ... +def dedent_lines(lines: op.CanIter[op.CanIterSelf[str]]) -> str: ... def get_doc_object( - obj, - what: Untyped | None = None, - doc: Untyped | None = None, - config: Untyped | None = None, - class_doc=..., - func_doc=..., - obj_doc=..., -) -> Untyped: ... + obj: type | ModuleType | Callable[..., object] | object, + what: Literal["class", "module", "function", "object"] | None = None, + doc: str | None = None, + config: dict[str, Any] | None = None, + class_doc: type[ClassDoc] = ..., + func_doc: type[FunctionDoc] = ..., + obj_doc: type[ObjDoc] = ..., +) -> NumpyDocString: ... diff --git a/scipy-stubs/_lib/_elementwise_iterative_method.pyi b/scipy-stubs/_lib/_elementwise_iterative_method.pyi index d298bf9b..f93c5705 100644 --- a/scipy-stubs/_lib/_elementwise_iterative_method.pyi +++ b/scipy-stubs/_lib/_elementwise_iterative_method.pyi @@ -1 +1 @@ -from ._array_api import array_namespace as array_namespace, xp_size as xp_size +# nothing to see here 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/_threadsafety.pyi b/scipy-stubs/_lib/_threadsafety.pyi index f1fd4ec7..ef40d6bc 100644 --- a/scipy-stubs/_lib/_threadsafety.pyi +++ b/scipy-stubs/_lib/_threadsafety.pyi @@ -1,11 +1,26 @@ +from collections.abc import Callable +from types import TracebackType +from typing import Any +from typing_extensions import TypeVar + from scipy._typing import Untyped +__all__ = ["ReentrancyError", "ReentrancyLock", "non_reentrant"] + +_FT = TypeVar("_FT", bound=Callable[..., Any]) + class ReentrancyError(RuntimeError): ... class ReentrancyLock: - def __init__(self, err_msg) -> None: ... - def __enter__(self): ... - def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None): ... - def decorate(self, func) -> Untyped: ... + def __init__(self, /, err_msg: str) -> None: ... + def __enter__(self, /) -> None: ... + def __exit__( + self, + /, + type: type[BaseException] | None, + value: BaseException | None, + traceback: TracebackType | None, + ) -> None: ... + def decorate(self, func: _FT, /) -> _FT: ... def non_reentrant(err_msg: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/_lib/_uarray/_backend.pyi b/scipy-stubs/_lib/_uarray/_backend.pyi index a3f5d4c4..4541d9b0 100644 --- a/scipy-stubs/_lib/_uarray/_backend.pyi +++ b/scipy-stubs/_lib/_uarray/_backend.pyi @@ -1,11 +1,40 @@ -import typing -from collections.abc import Generator +from collections.abc import Callable, Generator +from typing import TypeAlias -from ._uarray import BackendNotImplementedError as BackendNotImplementedError -from scipy._typing import Untyped +from scipy._typing import Untyped, UntypedCallable -ArgumentExtractorType: Untyped -ArgumentReplacerType: typing.TypeAlias = typing.Callable[[tuple, dict, tuple], tuple[tuple, dict]] +__all__ = [ + "BackendNotImplementedError", + "Dispatchable", + # "_BackendState", + # "_Function", + # "_SetBackendContext", + # "_SkipBackendContext", + "all_of_type", + "clear_backends", + "create_multimethod", + "determine_backend", + "determine_backend_multi", + "generate_multimethod", + "get_state", + "mark_as", + "register_backend", + "reset_state", + "set_backend", + "set_global_backend", + "set_state", + "skip_backend", + "wrap_single_convertor", + "wrap_single_convertor_instance", +] + +class BackendNotImplementedError(NotImplementedError): ... + +ArgumentExtractorType: TypeAlias = Callable[..., tuple[Dispatchable, ...]] +ArgumentReplacerType: TypeAlias = Callable[ + [tuple[Untyped, ...], dict[Untyped, Untyped], tuple[Untyped, ...]], + tuple[tuple[Untyped, ...], dict[Untyped, Untyped]], +] def unpickle_function(mod_name, qname, self_) -> Untyped: ... def pickle_function(func) -> Untyped: ... @@ -20,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 1768a125..8c83d31a 100644 --- a/scipy-stubs/_lib/_util.pyi +++ b/scipy-stubs/_lib/_util.pyi @@ -1,8 +1,8 @@ -from typing import NamedTuple, TypeVar +from types import TracebackType +from typing import Any, NamedTuple, TypeAlias +from typing_extensions import TypeVar, override import numpy as np - -from scipy._lib._array_api import array_namespace as array_namespace, is_numpy as is_numpy, xp_size as xp_size from scipy._typing import Untyped AxisError: type[Exception] @@ -11,16 +11,16 @@ VisibleDeprecationWarning: type[Warning] DTypePromotionError = TypeError np_long: type np_ulong: type -IntNumber: Untyped -DecimalNumber: Untyped copy_if_needed: bool | None -SeedType: Untyped -GeneratorType = TypeVar("GeneratorType", bound=np.random.Generator | np.random.RandomState) + +IntNumber: TypeAlias = int | np.integer[Any] +DecimalNumber: TypeAlias = float | np.floating[Any] | np.integer[Any] +SeedType: TypeAlias = IntNumber | np.random.Generator | np.random.RandomState | None class Generator: ... def float_factorial(n: int) -> float: ... -def check_random_state(seed) -> Untyped: ... +def check_random_state(seed: SeedType) -> np.random.Generator | np.random.RandomState: ... class FullArgSpec(NamedTuple): args: Untyped @@ -31,7 +31,7 @@ class FullArgSpec(NamedTuple): kwonlydefaults: Untyped annotations: Untyped -def getfullargspec_no_self(func) -> Untyped: ... +def getfullargspec_no_self(func) -> FullArgSpec: ... class _FunctionWrapper: f: Untyped @@ -47,17 +47,30 @@ class MapWrapper: def join(self): ... def close(self): ... def __exit__( - self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: types.TracebackType | None + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, ): ... def __call__(self, func, iterable) -> Untyped: ... def rng_integers( - gen, low, high: Untyped | None = None, size: Untyped | None = None, dtype: str = "int64", endpoint: bool = False + gen, + low, + high: Untyped | None = None, + size: Untyped | None = None, + dtype: str = "int64", + endpoint: bool = False, ) -> Untyped: ... def normalize_axis_index(axis, ndim) -> Untyped: ... -class _RichResult(dict): - def __getattr__(self, name) -> Untyped: ... - __setattr__: Untyped - __delattr__: Untyped - def __dir__(self) -> Untyped: ... +_VT = TypeVar("_VT", default=object) + +class _RichResult(dict[str, _VT]): + def __getattr__(self, name: str, /) -> _VT: ... + @override + def __setattr__(self, name: str, value: _VT, /) -> None: ... + @override + def __delattr__(self, name: str, /) -> None: ... + @override + def __dir__(self, /) -> list[str]: ... diff --git a/scipy-stubs/_lib/array_api_compat/__init__.pyi b/scipy-stubs/_lib/array_api_compat/__init__.pyi new file mode 100644 index 00000000..42b2ed39 --- /dev/null +++ b/scipy-stubs/_lib/array_api_compat/__init__.pyi @@ -0,0 +1,9 @@ +from typing import Final + +from . import common +from .common import * + +__all__ = ["__version__"] +__all__ += common.__all__ + +__version__: Final = "1.5.1" diff --git a/scipy-stubs/_lib/array_api_compat/common/__init__.pyi b/scipy-stubs/_lib/array_api_compat/common/__init__.pyi new file mode 100644 index 00000000..3317899b --- /dev/null +++ b/scipy-stubs/_lib/array_api_compat/common/__init__.pyi @@ -0,0 +1,27 @@ +from ._helpers import ( + array_namespace, + device, + get_namespace, + is_array_api_obj, + is_cupy_array, + is_dask_array, + is_jax_array, + is_numpy_array, + is_torch_array, + size, + to_device, +) + +__all__ = [ + "array_namespace", + "device", + "get_namespace", + "is_array_api_obj", + "is_cupy_array", + "is_dask_array", + "is_jax_array", + "is_numpy_array", + "is_torch_array", + "size", + "to_device", +] diff --git a/scipy-stubs/_lib/array_api_compat/common/_helpers.pyi b/scipy-stubs/_lib/array_api_compat/common/_helpers.pyi new file mode 100644 index 00000000..e61a5093 --- /dev/null +++ b/scipy-stubs/_lib/array_api_compat/common/_helpers.pyi @@ -0,0 +1,32 @@ +from types import ModuleType +from typing_extensions import TypeIs + +import numpy as np +from ._typing import Array, Device + +__all__ = [ + "array_namespace", + "device", + "get_namespace", + "is_array_api_obj", + "is_cupy_array", + "is_dask_array", + "is_jax_array", + "is_numpy_array", + "is_torch_array", + "size", + "to_device", +] + +def is_numpy_array(x: object) -> TypeIs[np.ndarray[tuple[int, ...], np.dtype[np.generic]] | np.generic]: ... +def is_cupy_array(x: object) -> bool: ... +def is_torch_array(x: object) -> bool: ... +def is_dask_array(x: object) -> bool: ... +def is_jax_array(x: object) -> bool: ... +def is_array_api_obj(x: object) -> bool: ... +def array_namespace(*xs: object, api_version: str | None = None) -> ModuleType: ... +def device(x: Array, /) -> Device: ... +def to_device(x: Array, device: Device, /, *, stream: int | object | None = None) -> Array: ... +def size(x: Array) -> int: ... + +get_namespace = array_namespace diff --git a/scipy-stubs/_lib/array_api_compat/common/_typing.pyi b/scipy-stubs/_lib/array_api_compat/common/_typing.pyi new file mode 100644 index 00000000..e456e950 --- /dev/null +++ b/scipy-stubs/_lib/array_api_compat/common/_typing.pyi @@ -0,0 +1,28 @@ +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"] + +_T_co = TypeVar("_T_co", covariant=True) + +class NestedSequence(Protocol[_T_co]): + def __getitem__(self, key: int, /) -> _T_co | NestedSequence[_T_co]: ... + def __len__(self, /) -> int: ... + +SupportsBufferProtocol: TypeAlias = ( + Buffer + | bytes + | bytearray + | memoryview + | _array.array[Any] + | mmap.mmap + | np.ndarray[tuple[int, ...], np.dtype[np.generic]] + | np.generic +) +Array: TypeAlias = op.CanGetitem[op.CanIndex | slice | tuple[op.CanIndex | slice, ...], Array | complex] +Device: TypeAlias = Literal["CPU"] | object diff --git a/scipy-stubs/_lib/decorator.pyi b/scipy-stubs/_lib/decorator.pyi index ad8ec993..fc20bf80 100644 --- a/scipy-stubs/_lib/decorator.pyi +++ b/scipy-stubs/_lib/decorator.pyi @@ -1,7 +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 @@ -51,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/_lib/uarray.pyi b/scipy-stubs/_lib/uarray.pyi index fae3244e..972e820f 100644 --- a/scipy-stubs/_lib/uarray.pyi +++ b/scipy-stubs/_lib/uarray.pyi @@ -1,3 +1 @@ -from uarray import * - from ._uarray import * diff --git a/scipy-stubs/_typing.pyi b/scipy-stubs/_typing.pyi index 27e45b76..59aab861 100644 --- a/scipy-stubs/_typing.pyi +++ b/scipy-stubs/_typing.pyi @@ -1,9 +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 -from typing_extensions import LiteralString, TypeVar +import optype.numpy as onpt __all__ = [ "AnyBool", @@ -16,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 26ca4fb1..ebffcf50 100644 --- a/scipy-stubs/cluster/__init__.pyi +++ b/scipy-stubs/cluster/__init__.pyi @@ -1,3 +1,3 @@ -from . import hierarchy as hierarchy, vq as vq 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 7020c3ed..62e8ea15 100644 --- a/scipy-stubs/cluster/hierarchy.pyi +++ b/scipy-stubs/cluster/hierarchy.pyi @@ -1,7 +1,41 @@ -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 +from scipy._lib._disjoint_set import DisjointSet from scipy._typing import Untyped +__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): ... def int_floor(arr, xp) -> Untyped: ... @@ -23,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 0ca4d6e0..61075dfc 100644 --- a/scipy-stubs/cluster/vq.pyi +++ b/scipy-stubs/cluster/vq.pyi @@ -1,15 +1,6 @@ -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._typing import Untyped -from scipy.spatial.distance import cdist as cdist -__docformat__: str +__all__ = ["kmeans", "kmeans2", "vq", "whiten"] class ClusterError(Exception): ... @@ -17,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/_codata.pyi b/scipy-stubs/constants/_codata.pyi index 130fd778..729c69d6 100644 --- a/scipy-stubs/constants/_codata.pyi +++ b/scipy-stubs/constants/_codata.pyi @@ -1,5 +1,4 @@ from typing import Final, Literal, TypeAlias - from typing_extensions import LiteralString __all__ = ["ConstantWarning", "find", "physical_constants", "precision", "unit", "value"] diff --git a/scipy-stubs/datasets/_fetchers.pyi b/scipy-stubs/datasets/_fetchers.pyi index 57c58dbe..3a22b4f6 100644 --- a/scipy-stubs/datasets/_fetchers.pyi +++ b/scipy-stubs/datasets/_fetchers.pyi @@ -1,5 +1,5 @@ -from ._registry import registry as registry, registry_urls as registry_urls 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 a4bda1a2..be4c9f84 100644 --- a/scipy-stubs/datasets/_utils.pyi +++ b/scipy-stubs/datasets/_utils.pyi @@ -1,4 +1,4 @@ -from ._registry import method_files_map as method_files_map 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.pyi b/scipy-stubs/fft/_basic.pyi index c692330e..899efd53 100644 --- a/scipy-stubs/fft/_basic.pyi +++ b/scipy-stubs/fft/_basic.pyi @@ -1,4 +1,3 @@ -from scipy._lib.uarray import Dispatchable as Dispatchable, generate_multimethod as generate_multimethod from scipy._typing import Untyped def fft( diff --git a/scipy-stubs/fft/_basic_backend.pyi b/scipy-stubs/fft/_basic_backend.pyi index 5fb0048e..899efd53 100644 --- a/scipy-stubs/fft/_basic_backend.pyi +++ b/scipy-stubs/fft/_basic_backend.pyi @@ -1,9 +1,3 @@ -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, -) from scipy._typing import Untyped def fft( diff --git a/scipy-stubs/fft/_fftlog.pyi b/scipy-stubs/fft/_fftlog.pyi index 03d58dd4..44a31913 100644 --- a/scipy-stubs/fft/_fftlog.pyi +++ b/scipy-stubs/fft/_fftlog.pyi @@ -1,6 +1,7 @@ -from ._fftlog_backend import fhtoffset as fhtoffset -from scipy._lib.uarray import Dispatchable as Dispatchable 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 85136fbc..a3279d93 100644 --- a/scipy-stubs/fft/_fftlog_backend.pyi +++ b/scipy-stubs/fft/_fftlog_backend.pyi @@ -1,11 +1,8 @@ -from ..special import loggamma as loggamma, poch as poch -from ._basic import irfft as irfft, rfft as rfft -from scipy._lib._array_api import array_namespace as array_namespace from scipy._typing import Untyped -LN_2: 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 313156a9..c1d32ca6 100644 --- a/scipy-stubs/fft/_helper.pyi +++ b/scipy-stubs/fft/_helper.pyi @@ -1,14 +1,7 @@ -from scipy._lib._array_api import array_namespace as array_namespace from scipy._typing import Untyped 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 d3c3b3d4..146e8f35 100644 --- a/scipy-stubs/fft/_pocketfft/helper.pyi +++ b/scipy-stubs/fft/_pocketfft/helper.pyi @@ -1,8 +1,8 @@ from collections.abc import Generator -from .pypocketfft import good_size as good_size, prev_good_size as prev_good_size -from scipy._lib._util import copy_if_needed as copy_if_needed -from scipy._typing import Untyped +from .pypocketfft import good_size, prev_good_size -def set_workers(workers) -> Generator[None, None, None]: ... -def get_workers() -> Untyped: ... +__all__ = ["get_workers", "good_size", "prev_good_size", "set_workers"] + +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.pyi b/scipy-stubs/fft/_realtransforms.pyi index b9025897..0ba33b70 100644 --- a/scipy-stubs/fft/_realtransforms.pyi +++ b/scipy-stubs/fft/_realtransforms.pyi @@ -1,4 +1,3 @@ -from scipy._lib.uarray import Dispatchable as Dispatchable from scipy._typing import Untyped def dctn( diff --git a/scipy-stubs/fftpack/_helper.pyi b/scipy-stubs/fftpack/_helper.pyi index 49f0fbf6..80df04a2 100644 --- a/scipy-stubs/fftpack/_helper.pyi +++ b/scipy-stubs/fftpack/_helper.pyi @@ -1,6 +1,7 @@ -from numpy.fft import fftfreq as fftfreq, fftshift as fftshift, ifftshift as ifftshift - +from numpy.fft import fftfreq, fftshift, ifftshift # noqa: ICN003 from scipy._typing import Untyped +__all__ = ["fftfreq", "fftshift", "ifftshift", "next_fast_len", "rfftfreq"] + def rfftfreq(n, d: float = 1.0) -> Untyped: ... def next_fast_len(target) -> Untyped: ... diff --git a/scipy-stubs/fftpack/_pseudo_diffs.pyi b/scipy-stubs/fftpack/_pseudo_diffs.pyi index d996d5e6..baaa5de0 100644 --- a/scipy-stubs/fftpack/_pseudo_diffs.pyi +++ b/scipy-stubs/fftpack/_pseudo_diffs.pyi @@ -1,6 +1,7 @@ -from . import convolve as convolve from scipy._typing import Untyped +__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: ... def itilbert(x, h, period: Untyped | None = None, _cache=...) -> Untyped: ... diff --git a/scipy-stubs/integrate/_bvp.pyi b/scipy-stubs/integrate/_bvp.pyi index 9380983a..a037b7f8 100644 --- a/scipy-stubs/integrate/_bvp.pyi +++ b/scipy-stubs/integrate/_bvp.pyi @@ -1,27 +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 8dfc463b..462b6466 100644 --- a/scipy-stubs/integrate/_ivp/bdf.pyi +++ b/scipy-stubs/integrate/_ivp/bdf.pyi @@ -1,24 +1,12 @@ -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 typing import Final + 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, 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/ivp.pyi b/scipy-stubs/integrate/_ivp/ivp.pyi index 38023525..6cd404aa 100644 --- a/scipy-stubs/integrate/_ivp/ivp.pyi +++ b/scipy-stubs/integrate/_ivp/ivp.pyi @@ -1,11 +1,11 @@ +from scipy._typing import Untyped +from scipy.optimize import OptimizeResult as OptimizeResult from .base import OdeSolver as OdeSolver from .bdf import BDF as BDF from .common import EPS as EPS, OdeSolution as OdeSolution from .lsoda import LSODA as LSODA from .radau import Radau as Radau from .rk import DOP853 as DOP853, RK23 as RK23, RK45 as RK45 -from scipy._typing import Untyped -from scipy.optimize import OptimizeResult as OptimizeResult METHODS: Untyped MESSAGES: Untyped diff --git a/scipy-stubs/integrate/_ivp/lsoda.pyi b/scipy-stubs/integrate/_ivp/lsoda.pyi index bb0261b4..01d53fe4 100644 --- a/scipy-stubs/integrate/_ivp/lsoda.pyi +++ b/scipy-stubs/integrate/_ivp/lsoda.pyi @@ -1,7 +1,7 @@ -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 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 class LSODA(OdeSolver): def __init__( diff --git a/scipy-stubs/integrate/_ivp/radau.pyi b/scipy-stubs/integrate/_ivp/radau.pyi index 464a76ad..cf020a5c 100644 --- a/scipy-stubs/integrate/_ivp/radau.pyi +++ b/scipy-stubs/integrate/_ivp/radau.pyi @@ -1,19 +1,5 @@ -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 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, OdeSolver S6: Untyped C: Untyped diff --git a/scipy-stubs/integrate/_ivp/rk.pyi b/scipy-stubs/integrate/_ivp/rk.pyi index 1082671a..f36eb03a 100644 --- a/scipy-stubs/integrate/_ivp/rk.pyi +++ b/scipy-stubs/integrate/_ivp/rk.pyi @@ -1,16 +1,8 @@ -import numpy as np +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, -) -from scipy._typing import Untyped +import numpy as np +from scipy._typing import Untyped, UntypedArray +from .base import DenseOutput, OdeSolver SAFETY: float MIN_FACTOR: float @@ -19,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 @@ -48,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 33021b0f..01ae77eb 100644 --- a/scipy-stubs/integrate/_quad_vec.pyi +++ b/scipy-stubs/integrate/_quad_vec.pyi @@ -1,12 +1,12 @@ import collections +from typing_extensions import override -from scipy._lib._util import MapWrapper as MapWrapper from scipy._typing import Untyped -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 ff02a28d..2174bbd1 100644 --- a/scipy-stubs/integrate/_quadrature.pyi +++ b/scipy-stubs/integrate/_quadrature.pyi @@ -1,33 +1,62 @@ -from collections.abc import Callable -from typing import Any, NamedTuple, Protocol +from typing import NamedTuple +from typing_extensions import deprecated -from scipy._typing import Untyped -from scipy.special import gammaln as gammaln, logsumexp as logsumexp, roots_legendre as roots_legendre +import numpy.typing as npt +from scipy._typing import Untyped, UntypedCallable, UntypedTuple +from scipy.stats.qmc import QMCEngine -def trapezoid(y, x: Untyped | None = None, dx: float = 1.0, axis: int = -1) -> Untyped: ... +__all__ = [ + "AccuracyWarning", + "cumulative_simpson", + "cumulative_trapezoid", + "fixed_quad", + "newton_cotes", + "qmc_quad", + "quadrature", + "romb", + "romberg", + "simpson", + "trapezoid", +] -class CacheAttributes(Protocol): - cache: dict[int, tuple[Any, Any]] +class AccuracyWarning(Warning): ... -CacheAttributes = Callable +class QMCQuadResult(NamedTuple): + integral: float + standard_error: float -def cache_decorator(func: Callable) -> CacheAttributes: ... -def fixed_quad(func, a, b, args=(), n: int = 5) -> Untyped: ... -def tupleset(t, i, value) -> Untyped: ... +@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 4223b83b..3430648e 100644 --- a/scipy-stubs/integrate/_tanhsinh.pyi +++ b/scipy-stubs/integrate/_tanhsinh.pyi @@ -1,14 +1,3 @@ -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, -) from scipy._typing import Untyped def nsum(f, a, b, *, step: int = 1, args=(), log: bool = False, maxterms=..., tolerances: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_cubic.pyi b/scipy-stubs/interpolate/_cubic.pyi index 7cfbfd80..a2175738 100644 --- a/scipy-stubs/interpolate/_cubic.pyi +++ b/scipy-stubs/interpolate/_cubic.pyi @@ -1,8 +1,8 @@ from typing import Literal -from . import PPoly as PPoly from scipy._typing import Untyped from scipy.linalg import solve as solve, solve_banded as solve_banded +from . import PPoly as PPoly def prepare_input(x, y, axis, dydx: Untyped | None = None) -> Untyped: ... 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 17260818..cfe5e398 100644 --- a/scipy-stubs/interpolate/_fitpack_py.pyi +++ b/scipy-stubs/interpolate/_fitpack_py.pyi @@ -1,6 +1,6 @@ +from scipy._typing import Untyped from ._bsplines import BSpline as BSpline from ._fitpack_impl import bisplev as bisplev, bisplrep as bisplrep, dblint as dblint -from scipy._typing import Untyped def splprep( x, diff --git a/scipy-stubs/interpolate/_interpolate.pyi b/scipy-stubs/interpolate/_interpolate.pyi index d77fbe4d..837d89fb 100644 --- a/scipy-stubs/interpolate/_interpolate.pyi +++ b/scipy-stubs/interpolate/_interpolate.pyi @@ -1,8 +1,8 @@ -from ._bsplines import BSpline as BSpline, make_interp_spline as make_interp_spline -from ._polyint import _Interpolator1D from scipy._lib._util import copy_if_needed as copy_if_needed from scipy._typing import Untyped from scipy.special import comb as comb +from ._bsplines import BSpline as BSpline, make_interp_spline as make_interp_spline +from ._polyint import _Interpolator1D def lagrange(x, w) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_ndgriddata.pyi b/scipy-stubs/interpolate/_ndgriddata.pyi index 7fb00933..407429b3 100644 --- a/scipy-stubs/interpolate/_ndgriddata.pyi +++ b/scipy-stubs/interpolate/_ndgriddata.pyi @@ -1,15 +1,34 @@ -from .interpnd import ( - CloughTocher2DInterpolator as CloughTocher2DInterpolator, - LinearNDInterpolator as LinearNDInterpolator, - NDInterpolatorBase as NDInterpolatorBase, -) +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 scipy.spatial import cKDTree as cKDTree +from .interpnd import CloughTocher2DInterpolator, LinearNDInterpolator, NDInterpolatorBase + +__all__ = ["CloughTocher2DInterpolator", "LinearNDInterpolator", "NearestNDInterpolator", "griddata"] class NearestNDInterpolator(NDInterpolatorBase): tree: Untyped values: Untyped - def __init__(self, x, y, rescale: bool = False, tree_options: Untyped | None = None): ... - def __call__(self, *args, **query_options) -> Untyped: ... + @override + def __init__( + self, + /, + x: onpt.AnyIntegerArray | onpt.AnyFloatingArray, + y: onpt.AnyFloatingArray, + rescale: bool = False, + tree_options: Untyped | None = None, + ) -> None: ... + @override + def __call__(self, /, *args: onpt.AnyFloatingArray, **query_options: Untyped) -> npt.NDArray[np.floating[Any]]: ... -def griddata(points, values, xi, method: str = "linear", fill_value=..., rescale: bool = False) -> Untyped: ... +def griddata( + points: onpt.AnyIntegerArray | onpt.AnyFloatingArray, + values: onpt.AnyFloatingArray, + xi: Untyped, + method: str = "linear", + fill_value: float = ..., + rescale: bool = False, +) -> Untyped: ... diff --git a/scipy-stubs/interpolate/_rbfinterp.pyi b/scipy-stubs/interpolate/_rbfinterp.pyi index ba772ea7..f19f1d1c 100644 --- a/scipy-stubs/interpolate/_rbfinterp.pyi +++ b/scipy-stubs/interpolate/_rbfinterp.pyi @@ -1,7 +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 @@ -15,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/_rgi.pyi b/scipy-stubs/interpolate/_rgi.pyi index 6a5d608f..ffff6039 100644 --- a/scipy-stubs/interpolate/_rgi.pyi +++ b/scipy-stubs/interpolate/_rgi.pyi @@ -1,10 +1,7 @@ -from ._bsplines import make_interp_spline as make_interp_spline -from ._cubic import PchipInterpolator as PchipInterpolator -from ._fitpack2 import RectBivariateSpline as RectBivariateSpline -from ._ndbspline import make_ndbspl as make_ndbspl -from ._rgi_cython import evaluate_linear_2d as evaluate_linear_2d, find_indices as find_indices from scipy._typing import Untyped +__all__ = ["RegularGridInterpolator", "interpn"] + class RegularGridInterpolator: method: Untyped bounds_error: Untyped @@ -12,15 +9,22 @@ class RegularGridInterpolator: fill_value: Untyped def __init__( self, - points, - values, + points: Untyped, + values: Untyped, method: str = "linear", bounds_error: bool = True, - fill_value=..., + fill_value: Untyped = ..., *, solver: Untyped | None = None, solver_args: Untyped | None = None, - ): ... - def __call__(self, xi, method: Untyped | None = None, *, nu: Untyped | None = None) -> Untyped: ... + ) -> None: ... + def __call__(self, xi: Untyped, method: Untyped | None = None, *, nu: Untyped | None = None) -> Untyped: ... -def interpn(points, values, xi, method: str = "linear", bounds_error: bool = True, fill_value=...) -> Untyped: ... +def interpn( + points: Untyped, + values: Untyped, + xi: Untyped, + method: str = "linear", + bounds_error: bool = True, + fill_value: Untyped = ..., +) -> Untyped: ... diff --git a/scipy-stubs/interpolate/interpnd.pyi b/scipy-stubs/interpolate/interpnd.pyi new file mode 100644 index 00000000..6e7b2b43 --- /dev/null +++ b/scipy-stubs/interpolate/interpnd.pyi @@ -0,0 +1,44 @@ +from typing import Any +from typing_extensions import override + +import numpy as np +import numpy.typing as npt +import optype.numpy as onpt + +class NDInterpolatorBase: + def __init__( + self, + /, + points: onpt.AnyIntegerArray | onpt.AnyFloatingArray, + values: onpt.AnyFloatingArray, + fill_value: float = ..., + ndim: int | None = None, + rescale: bool = False, + need_contiguous: bool = True, + need_values: bool = True, + ) -> None: ... + def __call__(self, /, *args: onpt.AnyFloatingArray) -> npt.NDArray[np.floating[Any]]: ... + +class LinearNDInterpolator(NDInterpolatorBase): + @override + def __init__( + self, + /, + points: onpt.AnyIntegerArray | onpt.AnyFloatingArray, + values: onpt.AnyFloatingArray, + fill_value: float = ..., + rescale: bool = False, + ) -> None: ... + +class CloughTocher2DInterpolator(NDInterpolatorBase): + @override + def __init__( + self, + /, + points: onpt.AnyIntegerArray | onpt.AnyFloatingArray, + values: onpt.AnyFloatingArray, + fill_value: float = ..., + tol: float = 1e-06, + maxiter: int = 400, + rescale: bool = False, + ) -> None: ... 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/_fortran.pyi b/scipy-stubs/io/_fortran.pyi index bb418c1d..fdbc8232 100644 --- a/scipy-stubs/io/_fortran.pyi +++ b/scipy-stubs/io/_fortran.pyi @@ -1,3 +1,5 @@ +from types import TracebackType + from scipy._typing import Untyped class FortranEOFError(TypeError, OSError): ... @@ -11,4 +13,4 @@ class FortranFile: def read_reals(self, dtype: str = "f8") -> Untyped: ... def close(self): ... def __enter__(self) -> Untyped: ... - def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None): ... + def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None): ... diff --git a/scipy-stubs/io/_harwell_boeing/hb.pyi b/scipy-stubs/io/_harwell_boeing/hb.pyi index d24f7938..89ffeeae 100644 --- a/scipy-stubs/io/_harwell_boeing/hb.pyi +++ b/scipy-stubs/io/_harwell_boeing/hb.pyi @@ -1,6 +1,6 @@ -from ._fortran_format_parser import ExpFormat as ExpFormat, FortranFormatParser as FortranFormatParser, IntFormat as IntFormat 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 class MalformedHeader(Exception): ... class LineOverflow(Warning): ... 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 54321d54..fab7ec4e 100644 --- a/scipy-stubs/io/_mmio.pyi +++ b/scipy-stubs/io/_mmio.pyi @@ -43,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 76f560d6..ab62f980 100644 --- a/scipy-stubs/io/_netcdf.pyi +++ b/scipy-stubs/io/_netcdf.pyi @@ -1,3 +1,5 @@ +from types import TracebackType + from scipy._typing import Untyped IS_PYPY: Untyped @@ -36,7 +38,7 @@ class netcdf_file: def close(self): ... __del__ = close def __enter__(self) -> Untyped: ... - def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None): ... + def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None): ... def createDimension(self, name, length): ... def createVariable(self, name, type, dimensions) -> Untyped: ... def flush(self): ... @@ -46,14 +48,21 @@ class netcdf_variable: data: Untyped dimensions: Untyped maskandscale: Untyped + @property + def isrec(self) -> Untyped: ... + @property + def shape(self) -> Untyped: ... def __init__( - self, data, typecode, size, shape, dimensions, attributes: Untyped | None = None, maskandscale: bool = False + self, + data, + typecode, + size, + shape, + dimensions, + attributes: Untyped | None = None, + 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 7ee0558a..b4016220 100644 --- a/scipy-stubs/io/matlab/_mio.pyi +++ b/scipy-stubs/io/matlab/_mio.pyi @@ -1,7 +1,7 @@ +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 -from scipy._typing import Untyped def mat_reader_factory(file_name, appendmat: bool = True, **kwargs) -> Untyped: ... def loadmat(file_name, mdict: Untyped | None = None, appendmat: bool = True, **kwargs) -> Untyped: ... diff --git a/scipy-stubs/io/matlab/_mio4.pyi b/scipy-stubs/io/matlab/_mio4.pyi index 4c1a738e..66819375 100644 --- a/scipy-stubs/io/matlab/_mio4.pyi +++ b/scipy-stubs/io/matlab/_mio4.pyi @@ -1,14 +1,28 @@ -from ._mio_utils import chars_to_strings as chars_to_strings, squeeze_element as squeeze_element -from ._miobase import ( - MatFileReader as MatFileReader, - arr_dtype_number as arr_dtype_number, - arr_to_chars as arr_to_chars, - convert_dtypes as convert_dtypes, - docfiller as docfiller, - matdims as matdims, - read_dtype as read_dtype, -) from scipy._typing import Untyped +from ._miobase import MatFileReader + +__all__ = [ + "SYS_LITTLE_ENDIAN", + "MatFile4Reader", + "MatFile4Writer", + "VarHeader4", + "VarReader4", + "VarWriter4", + "arr_to_2d", + "mclass_info", + "mdtypes_template", + "miDOUBLE", + "miINT16", + "miINT32", + "miSINGLE", + "miUINT8", + "miUINT16", + "mxCHAR_CLASS", + "mxFULL_CLASS", + "mxSPARSE_CLASS", + "np_to_mtypes", + "order_codes", +] SYS_LITTLE_ENDIAN: Untyped miDOUBLE: int diff --git a/scipy-stubs/io/matlab/_mio5.pyi b/scipy-stubs/io/matlab/_mio5.pyi index 3dc04458..b4a43487 100644 --- a/scipy-stubs/io/matlab/_mio5.pyi +++ b/scipy-stubs/io/matlab/_mio5.pyi @@ -1,3 +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, @@ -19,7 +20,6 @@ from ._mio5_params import ( mxSPARSE_CLASS as mxSPARSE_CLASS, mxSTRUCT_CLASS as mxSTRUCT_CLASS, ) -from ._mio5_utils import VarReader5 as VarReader5 from ._miobase import ( MatFileReader as MatFileReader, MatReadError as MatReadError, @@ -31,8 +31,6 @@ from ._miobase import ( matdims as matdims, read_dtype as read_dtype, ) -from ._streams import ZlibInputStream as ZlibInputStream -from scipy._typing import Untyped class MatFile5Reader(MatFileReader): uint16_codec: Untyped diff --git a/scipy-stubs/io/matlab/_mio5_params.pyi b/scipy-stubs/io/matlab/_mio5_params.pyi index 18718b93..c62d7fb6 100644 --- a/scipy-stubs/io/matlab/_mio5_params.pyi +++ b/scipy-stubs/io/matlab/_mio5_params.pyi @@ -1,7 +1,56 @@ +from typing import Literal +from typing_extensions import Self, override + import numpy as np +from scipy._typing import Untyped, UntypedDict -from ._miobase import convert_dtypes as convert_dtypes -from scipy._typing import Untyped +__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 @@ -36,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/linalg/_basic.pyi b/scipy-stubs/linalg/_basic.pyi index 0d271a9b..abb65c82 100644 --- a/scipy-stubs/linalg/_basic.pyi +++ b/scipy-stubs/linalg/_basic.pyi @@ -2,7 +2,6 @@ from typing import Literal, TypeAlias, overload import numpy as np import numpy.typing as npt - import scipy._typing as spt __all__ = [ @@ -96,6 +95,7 @@ def solve_circulant( ) -> _Array_fc: ... def inv(a: npt.ArrayLike, overwrite_a: bool = False, check_finite: bool = True) -> _Array_fc_2d: ... def det(a: npt.ArrayLike, overwrite_a: bool = False, check_finite: bool = True) -> np.inexact[npt.NBitBase] | _Array_fc: ... + # TODO: lstsq.default_lapack_driver def lstsq( a: npt.ArrayLike, diff --git a/scipy-stubs/linalg/_cythonized_array_utils.pyi b/scipy-stubs/linalg/_cythonized_array_utils.pyi index 8638edaf..fe554468 100644 --- a/scipy-stubs/linalg/_cythonized_array_utils.pyi +++ b/scipy-stubs/linalg/_cythonized_array_utils.pyi @@ -7,10 +7,19 @@ __all__ = ["bandwidth", "ishermitian", "issymmetric"] # see `scipy/linalg/_cythonized_array_utils.pxd` numeric_t: TypeAlias = ( # noqa: PYI042 - np.int8 | np.int16 | np.int32 | np.int64 - | np.uint8 | np.uint16 | np.uint32 | np.uint64 - | np.float32 | np.float64 | np.longdouble - | np.complex64 | np.complex128 + np.int8 + | np.int16 + | np.int32 + | np.int64 + | np.uint8 + | np.uint16 + | np.uint32 + | np.uint64 + | np.float32 + | np.float64 + | np.longdouble + | np.complex64 + | np.complex128 ) def bandwidth(a: npt.NDArray[numeric_t]) -> tuple[int, int]: ... diff --git a/scipy-stubs/linalg/_decomp.pyi b/scipy-stubs/linalg/_decomp.pyi index 460ad1fd..ef7a0f62 100644 --- a/scipy-stubs/linalg/_decomp.pyi +++ b/scipy-stubs/linalg/_decomp.pyi @@ -2,8 +2,7 @@ from typing import Literal, TypeAlias, overload import numpy as np import numpy.typing as npt -import optype as opt - +import optype as op import scipy._typing as spt __all__ = [ @@ -27,8 +26,8 @@ _EigSelect: TypeAlias = Literal["a", "v", "i"] _EigSelectRange: TypeAlias = tuple[spt.AnyReal, spt.AnyReal] _EigHType: TypeAlias = Literal[1, 2, 3] -_EigHSubsetByIndex: TypeAlias = opt.CanIter[opt.CanNext[opt.typing.AnyInt]] -_EigHSubsetByValue: TypeAlias = opt.CanIter[opt.CanNext[spt.AnyReal]] +_EigHSubsetByIndex: TypeAlias = op.CanIter[op.CanNext[op.typing.AnyInt]] +_EigHSubsetByValue: TypeAlias = op.CanIter[op.CanNext[spt.AnyReal]] _LapackDriverE: TypeAlias = Literal["ev", "evd", "evr", "evx"] _LapackDriverG: TypeAlias = Literal["gv", "gvd", "gvx"] @@ -220,7 +219,7 @@ def eigvalsh_tridiagonal( select: _EigSelect = "a", select_range: _EigSelectRange | None = None, check_finite: bool = True, - tol: spt.AnyReal = 0., + tol: spt.AnyReal = 0.0, lapack_driver: _LapackDriverST | _LapackDriverAuto = "auto", ) -> _Array_fc_1d: ... @overload @@ -231,7 +230,7 @@ def eigh_tridiagonal( select: _EigSelect = "a", select_range: _EigSelectRange | None = None, check_finite: bool = True, - tol: spt.AnyReal = 0., + tol: spt.AnyReal = 0.0, lapack_driver: _LapackDriverST | _LapackDriverAuto = "auto", ) -> tuple[_Array_fc_1d, _Array_fc_2d]: ... @overload @@ -242,7 +241,7 @@ def eigh_tridiagonal( select: _EigSelect = "a", select_range: _EigSelectRange | None = None, check_finite: bool = True, - tol: spt.AnyReal = 0., + tol: spt.AnyReal = 0.0, lapack_driver: _LapackDriverST | _LapackDriverAuto = "auto", ) -> _Array_fc_1d: ... @overload diff --git a/scipy-stubs/linalg/_decomp_cossin.pyi b/scipy-stubs/linalg/_decomp_cossin.pyi index ce977b79..1fae89dc 100644 --- a/scipy-stubs/linalg/_decomp_cossin.pyi +++ b/scipy-stubs/linalg/_decomp_cossin.pyi @@ -2,7 +2,7 @@ from typing import Literal, TypeAlias, overload import numpy as np import numpy.typing as npt -import optype as opt +import optype as op __all__ = ["cossin"] @@ -12,9 +12,9 @@ _Array_c_2d: TypeAlias = np.ndarray[tuple[int, int], np.dtype[np.complexfloating @overload def cossin( - X: npt.ArrayLike | opt.CanIter[opt.CanNext[npt.ArrayLike]], - p: opt.typing.AnyInt | None = None, - q: opt.typing.AnyInt | None = None, + X: npt.ArrayLike | op.CanIter[op.CanNext[npt.ArrayLike]], + p: op.typing.AnyInt | None = None, + q: op.typing.AnyInt | None = None, separate: Literal[False] = False, swap_sign: bool = False, compute_u: bool = True, @@ -22,9 +22,9 @@ def cossin( ) -> tuple[_Array_f_2d, _Array_f_2d, _Array_f_2d] | tuple[_Array_c_2d, _Array_f_2d, _Array_c_2d]: ... @overload def cossin( - X: npt.ArrayLike | opt.CanIter[opt.CanNext[npt.ArrayLike]], - p: opt.typing.AnyInt | None = None, - q: opt.typing.AnyInt | None = None, + X: npt.ArrayLike | op.CanIter[op.CanNext[npt.ArrayLike]], + p: op.typing.AnyInt | None = None, + q: op.typing.AnyInt | None = None, *, separate: Literal[True], swap_sign: bool = False, diff --git a/scipy-stubs/linalg/_decomp_qr.pyi b/scipy-stubs/linalg/_decomp_qr.pyi index fec89cbf..cd1ba237 100644 --- a/scipy-stubs/linalg/_decomp_qr.pyi +++ b/scipy-stubs/linalg/_decomp_qr.pyi @@ -118,7 +118,6 @@ def qr( /, check_finite: bool = True, ) -> tuple[tuple[_Array_fc_2d, _Array_fc_2d], _Array_fc_2d, _Array_i_1d]: ... - @overload def qr_multiply( a: npt.ArrayLike, @@ -151,7 +150,6 @@ def qr_multiply( overwrite_a: bool = False, overwrite_c: bool = False, ) -> tuple[_Array_fc_2d, _Array_fc_2d, _Array_i_1d]: ... - @overload def rq( a: npt.ArrayLike, diff --git a/scipy-stubs/linalg/_decomp_schur.pyi b/scipy-stubs/linalg/_decomp_schur.pyi index 85141497..d3e80c99 100644 --- a/scipy-stubs/linalg/_decomp_schur.pyi +++ b/scipy-stubs/linalg/_decomp_schur.pyi @@ -28,5 +28,4 @@ def schur( sort: Literal["lhp", "rhp", "iuc", "ouc"] | Callable[[float, float], bool], check_finite: bool = True, ) -> tuple[_Array_fc_2d, _Array_fc_2d, int]: ... - def rsf2csf(T: npt.ArrayLike, Z: npt.ArrayLike, check_finite: bool = True) -> tuple[_Array_c_2d, _Array_c_2d]: ... diff --git a/scipy-stubs/linalg/_decomp_svd.pyi b/scipy-stubs/linalg/_decomp_svd.pyi index 840fd193..1d61a949 100644 --- a/scipy-stubs/linalg/_decomp_svd.pyi +++ b/scipy-stubs/linalg/_decomp_svd.pyi @@ -2,7 +2,6 @@ from typing import Literal, TypeAlias, overload import numpy as np import numpy.typing as npt - import scipy._typing as spt __all__ = ["diagsvd", "null_space", "orth", "subspace_angles", "svd", "svdvals"] @@ -39,7 +38,6 @@ def svd( check_finite: bool = True, lapack_driver: Literal["gesdd", "gesvd"] = "gesdd", ) -> _Array_f_1d: ... - def svdvals(a: npt.ArrayLike, overwrite_a: bool = False, check_finite: bool = True) -> _Array_f_1d: ... def diagsvd(s: npt.ArrayLike, M: spt.AnyInt, N: spt.AnyInt) -> _Array_f_2d: ... def orth(A: npt.ArrayLike, rcond: spt.AnyReal | None = None) -> _Array_f_2d: ... diff --git a/scipy-stubs/linalg/_expm_frechet.pyi b/scipy-stubs/linalg/_expm_frechet.pyi index 91960f86..d3c5f174 100644 --- a/scipy-stubs/linalg/_expm_frechet.pyi +++ b/scipy-stubs/linalg/_expm_frechet.pyi @@ -33,5 +33,4 @@ def expm_frechet( /, check_finite: bool = True, ) -> _Array_fc_2d: ... - def expm_cond(A: npt.ArrayLike, check_finite: bool = True) -> np.float64: ... diff --git a/scipy-stubs/linalg/_matfuncs.pyi b/scipy-stubs/linalg/_matfuncs.pyi index e0698f20..1594fe81 100644 --- a/scipy-stubs/linalg/_matfuncs.pyi +++ b/scipy-stubs/linalg/_matfuncs.pyi @@ -3,7 +3,6 @@ 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_inv_ssq.pyi b/scipy-stubs/linalg/_matfuncs_inv_ssq.pyi index f58a4197..c579c169 100644 --- a/scipy-stubs/linalg/_matfuncs_inv_ssq.pyi +++ b/scipy-stubs/linalg/_matfuncs_inv_ssq.pyi @@ -1,6 +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/_misc.pyi b/scipy-stubs/linalg/_misc.pyi index e3515e71..79e2aa6e 100644 --- a/scipy-stubs/linalg/_misc.pyi +++ b/scipy-stubs/linalg/_misc.pyi @@ -2,8 +2,7 @@ from typing import Literal import numpy as np import numpy.typing as npt -from numpy.linalg import LinAlgError as LinAlgError - +from numpy.linalg import LinAlgError # noqa: ICN003 from scipy._typing import Untyped __all__ = ["LinAlgError", "LinAlgWarning", "norm"] diff --git a/scipy-stubs/linalg/_sketches.pyi b/scipy-stubs/linalg/_sketches.pyi index 052dd2c0..fa9cacd9 100644 --- a/scipy-stubs/linalg/_sketches.pyi +++ b/scipy-stubs/linalg/_sketches.pyi @@ -1,6 +1,5 @@ import numpy as np import numpy.typing as npt - import scipy._typing as spt from scipy.sparse import csc_matrix diff --git a/scipy-stubs/linalg/_special_matrices.pyi b/scipy-stubs/linalg/_special_matrices.pyi index 2df62368..d0cd9015 100644 --- a/scipy-stubs/linalg/_special_matrices.pyi +++ b/scipy-stubs/linalg/_special_matrices.pyi @@ -2,7 +2,6 @@ from typing import Literal, TypeAlias, overload import numpy as np import numpy.typing as npt - import scipy._typing as spt __all__ = [ @@ -44,26 +43,22 @@ def block_diag(*arrs: npt.ArrayLike) -> _Array_2d: ... def companion(a: npt.ArrayLike) -> _Array_2d: ... def helmert(n: spt.AnyInt, full: bool = False) -> _Array_f8_2d: ... def hilbert(n: spt.AnyInt) -> _Array_f8_2d: ... - @overload def invhilbert(n: spt.AnyInt, exact: Literal[False] = False) -> _Array_f8_2d: ... @overload def invhilbert(n: spt.AnyInt, exact: Literal[True]) -> _Array_i8_2d | _Array_O_2d: ... - @overload def pascal(n: spt.AnyInt, kind: _SymmetryKind = "symmetric", exact: Literal[True] = True) -> _Array_u8_2d | _Array_O_2d: ... @overload def pascal(n: spt.AnyInt, kind: _SymmetryKind = "symmetric", *, exact: Literal[False]) -> _Array_f8_2d: ... @overload def pascal(n: spt.AnyInt, kind: _SymmetryKind, exact: Literal[False], /) -> _Array_f8_2d: ... - @overload def invpascal(n: spt.AnyInt, kind: _SymmetryKind = "symmetric", exact: Literal[True] = True) -> _Array_i8_2d | _Array_O_2d: ... @overload def invpascal(n: spt.AnyInt, kind: _SymmetryKind = "symmetric", *, exact: Literal[False]) -> _Array_f8_2d: ... @overload def invpascal(n: spt.AnyInt, kind: _SymmetryKind, exact: Literal[False], /) -> _Array_f8_2d: ... - def dft(n: spt.AnyInt, scale: Literal["sqrtn", "n"] | None = None) -> _Array_c16_2d: ... def fiedler(a: npt.ArrayLike) -> _Array_2d: ... def fiedler_companion(a: npt.ArrayLike) -> _Array_2d: ... diff --git a/scipy-stubs/linalg/blas.pyi b/scipy-stubs/linalg/blas.pyi index 303f57ac..86a5d475 100644 --- a/scipy-stubs/linalg/blas.pyi +++ b/scipy-stubs/linalg/blas.pyi @@ -3,7 +3,6 @@ from typing import Literal import numpy as np import numpy.typing as npt - import scipy._typing as spt __all__ = ["find_best_blas_type", "get_blas_funcs"] diff --git a/scipy-stubs/linalg/interpolative.pyi b/scipy-stubs/linalg/interpolative.pyi index 8cc17809..441b2d77 100644 --- a/scipy-stubs/linalg/interpolative.pyi +++ b/scipy-stubs/linalg/interpolative.pyi @@ -1,9 +1,8 @@ from typing import SupportsIndex, TypeAlias, TypeVar +from typing_extensions import Never, deprecated import numpy as np import numpy.typing as npt -from typing_extensions import Never, deprecated - import scipy._typing as spt from scipy.sparse.linalg import LinearOperator diff --git a/scipy-stubs/linalg/lapack.pyi b/scipy-stubs/linalg/lapack.pyi index aebf00ff..c08dda71 100644 --- a/scipy-stubs/linalg/lapack.pyi +++ b/scipy-stubs/linalg/lapack.pyi @@ -3,7 +3,6 @@ from typing import Final, Literal import numpy as np import numpy.typing as npt - import scipy._typing as spt __all__ = ["get_lapack_funcs"] diff --git a/scipy-stubs/misc/__init__.pyi b/scipy-stubs/misc/__init__.pyi index 3286abca..157378c8 100644 --- a/scipy-stubs/misc/__init__.pyi +++ b/scipy-stubs/misc/__init__.pyi @@ -1,6 +1,6 @@ +from scipy._typing import Untyped from . import common as common, doccer as doccer from ._common import * -from scipy._typing import Untyped dataset_methods: Untyped 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/_interpolation.pyi b/scipy-stubs/ndimage/_interpolation.pyi index 5e3db8f3..d20acaac 100644 --- a/scipy-stubs/ndimage/_interpolation.pyi +++ b/scipy-stubs/ndimage/_interpolation.pyi @@ -1,7 +1,7 @@ -from ._ni_docstrings import docfiller as docfiller 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: ... def spline_filter(input, order: int = 3, output=..., mode: str = "mirror") -> Untyped: ... diff --git a/scipy-stubs/ndimage/_support_alternative_backends.pyi b/scipy-stubs/ndimage/_support_alternative_backends.pyi deleted file mode 100644 index 876bed71..00000000 --- a/scipy-stubs/ndimage/_support_alternative_backends.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from ._ndimage_api import * -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 scipy._typing import Untyped - -MODULE_NAME: str - -def dispatch_xp(dispatcher, module_name) -> Untyped: ... - -bare_func: Untyped -dispatcher: Untyped -f: Untyped 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 ffb6b50f..298ffc6b 100644 --- a/scipy-stubs/optimize/_cobyla_py.pyi +++ b/scipy-stubs/optimize/_cobyla_py.pyi @@ -1,5 +1,5 @@ -from ._optimize import OptimizeResult as OptimizeResult 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 2b1a2007..e0dc718a 100644 --- a/scipy-stubs/optimize/_constraints.pyi +++ b/scipy-stubs/optimize/_constraints.pyi @@ -1,12 +1,16 @@ -from ._differentiable_functions import ( - IdentityVectorFunction as IdentityVectorFunction, - LinearVectorFunction as LinearVectorFunction, - VectorFunction as VectorFunction, -) -from ._hessian_update_strategy import BFGS as BFGS -from ._optimize import OptimizeWarning as OptimizeWarning from scipy._typing import Untyped -from scipy.sparse import issparse as issparse + +__all__ = ( + "Bounds", + "LinearConstraint", + "NonlinearConstraint", + "PreparedConstraint", + "new_bounds_to_old", + "new_constraint_to_old", + "old_bound_to_new", + "old_constraint_to_new", + "strict_bounds", +) class NonlinearConstraint: fun: Untyped diff --git a/scipy-stubs/optimize/_differentiable_functions.pyi b/scipy-stubs/optimize/_differentiable_functions.pyi index 60a4bba4..7b5724b0 100644 --- a/scipy-stubs/optimize/_differentiable_functions.pyi +++ b/scipy-stubs/optimize/_differentiable_functions.pyi @@ -1,10 +1,8 @@ -from ._hessian_update_strategy import HessianUpdateStrategy as HessianUpdateStrategy -from ._numdiff import approx_derivative as approx_derivative, group_columns as group_columns -from scipy._lib._array_api import array_namespace as array_namespace, xp_atleast_nd as xp_atleast_nd +from typing import Final + from scipy._typing import Untyped -from scipy.sparse.linalg import LinearOperator as LinearOperator -FD_METHODS: Untyped +FD_METHODS: Final = ("2-point", "3-point", "cs") class ScalarFunction: xp: Untyped @@ -17,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 @@ -50,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/_direct_py.pyi b/scipy-stubs/optimize/_direct_py.pyi index d080c675..083e0339 100644 --- a/scipy-stubs/optimize/_direct_py.pyi +++ b/scipy-stubs/optimize/_direct_py.pyi @@ -2,19 +2,20 @@ from collections.abc import Callable, Iterable from typing import Any import numpy.typing as npt - -from ._constraints import Bounds as Bounds, old_bound_to_new as old_bound_to_new from scipy._typing import Untyped -from scipy.optimize import OptimizeResult as OptimizeResult +from ._constraints import Bounds +from ._optimize import OptimizeResult + +__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/_isotonic.pyi b/scipy-stubs/optimize/_isotonic.pyi index 85b8dce0..5b96e048 100644 --- a/scipy-stubs/optimize/_isotonic.pyi +++ b/scipy-stubs/optimize/_isotonic.pyi @@ -1,6 +1,6 @@ import numpy.typing as npt +from ._optimize import OptimizeResult -from ._optimize import OptimizeResult as OptimizeResult -from ._pava_pybind import pava as pava +__all__ = ["isotonic_regression"] def isotonic_regression(y: npt.ArrayLike, *, weights: npt.ArrayLike | None = None, increasing: bool = True) -> OptimizeResult: ... diff --git a/scipy-stubs/optimize/_lbfgsb_py.pyi b/scipy-stubs/optimize/_lbfgsb_py.pyi index 824a8c9e..81b7ca92 100644 --- a/scipy-stubs/optimize/_lbfgsb_py.pyi +++ b/scipy-stubs/optimize/_lbfgsb_py.pyi @@ -1,7 +1,7 @@ -from ._constraints import old_bound_to_new as old_bound_to_new -from ._optimize import MemoizeJac as MemoizeJac, OptimizeResult as OptimizeResult 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 def fmin_l_bfgs_b( func, diff --git a/scipy-stubs/optimize/_linesearch.pyi b/scipy-stubs/optimize/_linesearch.pyi index 38c41344..fb4938d8 100644 --- a/scipy-stubs/optimize/_linesearch.pyi +++ b/scipy-stubs/optimize/_linesearch.pyi @@ -1,5 +1,5 @@ -from ._dcsrch import DCSRCH as DCSRCH 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 1c2ed59c..5fc5f371 100644 --- a/scipy-stubs/optimize/_linprog.pyi +++ b/scipy-stubs/optimize/_linprog.pyi @@ -1,5 +1,5 @@ -from ._optimize import OptimizeResult as OptimizeResult, OptimizeWarning as OptimizeWarning from scipy._typing import Untyped +from ._optimize import OptimizeResult as OptimizeResult, OptimizeWarning as OptimizeWarning __docformat__: str LINPROG_METHODS: Untyped diff --git a/scipy-stubs/optimize/_linprog_highs.pyi b/scipy-stubs/optimize/_linprog_highs.pyi index f15b7de0..e69de29b 100644 --- a/scipy-stubs/optimize/_linprog_highs.pyi +++ b/scipy-stubs/optimize/_linprog_highs.pyi @@ -1,27 +0,0 @@ -from ._highs._highs_constants import ( - CONST_INF as CONST_INF, - HIGHS_OBJECTIVE_SENSE_MINIMIZE as HIGHS_OBJECTIVE_SENSE_MINIMIZE, - HIGHS_SIMPLEX_CRASH_STRATEGY_OFF as HIGHS_SIMPLEX_CRASH_STRATEGY_OFF, - HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_CHOOSE as HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_CHOOSE, - HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_DANTZIG as HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_DANTZIG, - HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_DEVEX as HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_DEVEX, - HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_STEEPEST_EDGE as HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_STEEPEST_EDGE, - HIGHS_SIMPLEX_STRATEGY_DUAL as HIGHS_SIMPLEX_STRATEGY_DUAL, - MESSAGE_LEVEL_NONE as MESSAGE_LEVEL_NONE, - MODEL_STATUS_INFEASIBLE as MODEL_STATUS_INFEASIBLE, - MODEL_STATUS_LOAD_ERROR as MODEL_STATUS_LOAD_ERROR, - MODEL_STATUS_MODEL_EMPTY as MODEL_STATUS_MODEL_EMPTY, - MODEL_STATUS_MODEL_ERROR as MODEL_STATUS_MODEL_ERROR, - MODEL_STATUS_NOTSET as MODEL_STATUS_NOTSET, - MODEL_STATUS_OPTIMAL as MODEL_STATUS_OPTIMAL, - MODEL_STATUS_POSTSOLVE_ERROR as MODEL_STATUS_POSTSOLVE_ERROR, - MODEL_STATUS_PRESOLVE_ERROR as MODEL_STATUS_PRESOLVE_ERROR, - MODEL_STATUS_REACHED_ITERATION_LIMIT as MODEL_STATUS_REACHED_ITERATION_LIMIT, - MODEL_STATUS_REACHED_OBJECTIVE_TARGET as MODEL_STATUS_REACHED_OBJECTIVE_TARGET, - MODEL_STATUS_REACHED_TIME_LIMIT as MODEL_STATUS_REACHED_TIME_LIMIT, - MODEL_STATUS_SOLVE_ERROR as MODEL_STATUS_SOLVE_ERROR, - MODEL_STATUS_UNBOUNDED as MODEL_STATUS_UNBOUNDED, - MODEL_STATUS_UNBOUNDED_OR_INFEASIBLE as MODEL_STATUS_UNBOUNDED_OR_INFEASIBLE, -) -from ._optimize import OptimizeResult as OptimizeResult, OptimizeWarning as OptimizeWarning -from scipy.sparse import csc_matrix as csc_matrix, issparse as issparse, vstack as vstack diff --git a/scipy-stubs/optimize/_linprog_ip.pyi b/scipy-stubs/optimize/_linprog_ip.pyi index 9ebee0c5..25e77744 100644 --- a/scipy-stubs/optimize/_linprog_ip.pyi +++ b/scipy-stubs/optimize/_linprog_ip.pyi @@ -1,5 +1,5 @@ -from ._optimize import OptimizeResult as OptimizeResult, OptimizeWarning as OptimizeWarning from scipy.linalg import LinAlgError as LinAlgError +from ._optimize import OptimizeResult as OptimizeResult, OptimizeWarning as OptimizeWarning has_umfpack: bool has_cholmod: bool diff --git a/scipy-stubs/optimize/_linprog_rs.pyi b/scipy-stubs/optimize/_linprog_rs.pyi index 05d88a64..e69de29b 100644 --- a/scipy-stubs/optimize/_linprog_rs.pyi +++ b/scipy-stubs/optimize/_linprog_rs.pyi @@ -1,3 +0,0 @@ -from ._bglu_dense import LU as LU -from ._optimize import OptimizeResult as OptimizeResult -from scipy.linalg import solve as solve diff --git a/scipy-stubs/optimize/_linprog_util.pyi b/scipy-stubs/optimize/_linprog_util.pyi index 1a2c453b..a31feb29 100644 --- a/scipy-stubs/optimize/_linprog_util.pyi +++ b/scipy-stubs/optimize/_linprog_util.pyi @@ -1,7 +1,7 @@ from typing import NamedTuple -from ._optimize import OptimizeWarning as OptimizeWarning from scipy._typing import Untyped +from ._optimize import OptimizeWarning as OptimizeWarning class _LPProblem(NamedTuple): c: Untyped diff --git a/scipy-stubs/optimize/_lsap.pyi b/scipy-stubs/optimize/_lsap.pyi new file mode 100644 index 00000000..0c80dbfa --- /dev/null +++ b/scipy-stubs/optimize/_lsap.pyi @@ -0,0 +1,6 @@ +# TODO +from scipy._typing import Untyped + +__all__ = ["linear_sum_assignment"] + +def linear_sum_assignment(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/optimize/_lsq/bvls.pyi b/scipy-stubs/optimize/_lsq/bvls.pyi index 4677d241..e41e16fb 100644 --- a/scipy-stubs/optimize/_lsq/bvls.pyi +++ b/scipy-stubs/optimize/_lsq/bvls.pyi @@ -1,6 +1,6 @@ -from .common import print_header_linear as print_header_linear, print_iteration_linear as print_iteration_linear 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 def compute_kkt_optimality(g, on_bound) -> Untyped: ... def bvls(A, b, x_lsq, lb, ub, tol, max_iter, verbose, rcond: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/optimize/_lsq/dogbox.pyi b/scipy-stubs/optimize/_lsq/dogbox.pyi index ed140f73..5f9a5df9 100644 --- a/scipy-stubs/optimize/_lsq/dogbox.pyi +++ b/scipy-stubs/optimize/_lsq/dogbox.pyi @@ -1,3 +1,6 @@ +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 ( build_quadratic_1d as build_quadratic_1d, check_termination as check_termination, @@ -12,9 +15,6 @@ from .common import ( step_size_to_bound as step_size_to_bound, update_tr_radius as update_tr_radius, ) -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 def lsmr_operator(Jop, d, active_set) -> Untyped: ... def find_intersection(x, tr_bounds, lb, ub) -> Untyped: ... diff --git a/scipy-stubs/optimize/_lsq/least_squares.pyi b/scipy-stubs/optimize/_lsq/least_squares.pyi index 063e8601..f60f4642 100644 --- a/scipy-stubs/optimize/_lsq/least_squares.pyi +++ b/scipy-stubs/optimize/_lsq/least_squares.pyi @@ -1,15 +1,9 @@ -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._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 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: ... @@ -20,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, @@ -44,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 036bef3a..f973b659 100644 --- a/scipy-stubs/optimize/_lsq/lsq_linear.pyi +++ b/scipy-stubs/optimize/_lsq/lsq_linear.pyi @@ -1,16 +1,11 @@ -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 -from scipy._typing import Untyped -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 typing import Final -def prepare_bounds(bounds, n) -> Untyped: ... +from scipy._typing import Untyped +from scipy.optimize import OptimizeResult -TERMINATION_MESSAGES: Untyped +TERMINATION_MESSAGES: Final[dict[int, str]] +def prepare_bounds(bounds, n) -> Untyped: ... def lsq_linear( A, b, @@ -23,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 c23d6d46..ee19d72e 100644 --- a/scipy-stubs/optimize/_lsq/trf.pyi +++ b/scipy-stubs/optimize/_lsq/trf.pyi @@ -1,3 +1,7 @@ +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 from .common import ( CL_scaling_vector as CL_scaling_vector, build_quadratic_1d as build_quadratic_1d, @@ -20,10 +24,6 @@ from .common import ( step_size_to_bound as step_size_to_bound, update_tr_radius as update_tr_radius, ) -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 def trf( fun, jac, x0, f0, J0, lb, ub, ftol, xtol, gtol, max_nfev, x_scale, loss_function, tr_solver, tr_options, verbose diff --git a/scipy-stubs/optimize/_lsq/trf_linear.pyi b/scipy-stubs/optimize/_lsq/trf_linear.pyi index fb540834..5c7dc3c8 100644 --- a/scipy-stubs/optimize/_lsq/trf_linear.pyi +++ b/scipy-stubs/optimize/_lsq/trf_linear.pyi @@ -1,29 +1,48 @@ -from .common import ( - EPS as EPS, - CL_scaling_vector as CL_scaling_vector, - build_quadratic_1d as build_quadratic_1d, - compute_grad as compute_grad, - evaluate_quadratic as evaluate_quadratic, - find_active_constraints as find_active_constraints, - in_bounds as in_bounds, - make_strictly_feasible as make_strictly_feasible, - minimize_quadratic_1d as minimize_quadratic_1d, - print_header_linear as print_header_linear, - print_iteration_linear as print_iteration_linear, - reflective_transformation as reflective_transformation, - regularized_lsq_operator as regularized_lsq_operator, - right_multiplied_operator as right_multiplied_operator, - step_size_to_bound as step_size_to_bound, -) -from .givens_elimination import givens_elimination as givens_elimination from scipy._typing import Untyped -from scipy.linalg import qr as qr, solve_triangular as solve_triangular from scipy.optimize import OptimizeResult as OptimizeResult -from scipy.sparse.linalg import lsmr as lsmr -def regularized_lsq_with_qr(m, n, R, QTb, perm, diag, copy_R: bool = True) -> Untyped: ... -def backtracking(A, g, x, p, theta, p_dot_g, lb, ub) -> Untyped: ... -def select_step(x, A_h, g_h, c_h, p, p_h, d, lb, ub, theta) -> Untyped: ... -def trf_linear( - A, b, x_lsq, lb, ub, tol, lsq_solver, lsmr_tol, max_iter, verbose, *, lsmr_maxiter: Untyped | None = None +def regularized_lsq_with_qr( + m: Untyped, + n: Untyped, + R: Untyped, + QTb: Untyped, + perm: Untyped, + diag: Untyped, + copy_R: bool = True, +) -> Untyped: ... +def backtracking( + A: Untyped, + g: Untyped, + x: Untyped, + p: Untyped, + theta: Untyped, + p_dot_g: Untyped, + lb: Untyped, + ub: Untyped, ) -> Untyped: ... +def select_step( + x: Untyped, + A_h: Untyped, + g_h: Untyped, + c_h: Untyped, + p: Untyped, + p_h: Untyped, + d: Untyped, + lb: Untyped, + ub: Untyped, + theta: Untyped, +) -> Untyped: ... +def trf_linear( + A: Untyped, + b: Untyped, + x_lsq: Untyped, + lb: Untyped, + ub: Untyped, + tol: Untyped, + lsq_solver: Untyped, + lsmr_tol: Untyped, + max_iter: Untyped, + verbose: Untyped, + *, + lsmr_maxiter: Untyped | None = None, +) -> OptimizeResult: ... diff --git a/scipy-stubs/optimize/_milp.pyi b/scipy-stubs/optimize/_milp.pyi index f4949670..854bf8a2 100644 --- a/scipy-stubs/optimize/_milp.pyi +++ b/scipy-stubs/optimize/_milp.pyi @@ -1,8 +1,8 @@ -from ._constraints import Bounds as Bounds, LinearConstraint as LinearConstraint -from ._optimize import OptimizeResult as OptimizeResult 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 def milp( c, diff --git a/scipy-stubs/optimize/_minimize.pyi b/scipy-stubs/optimize/_minimize.pyi index 25f31585..5d5712b9 100644 --- a/scipy-stubs/optimize/_minimize.pyi +++ b/scipy-stubs/optimize/_minimize.pyi @@ -1,20 +1,6 @@ -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 from scipy._typing import Untyped -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 b562a59a..b6dbb557 100644 --- a/scipy-stubs/optimize/_minpack_py.pyi +++ b/scipy-stubs/optimize/_minpack_py.pyi @@ -1,10 +1,6 @@ -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 -from scipy import linalg as linalg from scipy._typing import Untyped -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 + +__all__ = ["curve_fit", "fixed_point", "fsolve", "leastsq"] def fsolve( func, @@ -20,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 7cd11587..1473a39c 100644 --- a/scipy-stubs/optimize/_nonlin.pyi +++ b/scipy-stubs/optimize/_nonlin.pyi @@ -1,15 +1,20 @@ -from ._linesearch import scalar_search_armijo as scalar_search_armijo, scalar_search_wolfe1 as scalar_search_wolfe1 -from scipy._lib._util import copy_if_needed as copy_if_needed +from typing_extensions import override + from scipy._typing import Untyped -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, -) + +__all__ = [ + "BroydenFirst", + "InverseJacobian", + "KrylovJacobian", + "NoConvergence", + "anderson", + "broyden1", + "broyden2", + "diagbroyden", + "excitingmixing", + "linearmixing", + "newton_krylov", +] class NoConvergence(Exception): ... @@ -49,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 @@ -80,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 @@ -93,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): ... @@ -107,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): ... @@ -124,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: ... @@ -151,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: ... @@ -164,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, @@ -172,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 57b618eb..7d5ce02f 100644 --- a/scipy-stubs/optimize/_numdiff.pyi +++ b/scipy-stubs/optimize/_numdiff.pyi @@ -1,14 +1,5 @@ -from ..sparse import ( - coo_matrix as coo_matrix, - csc_matrix as csc_matrix, - csr_matrix as csr_matrix, - find as find, - issparse as issparse, -) -from ._group_columns import group_dense as group_dense, group_sparse as group_sparse -from scipy._lib._array_api import array_namespace as array_namespace, xp_atleast_nd as xp_atleast_nd from scipy._typing import Untyped -from scipy.sparse.linalg import LinearOperator as LinearOperator +from ._group_columns import group_dense as group_dense, group_sparse as group_sparse def group_columns(A, order: int = 0) -> Untyped: ... def approx_derivative( diff --git a/scipy-stubs/optimize/_optimize.pyi b/scipy-stubs/optimize/_optimize.pyi index 7c18b5a4..15b0ecee 100644 --- a/scipy-stubs/optimize/_optimize.pyi +++ b/scipy-stubs/optimize/_optimize.pyi @@ -1,16 +1,29 @@ -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 -from scipy._lib._util import MapWrapper as MapWrapper, _RichResult, check_random_state as check_random_state +from scipy._lib._util import MapWrapper, _RichResult from scipy._typing import Untyped -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 line_search_wolfe2 as line_search -__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 6fd866ee..4932059c 100644 --- a/scipy-stubs/optimize/_qap.pyi +++ b/scipy-stubs/optimize/_qap.pyi @@ -1,6 +1,6 @@ -from . import OptimizeResult as OptimizeResult, linear_sum_assignment as linear_sum_assignment 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 8fc85ddb..19cf0599 100644 --- a/scipy-stubs/optimize/_remove_redundancy.pyi +++ b/scipy-stubs/optimize/_remove_redundancy.pyi @@ -1,6 +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 -def bg_update_dense(plu, perm_r, v, j) -> Untyped: ... +__all__ = ["bg_update_dense"] + +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 f5546ef3..7f1f6fe2 100644 --- a/scipy-stubs/optimize/_root.pyi +++ b/scipy-stubs/optimize/_root.pyi @@ -1,8 +1,7 @@ -from ._minpack_py import leastsq as leastsq -from ._optimize import MemoizeJac as MemoizeJac, OptimizeResult as OptimizeResult from scipy._typing import Untyped +from ._optimize import OptimizeResult -ROOT_METHODS: Untyped +__all__ = ["root"] def root( fun, @@ -13,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 a2abb89d..03eb148d 100644 --- a/scipy-stubs/optimize/_root_scalar.pyi +++ b/scipy-stubs/optimize/_root_scalar.pyi @@ -1,6 +1,7 @@ -from ._numdiff import approx_derivative as approx_derivative from scipy._typing import Untyped +__all__ = ["root_scalar"] + ROOT_SCALAR_METHODS: Untyped class MemoizeDer: diff --git a/scipy-stubs/optimize/_shgo_lib/_complex.pyi b/scipy-stubs/optimize/_shgo_lib/_complex.pyi index 76cc95d1..225a663c 100644 --- a/scipy-stubs/optimize/_shgo_lib/_complex.pyi +++ b/scipy-stubs/optimize/_shgo_lib/_complex.pyi @@ -1,7 +1,7 @@ from collections.abc import Generator -from ._vertex import VertexCacheField as VertexCacheField, VertexCacheIndex as VertexCacheIndex from scipy._typing import Untyped +from ._vertex import VertexCacheField as VertexCacheField, VertexCacheIndex as VertexCacheIndex class Complex: dim: Untyped diff --git a/scipy-stubs/optimize/_shgo_lib/_vertex.pyi b/scipy-stubs/optimize/_shgo_lib/_vertex.pyi index 50b44f30..5da68ba2 100644 --- a/scipy-stubs/optimize/_shgo_lib/_vertex.pyi +++ b/scipy-stubs/optimize/_shgo_lib/_vertex.pyi @@ -1,20 +1,20 @@ -from abc import ABC, abstractmethod +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: ... @@ -32,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, @@ -62,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/_slsqp_py.pyi b/scipy-stubs/optimize/_slsqp_py.pyi index 96b704d3..237adcad 100644 --- a/scipy-stubs/optimize/_slsqp_py.pyi +++ b/scipy-stubs/optimize/_slsqp_py.pyi @@ -1,30 +1,25 @@ -from ._constraints import old_bound_to_new as old_bound_to_new -from ._numdiff import approx_derivative as approx_derivative -from ._optimize import OptimizeResult as OptimizeResult -from scipy._lib._array_api import array_namespace as array_namespace, xp_atleast_nd as xp_atleast_nd from scipy._typing import Untyped -from scipy.optimize._slsqp import slsqp as slsqp -__docformat__: str +__all__ = ["approx_jacobian", "fmin_slsqp"] -def approx_jacobian(x, func, epsilon, *args) -> Untyped: ... +def approx_jacobian(x: Untyped, func: Untyped, epsilon: Untyped, *args: Untyped) -> Untyped: ... def fmin_slsqp( - func, - x0, - eqcons=(), + func: Untyped, + x0: Untyped, + eqcons: Untyped = ..., f_eqcons: Untyped | None = None, - ieqcons=(), + ieqcons: Untyped = ..., f_ieqcons: Untyped | None = None, - bounds=(), + bounds: Untyped = ..., fprime: Untyped | None = None, fprime_eqcons: Untyped | None = None, fprime_ieqcons: Untyped | None = None, - args=(), + args: Untyped = ..., iter: int = 100, acc: float = 1e-06, iprint: int = 1, disp: Untyped | None = None, full_output: int = 0, - epsilon=..., + epsilon: Untyped = ..., callback: Untyped | None = None, ) -> Untyped: ... diff --git a/scipy-stubs/optimize/_tnc.pyi b/scipy-stubs/optimize/_tnc.pyi index 7b517770..017afe09 100644 --- a/scipy-stubs/optimize/_tnc.pyi +++ b/scipy-stubs/optimize/_tnc.pyi @@ -1,8 +1,7 @@ -from ._constraints import old_bound_to_new as old_bound_to_new -from ._optimize import MemoizeJac as MemoizeJac, OptimizeResult as OptimizeResult -from scipy._lib._array_api import array_namespace as array_namespace, xp_atleast_nd as xp_atleast_nd from scipy._typing import Untyped +__all__ = ["fmin_tnc"] + MSG_NONE: int MSG_ITER: int MSG_INFO: int diff --git a/scipy-stubs/optimize/_trlib/__init__.pyi b/scipy-stubs/optimize/_trlib/__init__.pyi index a10b2611..b7082c8d 100644 --- a/scipy-stubs/optimize/_trlib/__init__.pyi +++ b/scipy-stubs/optimize/_trlib/__init__.pyi @@ -1,4 +1,6 @@ -from ._trlib import TRLIBQuadraticSubproblem as TRLIBQuadraticSubproblem from scipy._typing import Untyped +from ._trlib import 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 cae7625a..5e6351a4 100644 --- a/scipy-stubs/optimize/_trustregion.pyi +++ b/scipy-stubs/optimize/_trustregion.pyi @@ -1,8 +1,12 @@ -from ._optimize import OptimizeResult as OptimizeResult +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 +__all__: list[str] = [] + class BaseQuadraticSubproblem: def __init__(self, x, fun, jac, hess: Untyped | None = None, hessp: Untyped | None = None): ... def __call__(self, p) -> Untyped: ... @@ -16,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 f744e443..fe490b25 100644 --- a/scipy-stubs/optimize/_trustregion_constr/equality_constrained_sqp.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/equality_constrained_sqp.pyi @@ -1,10 +1,10 @@ +from scipy._typing import Untyped from .projections import projections as projections from .qp_subproblem import ( box_intersections as box_intersections, modified_dogleg as modified_dogleg, projected_cg as projected_cg, ) -from scipy._typing import Untyped def default_scaling(x) -> Untyped: ... def equality_constrained_sqp( diff --git a/scipy-stubs/optimize/_trustregion_constr/minimize_trustregion_constr.pyi b/scipy-stubs/optimize/_trustregion_constr/minimize_trustregion_constr.pyi index 47780fb4..b13866da 100644 --- a/scipy-stubs/optimize/_trustregion_constr/minimize_trustregion_constr.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/minimize_trustregion_constr.pyi @@ -1,13 +1,15 @@ -from .._constraints import ( +from scipy._typing import Untyped +from scipy.optimize._constraints import ( Bounds as Bounds, LinearConstraint as LinearConstraint, NonlinearConstraint as NonlinearConstraint, PreparedConstraint as PreparedConstraint, strict_bounds as strict_bounds, ) -from .._differentiable_functions import ScalarFunction as ScalarFunction, VectorFunction as VectorFunction -from .._hessian_update_strategy import BFGS as BFGS -from .._optimize import OptimizeResult as OptimizeResult +from scipy.optimize._differentiable_functions import ScalarFunction as ScalarFunction, VectorFunction as VectorFunction +from scipy.optimize._hessian_update_strategy import BFGS as BFGS +from scipy.optimize._optimize import OptimizeResult as OptimizeResult +from scipy.sparse.linalg import LinearOperator as LinearOperator from .canonical_constraint import ( CanonicalConstraint as CanonicalConstraint, initial_constraints_as_canonical as initial_constraints_as_canonical, @@ -15,8 +17,6 @@ from .canonical_constraint import ( from .equality_constrained_sqp import equality_constrained_sqp as equality_constrained_sqp from .report import BasicReport as BasicReport, IPReport as IPReport, SQPReport as SQPReport from .tr_interior_point import tr_interior_point as tr_interior_point -from scipy._typing import Untyped -from scipy.sparse.linalg import LinearOperator as LinearOperator TERMINATION_MESSAGES: 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 9177e859..f449e4e5 100644 --- a/scipy-stubs/optimize/_trustregion_constr/tr_interior_point.pyi +++ b/scipy-stubs/optimize/_trustregion_constr/tr_interior_point.pyi @@ -1,6 +1,6 @@ -from .equality_constrained_sqp import equality_constrained_sqp as equality_constrained_sqp 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 class BarrierSubproblem: n_vars: Untyped diff --git a/scipy-stubs/optimize/_trustregion_dogleg.pyi b/scipy-stubs/optimize/_trustregion_dogleg.pyi index f39249cf..4a3c2dbf 100644 --- a/scipy-stubs/optimize/_trustregion_dogleg.pyi +++ b/scipy-stubs/optimize/_trustregion_dogleg.pyi @@ -1,5 +1,5 @@ -from ._trustregion import BaseQuadraticSubproblem as BaseQuadraticSubproblem from scipy._typing import Untyped +from ._trustregion import BaseQuadraticSubproblem as BaseQuadraticSubproblem class DoglegSubproblem(BaseQuadraticSubproblem): def cauchy_point(self) -> Untyped: ... diff --git a/scipy-stubs/optimize/_trustregion_exact.pyi b/scipy-stubs/optimize/_trustregion_exact.pyi index c1f4cfd2..464a303f 100644 --- a/scipy-stubs/optimize/_trustregion_exact.pyi +++ b/scipy-stubs/optimize/_trustregion_exact.pyi @@ -1,11 +1,9 @@ -from ._trustregion import BaseQuadraticSubproblem as BaseQuadraticSubproblem +from typing_extensions import override + +import numpy as np +import numpy.typing as npt from scipy._typing import Untyped -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 def estimate_smallest_singular_value(U) -> Untyped: ... def gershgorin_bounds(H) -> Untyped: ... @@ -23,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 834122eb..15085fb3 100644 --- a/scipy-stubs/optimize/_trustregion_ncg.pyi +++ b/scipy-stubs/optimize/_trustregion_ncg.pyi @@ -1,5 +1,5 @@ -from ._trustregion import BaseQuadraticSubproblem as BaseQuadraticSubproblem from scipy._typing import Untyped +from ._trustregion import BaseQuadraticSubproblem as BaseQuadraticSubproblem class CGSteihaugSubproblem(BaseQuadraticSubproblem): def solve(self, trust_radius) -> Untyped: ... diff --git a/scipy-stubs/optimize/_zeros_py.pyi b/scipy-stubs/optimize/_zeros_py.pyi index 3bc66308..66dbf2da 100644 --- a/scipy-stubs/optimize/_zeros_py.pyi +++ b/scipy-stubs/optimize/_zeros_py.pyi @@ -1,12 +1,16 @@ -from ._optimize import OptimizeResult as OptimizeResult +from typing import Final + from scipy._typing import Untyped +from ._optimize import OptimizeResult as OptimizeResult + +__all__ = ["RootResults", "bisect", "brenth", "brentq", "newton", "ridder", "toms748"] -CONVERGED: str -SIGNERR: str -CONVERR: str -VALUEERR: str -INPROGRESS: str -flag_map: Untyped +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 @@ -61,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/_filter_design.pyi b/scipy-stubs/signal/_filter_design.pyi index 720d722d..7f623a61 100644 --- a/scipy-stubs/signal/_filter_design.pyi +++ b/scipy-stubs/signal/_filter_design.pyi @@ -1,13 +1,11 @@ -from numpy import absolute - -from scipy import optimize as optimize, special as special +import numpy as np 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): ... -abs = absolute +abs = np.absolute def findfreqs(num, den, N, kind: str = "ba") -> Untyped: ... def freqs(b, a, worN: int = 200, plot: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/signal/_fir_filter_design.pyi b/scipy-stubs/signal/_fir_filter_design.pyi index d875753c..2aad0e70 100644 --- a/scipy-stubs/signal/_fir_filter_design.pyi +++ b/scipy-stubs/signal/_fir_filter_design.pyi @@ -1,8 +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, @@ -49,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 f2dc47d7..ec85dacf 100644 --- a/scipy-stubs/signal/_lti_conversion.pyi +++ b/scipy-stubs/signal/_lti_conversion.pyi @@ -1,6 +1,6 @@ -from ._filter_design import normalize as normalize, tf2zpk as tf2zpk, zpk2tf as zpk2tf 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: ... def abcd_normalize( diff --git a/scipy-stubs/signal/_ltisys.pyi b/scipy-stubs/signal/_ltisys.pyi index 709d1300..d5bc3498 100644 --- a/scipy-stubs/signal/_ltisys.pyi +++ b/scipy-stubs/signal/_ltisys.pyi @@ -1,26 +1,28 @@ -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, -) -from scipy import linalg as linalg +from typing_extensions import Self, override + from scipy._typing import Untyped -from scipy.interpolate import make_interp_spline as make_interp_spline + +__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: ... @@ -32,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: ... @@ -55,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 @@ -72,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 @@ -105,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: ... @@ -121,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 80fab125..81b7192c 100644 --- a/scipy-stubs/signal/_peak_finding.pyi +++ b/scipy-stubs/signal/_peak_finding.pyi @@ -1,15 +1,20 @@ from scipy._typing import Untyped -from scipy.stats import scoreatpercentile as scoreatpercentile -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: ... +__all__ = ["argrelextrema", "argrelmax", "argrelmin", "find_peaks", "find_peaks_cwt", "peak_prominences", "peak_widths"] + +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, @@ -20,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 01de185e..b4584780 100644 --- a/scipy-stubs/signal/_savitzky_golay.pyi +++ b/scipy-stubs/signal/_savitzky_golay.pyi @@ -1,12 +1,20 @@ -from ._arraytools import axis_slice as axis_slice -from scipy._lib._util import float_factorial as float_factorial from scipy._typing import Untyped -from scipy.linalg import lstsq as lstsq -from scipy.ndimage import convolve1d as convolve1d 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 7beed951..384150a2 100644 --- a/scipy-stubs/signal/_short_time_fft.pyi +++ b/scipy-stubs/signal/_short_time_fft.pyi @@ -1,32 +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 -PAD_TYPE: Untyped -FFT_MODE_TYPE: Untyped +__all__ = ["ShortTimeFFT"] + +# 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, *, @@ -34,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, @@ -48,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 @@ -135,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: ... @@ -144,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 c20c4bdd..ee519406 100644 --- a/scipy-stubs/signal/_signaltools.pyi +++ b/scipy-stubs/signal/_signaltools.pyi @@ -1,24 +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 ._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 -from scipy import linalg as linalg, ndimage as ndimage -from scipy._typing import Untyped -from scipy.spatial import cKDTree as cKDTree -from scipy.special import lambertw as lambertw +__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: ... @@ -48,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 eb944699..0853d5c6 100644 --- a/scipy-stubs/signal/_spectral_py.pyi +++ b/scipy-stubs/signal/_spectral_py.pyi @@ -1,6 +1,6 @@ +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 -from scipy._typing import Untyped def lombscargle(x, y, freqs, precenter: bool = False, normalize: bool = False) -> Untyped: ... def periodogram( 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 c4bea2c1..41f4071f 100644 --- a/scipy-stubs/signal/_spline_filters.pyi +++ b/scipy-stubs/signal/_spline_filters.pyi @@ -1,3 +1,6 @@ +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 from ._spline import ( @@ -6,9 +9,6 @@ from ._spline import ( symiirorder2_ic_bwd as symiirorder2_ic_bwd, symiirorder2_ic_fwd as symiirorder2_ic_fwd, ) -from scipy._lib._util import normalize_axis_index as normalize_axis_index -from scipy._typing import Untyped -from scipy.interpolate import BSpline as BSpline def spline_filter(Iin, lmbda: float = 5.0) -> Untyped: ... def gauss_spline(x, n) -> Untyped: ... diff --git a/scipy-stubs/signal/_upfirdn.pyi b/scipy-stubs/signal/_upfirdn.pyi index d9aa1725..291c5e3f 100644 --- a/scipy-stubs/signal/_upfirdn.pyi +++ b/scipy-stubs/signal/_upfirdn.pyi @@ -1,8 +1,33 @@ -from ._upfirdn_apply import mode_enum as mode_enum -from scipy._typing import Untyped +from typing import Any, Literal, TypeAlias + +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/sparse/_base.pyi b/scipy-stubs/sparse/_base.pyi index c2f4f8aa..fcc64ca9 100644 --- a/scipy-stubs/sparse/_base.pyi +++ b/scipy-stubs/sparse/_base.pyi @@ -1,18 +1,9 @@ -from typing_extensions import Self +from typing_extensions import Self, override -from ._matrix import spmatrix as spmatrix -from ._sputils import ( - asmatrix as asmatrix, - check_reshape_kwargs as check_reshape_kwargs, - check_shape as check_shape, - get_sum_dtype as get_sum_dtype, - getdtype as getdtype, - isdense as isdense, - isscalarlike as isscalarlike, - matrix as matrix, - validateaxis as validateaxis, -) from scipy._typing import Untyped +from ._matrix import spmatrix as spmatrix + +__all__ = ["SparseEfficiencyWarning", "SparseWarning", "issparse", "isspmatrix", "sparray"] class SparseWarning(Warning): ... class SparseFormatWarning(SparseWarning): ... @@ -22,17 +13,17 @@ MAXPRINT: int class _spbase: __array_priority__: float + maxprint: Untyped @property def ndim(self) -> int: ... - maxprint: Untyped - def __init__(self, arg1, *, maxprint: Untyped | None = None): ... + def __init__(self, arg1: Untyped, *, maxprint: Untyped | None = None) -> None: ... @property - def shape(self) -> Untyped: ... - def reshape(self, *args, **kwargs) -> Untyped: ... - def resize(self, shape): ... - def astype(self, dtype, casting: str = "unsafe", copy: bool = True) -> Untyped: ... + def shape(self) -> tuple[int, ...]: ... + def reshape(self, *args: Untyped, **kwargs: Untyped) -> Untyped: ... + def resize(self, shape: tuple[int, int]) -> None: ... + def astype(self, dtype: Untyped, casting: str = "unsafe", copy: bool = True) -> Untyped: ... def __iter__(self) -> Untyped: ... - def count_nonzero(self, axis: Untyped | None = None): ... + def count_nonzero(self, axis: Untyped | None = None) -> int: ... @property def nnz(self) -> int: ... @property @@ -40,50 +31,52 @@ 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 __bool__(self) -> bool: ... - __nonzero__ = __bool__ - def __len__(self) -> int: ... - def asformat(self, format, copy: bool = False) -> Untyped: ... - def multiply(self, other) -> Untyped: ... - def maximum(self, other) -> Untyped: ... - def minimum(self, other) -> Untyped: ... - def dot(self, other) -> Untyped: ... - def power(self, n, dtype: Untyped | None = None) -> Untyped: ... - def __eq__(self, other) -> Untyped: ... - def __ne__(self, other) -> Untyped: ... - def __lt__(self, other) -> Untyped: ... - def __gt__(self, other) -> Untyped: ... - def __le__(self, other) -> Untyped: ... - def __ge__(self, other) -> Untyped: ... - def __abs__(self) -> Untyped: ... - def __round__(self, ndigits: int = 0) -> Untyped: ... - def __add__(self, other) -> Untyped: ... - def __radd__(self, other) -> Untyped: ... - def __sub__(self, other) -> Untyped: ... - def __rsub__(self, other) -> Untyped: ... - def __mul__(self, other) -> Untyped: ... - def __rmul__(self, other) -> Untyped: ... - def __matmul__(self, other) -> Untyped: ... - def __rmatmul__(self, other) -> Untyped: ... - def __truediv__(self, other) -> Untyped: ... - def __div__(self, other) -> Untyped: ... - def __rtruediv__(self, other) -> Untyped: ... - def __rdiv__(self, other) -> Untyped: ... - def __neg__(self) -> Untyped: ... - def __iadd__(self, other) -> Self: ... - def __isub__(self, other) -> Self: ... - def __imul__(self, other) -> Self: ... - def __idiv__(self, other) -> Self: ... - def __itruediv__(self, other) -> Self: ... - def __pow__(self, *args, **kwargs) -> 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 imag(self) -> Self: ... + def __bool__(self, /) -> 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) -> Self: ... + @override + def __eq__(self, other: Untyped, /) -> Untyped: ... # type: ignore[override] + @override + def __ne__(self, other: Untyped, /) -> Untyped: ... # type: ignore[override] + def __lt__(self, other: Untyped, /) -> Untyped: ... + def __gt__(self, other: Untyped, /) -> Untyped: ... + def __le__(self, other: Untyped, /) -> Untyped: ... + def __ge__(self, other: Untyped, /) -> 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: ... + def __rsub__(self, other: Untyped, /) -> Untyped: ... + def __mul__(self, other: Untyped, /) -> Untyped: ... + def __rmul__(self, other: Untyped, /) -> Untyped: ... + def __matmul__(self, other: Untyped, /) -> Untyped: ... + def __rmatmul__(self, other: Untyped, /) -> Untyped: ... + def __truediv__(self, other: Untyped, /) -> Untyped: ... + def __div__(self, other: Untyped, /) -> Untyped: ... + def __rtruediv__(self, other: Untyped, /) -> Untyped: ... + def __rdiv__(self, other: Untyped, /) -> 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: ... + # 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: ... @@ -94,14 +87,14 @@ 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: ... def trace(self, offset: int = 0) -> Untyped: ... - def setdiag(self, values, k: int = 0): ... + def setdiag(self, values: Untyped, k: int = 0) -> None: ... class sparray: ... -def issparse(x) -> Untyped: ... -def isspmatrix(x) -> Untyped: ... +def issparse(x: Untyped) -> bool: ... +def isspmatrix(x: Untyped) -> bool: ... diff --git a/scipy-stubs/sparse/_bsr.pyi b/scipy-stubs/sparse/_bsr.pyi index b6d6ab69..be0682b6 100644 --- a/scipy-stubs/sparse/_bsr.pyi +++ b/scipy-stubs/sparse/_bsr.pyi @@ -1,28 +1,14 @@ -from ._base import issparse as issparse, sparray as sparray +from collections.abc import Sequence + +import numpy.typing as npt +import scipy._typing as spt +from scipy._typing import Untyped +from ._base import sparray from ._compressed import _cs_matrix from ._data import _minmax_mixin -from ._matrix import spmatrix as spmatrix -from ._sparsetools import ( - bsr_matmat as bsr_matmat, - bsr_matvec as bsr_matvec, - bsr_matvecs as bsr_matvecs, - bsr_sort_indices as bsr_sort_indices, - bsr_tocsr as bsr_tocsr, - bsr_transpose as bsr_transpose, - csr_matmat_maxnnz as csr_matmat_maxnnz, -) -from ._sputils import ( - check_shape as check_shape, - getdata as getdata, - getdtype as getdtype, - isshape as isshape, - to_native as to_native, - upcast as upcast, -) -from scipy._lib._util import copy_if_needed as copy_if_needed -from scipy._typing import Untyped +from ._matrix import spmatrix -__docformat__: str +__all__ = ["bsr_array", "bsr_matrix", "isspmatrix_bsr"] class _bsr_base(_cs_matrix, _minmax_mixin): data: Untyped @@ -30,35 +16,18 @@ class _bsr_base(_cs_matrix, _minmax_mixin): indptr: Untyped def __init__( self, - arg1, - shape: Untyped | None = None, - dtype: Untyped | None = None, + arg1: Untyped, + shape: spt.AnyInt | Sequence[spt.AnyInt] | None = None, + dtype: npt.DTypeLike | None = None, copy: bool = False, - blocksize: Untyped | None = None, + blocksize: tuple[int, int] | None = None, *, maxprint: Untyped | None = None, - ): ... - def check_format(self, full_check: bool = True): ... + ) -> None: ... @property - def blocksize(self) -> tuple: ... - def count_nonzero(self, axis: Untyped | None = None) -> Untyped: ... - def diagonal(self, k: int = 0) -> Untyped: ... - def __getitem__(self, key): ... - def __setitem__(self, key, val) -> None: ... - def tobsr(self, blocksize: Untyped | None = None, copy: bool = False) -> Untyped: ... - def tocsr(self, copy: bool = False) -> Untyped: ... - def tocsc(self, copy: bool = False) -> Untyped: ... - def tocoo(self, copy: bool = True) -> Untyped: ... - def toarray(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - def eliminate_zeros(self): ... - has_canonical_format: bool - def sum_duplicates(self): ... - has_sorted_indices: bool - def sort_indices(self): ... - def prune(self): ... - -def isspmatrix_bsr(x) -> Untyped: ... + def blocksize(self) -> tuple[int, int]: ... class bsr_array(_bsr_base, sparray): ... class bsr_matrix(spmatrix, _bsr_base): ... + +def isspmatrix_bsr(x: Untyped) -> bool: ... diff --git a/scipy-stubs/sparse/_compressed.pyi b/scipy-stubs/sparse/_compressed.pyi index 67ac506b..d9c142f2 100644 --- a/scipy-stubs/sparse/_compressed.pyi +++ b/scipy-stubs/sparse/_compressed.pyi @@ -1,72 +1,39 @@ -from ._base import SparseEfficiencyWarning as SparseEfficiencyWarning, issparse as issparse, sparray as sparray -from ._data import _data_matrix, _minmax_mixin -from ._index import IndexMixin as IndexMixin -from ._sparsetools import ( - csr_column_index1 as csr_column_index1, - csr_column_index2 as csr_column_index2, - csr_row_index as csr_row_index, - csr_row_slice as csr_row_slice, - csr_sample_offsets as csr_sample_offsets, - csr_sample_values as csr_sample_values, - csr_todense as csr_todense, - get_csr_submatrix as get_csr_submatrix, -) -from ._sputils import ( - check_shape as check_shape, - downcast_intp_index as downcast_intp_index, - get_sum_dtype as get_sum_dtype, - getdtype as getdtype, - is_pydata_spmatrix as is_pydata_spmatrix, - isdense as isdense, - isintlike as isintlike, - isscalarlike as isscalarlike, - isshape as isshape, - to_native as to_native, - upcast as upcast, - upcast_char as upcast_char, -) -from scipy._lib._util import copy_if_needed as copy_if_needed +from typing_extensions import override + from scipy._typing import Untyped +from ._data import _data_matrix, _minmax_mixin +from ._index import IndexMixin + +__all__: list[str] = [] class _cs_matrix(_data_matrix, _minmax_mixin, IndexMixin): data: Untyped indices: Untyped indptr: Untyped def __init__( - self, - arg1, + self: Untyped, + arg1: Untyped, shape: Untyped | None = None, dtype: Untyped | None = None, copy: bool = False, *, maxprint: Untyped | None = None, - ): ... - def count_nonzero(self, axis: Untyped | None = None) -> Untyped: ... - def check_format(self, full_check: bool = True): ... - def __eq__(self, other) -> Untyped: ... - def __ne__(self, other) -> Untyped: ... - def __lt__(self, other) -> Untyped: ... - def __gt__(self, other) -> Untyped: ... - def __le__(self, other) -> Untyped: ... - def __ge__(self, other) -> Untyped: ... - def multiply(self, other) -> Untyped: ... - def diagonal(self, k: int = 0) -> Untyped: ... - def maximum(self, other) -> Untyped: ... - def minimum(self, other) -> Untyped: ... - def sum(self, axis: Untyped | None = None, dtype: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - def tocoo(self, copy: bool = True) -> Untyped: ... - def toarray(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - def eliminate_zeros(self): ... + ) -> None: ... + @override + def count_nonzero(self, axis: Untyped | None = None) -> int: ... + def check_format(self, full_check: bool = True) -> Untyped: ... + def eliminate_zeros(self) -> Untyped: ... @property def has_canonical_format(self) -> bool: ... @has_canonical_format.setter - def has_canonical_format(self, val: bool): ... - def sum_duplicates(self): ... + def has_canonical_format(self, val: bool) -> None: ... + def sum_duplicates(self) -> Untyped: ... @property def has_sorted_indices(self) -> bool: ... @has_sorted_indices.setter - def has_sorted_indices(self, val: bool): ... + def has_sorted_indices(self, val: bool) -> None: ... def sorted_indices(self) -> Untyped: ... - def sort_indices(self): ... - def prune(self): ... - def resize(self, *shape): ... + def sort_indices(self) -> None: ... + def prune(self) -> None: ... + @override + def resize(self, *shape: int) -> None: ... # type: ignore[override] diff --git a/scipy-stubs/sparse/_construct.pyi b/scipy-stubs/sparse/_construct.pyi index cbc6d039..d30c7ddc 100644 --- a/scipy-stubs/sparse/_construct.pyi +++ b/scipy-stubs/sparse/_construct.pyi @@ -1,35 +1,66 @@ -from ._base import issparse as issparse, sparray as sparray -from ._bsr import bsr_array as bsr_array, bsr_matrix as bsr_matrix -from ._coo import coo_array as coo_array, coo_matrix as coo_matrix -from ._csc import csc_array as csc_array, csc_matrix as csc_matrix -from ._csr import csr_array as csr_array, csr_matrix as csr_matrix -from ._dia import dia_array as dia_array, dia_matrix as dia_matrix -from ._sparsetools import csr_hstack as csr_hstack -from ._sputils import get_index_dtype as get_index_dtype, isscalarlike as isscalarlike, upcast as upcast -from scipy._lib._util import check_random_state as check_random_state, rng_integers as rng_integers from scipy._typing import Untyped -__docformat__: str +__all__ = [ + "block_array", + "block_diag", + "bmat", + "diags", + "diags_array", + "eye", + "eye_array", + "hstack", + "identity", + "kron", + "kronsum", + "rand", + "random", + "random_array", + "spdiags", + "vstack", +] -def spdiags(data, diags, m: Untyped | None = None, n: Untyped | None = None, format: Untyped | None = None) -> Untyped: ... +def spdiags( + data: Untyped, + diags: Untyped, + m: Untyped | None = None, + n: Untyped | None = None, + format: Untyped | None = None, +) -> Untyped: ... def diags_array( - diagonals, /, *, offsets: int = 0, shape: Untyped | None = None, format: Untyped | None = None, dtype: Untyped | None = None + diagonals: Untyped, + /, + *, + offsets: int = 0, + shape: Untyped | None = None, + format: Untyped | None = None, + dtype: Untyped | None = None, ) -> Untyped: ... def diags( - diagonals, offsets: int = 0, shape: Untyped | None = None, format: Untyped | None = None, dtype: Untyped | None = None + diagonals: Untyped, + offsets: int = 0, + shape: Untyped | None = None, + format: Untyped | None = None, + dtype: Untyped | None = None, +) -> Untyped: ... +def identity(n: Untyped, dtype: str = "d", format: Untyped | None = None) -> Untyped: ... +def eye_array( + m: Untyped, + n: Untyped | None = None, + *, + k: int = 0, + dtype: Untyped = ..., + format: Untyped | None = None, ) -> Untyped: ... -def identity(n, dtype: str = "d", format: Untyped | None = None) -> Untyped: ... -def eye_array(m, n: Untyped | None = None, *, k: int = 0, dtype=..., format: Untyped | None = None) -> Untyped: ... -def eye(m, n: Untyped | None = None, k: int = 0, dtype=..., format: Untyped | None = None) -> Untyped: ... -def kron(A, B, format: Untyped | None = None) -> Untyped: ... -def kronsum(A, B, format: Untyped | None = None) -> Untyped: ... -def hstack(blocks, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... -def vstack(blocks, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... -def bmat(blocks, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... -def block_array(blocks, *, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... -def block_diag(mats, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... +def eye(m: Untyped, n: Untyped | None = None, k: int = 0, dtype: Untyped = ..., format: Untyped | None = None) -> Untyped: ... +def kron(A: Untyped, B: Untyped, format: Untyped | None = None) -> Untyped: ... +def kronsum(A: Untyped, B: Untyped, format: Untyped | None = None) -> Untyped: ... +def hstack(blocks: Untyped, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... +def vstack(blocks: Untyped, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... +def bmat(blocks: Untyped, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... +def block_array(blocks: Untyped, *, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... +def block_diag(mats: Untyped, format: Untyped | None = None, dtype: Untyped | None = None) -> Untyped: ... def random_array( - shape, + shape: Untyped, *, density: float = 0.01, format: str = "coo", @@ -38,8 +69,8 @@ def random_array( data_sampler: Untyped | None = None, ) -> Untyped: ... def random( - m, - n, + m: Untyped, + n: Untyped, density: float = 0.01, format: str = "coo", dtype: Untyped | None = None, @@ -47,5 +78,10 @@ def random( data_rvs: Untyped | None = None, ) -> Untyped: ... def rand( - m, n, density: float = 0.01, format: str = "coo", dtype: Untyped | None = None, random_state: Untyped | None = None + m: Untyped, + n: Untyped, + density: float = 0.01, + format: str = "coo", + dtype: Untyped | None = None, + random_state: Untyped | None = None, ) -> Untyped: ... diff --git a/scipy-stubs/sparse/_coo.pyi b/scipy-stubs/sparse/_coo.pyi index 41db5e0d..7013a036 100644 --- a/scipy-stubs/sparse/_coo.pyi +++ b/scipy-stubs/sparse/_coo.pyi @@ -1,27 +1,11 @@ -from .._lib._util import copy_if_needed as copy_if_needed -from ._base import SparseEfficiencyWarning as SparseEfficiencyWarning, issparse as issparse, sparray as sparray -from ._data import _data_matrix, _minmax_mixin -from ._matrix import spmatrix as spmatrix -from ._sparsetools import ( - coo_matmat_dense as coo_matmat_dense, - coo_matvec as coo_matvec, - coo_tocsr as coo_tocsr, - coo_todense as coo_todense, -) -from ._sputils import ( - check_reshape_kwargs as check_reshape_kwargs, - check_shape as check_shape, - downcast_intp_index as downcast_intp_index, - get_index_dtype as get_index_dtype, - getdata as getdata, - getdtype as getdtype, - isshape as isshape, - to_native as to_native, - upcast_char as upcast_char, -) +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 -__docformat__: str +__all__ = ["coo_array", "coo_matrix", "isspmatrix_coo"] class _coo_base(_data_matrix, _minmax_mixin): coords: Untyped @@ -29,36 +13,27 @@ class _coo_base(_data_matrix, _minmax_mixin): has_canonical_format: bool def __init__( self, - arg1, + arg1: Untyped, shape: Untyped | None = None, dtype: Untyped | None = None, copy: bool = False, *, maxprint: Untyped | None = None, - ): ... + ) -> None: ... @property def row(self) -> Untyped: ... @row.setter - def row(self, new_row): ... + def row(self, new_row: Untyped) -> None: ... @property def col(self) -> Untyped: ... @col.setter - def col(self, new_col): ... - def reshape(self, *args, **kwargs) -> Untyped: ... - def count_nonzero(self, axis: Untyped | None = None) -> Untyped: ... - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - def resize(self, *shape) -> None: ... - def toarray(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - def tocsc(self, copy: bool = False) -> Untyped: ... - def tocsr(self, copy: bool = False) -> Untyped: ... - def tocoo(self, copy: bool = False) -> Untyped: ... - def todia(self, copy: bool = False) -> Untyped: ... - def todok(self, copy: bool = False) -> Untyped: ... - def diagonal(self, k: int = 0) -> Untyped: ... + def col(self, new_col: Untyped) -> None: ... + @override + def reshape(self, *args: Untyped, **kwargs: Untyped) -> Untyped: ... def sum_duplicates(self) -> None: ... - def eliminate_zeros(self): ... - -def isspmatrix_coo(x) -> Untyped: ... + def eliminate_zeros(self) -> Untyped: ... class coo_array(_coo_base, sparray): ... class coo_matrix(spmatrix, _coo_base): ... + +def isspmatrix_coo(x: Untyped) -> bool: ... diff --git a/scipy-stubs/sparse/_csc.pyi b/scipy-stubs/sparse/_csc.pyi index 083d789f..4866c5b0 100644 --- a/scipy-stubs/sparse/_csc.pyi +++ b/scipy-stubs/sparse/_csc.pyi @@ -1,20 +1,14 @@ -from ._base import sparray as sparray -from ._compressed import _cs_matrix -from ._matrix import spmatrix as spmatrix -from ._sparsetools import csc_tocsr as csc_tocsr, expandptr as expandptr -from ._sputils import upcast as upcast -from scipy._typing import Untyped - -__docformat__: str +from typing_extensions import override -class _csc_base(_cs_matrix): - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - def __iter__(self) -> Untyped: ... - def tocsc(self, copy: bool = False) -> Untyped: ... - def tocsr(self, copy: bool = False) -> Untyped: ... - def nonzero(self) -> Untyped: ... +from scipy._typing import Untyped +from ._base import sparray +from ._compressed import _cs_matrix +from ._matrix import spmatrix -def isspmatrix_csc(x) -> Untyped: ... +__all__ = ["csc_array", "csc_matrix", "isspmatrix_csc"] +class _csc_base(_cs_matrix): ... class csc_array(_csc_base, sparray): ... class csc_matrix(spmatrix, _csc_base): ... + +def isspmatrix_csc(x: Untyped) -> bool: ... diff --git a/scipy-stubs/sparse/_csr.pyi b/scipy-stubs/sparse/_csr.pyi index 7e94b145..3e05c0d2 100644 --- a/scipy-stubs/sparse/_csr.pyi +++ b/scipy-stubs/sparse/_csr.pyi @@ -1,27 +1,14 @@ -from ._base import sparray as sparray -from ._compressed import _cs_matrix -from ._matrix import spmatrix as spmatrix -from ._sparsetools import ( - csr_count_blocks as csr_count_blocks, - csr_sample_values as csr_sample_values, - csr_tobsr as csr_tobsr, - csr_tocsc as csr_tocsc, - get_csr_submatrix as get_csr_submatrix, -) -from ._sputils import upcast as upcast -from scipy._typing import Untyped - -__docformat__: str +from typing_extensions import override -class _csr_base(_cs_matrix): - 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: ... - def tocsc(self, copy: bool = False) -> Untyped: ... - def tobsr(self, blocksize: Untyped | None = None, copy: bool = True) -> Untyped: ... - def __iter__(self) -> Untyped: ... +from scipy._typing import Untyped +from ._base import sparray +from ._compressed import _cs_matrix +from ._matrix import spmatrix -def isspmatrix_csr(x) -> Untyped: ... +__all__ = ["csr_array", "csr_matrix", "isspmatrix_csr"] +class _csr_base(_cs_matrix): ... class csr_array(_csr_base, sparray): ... class csr_matrix(spmatrix, _csr_base): ... + +def isspmatrix_csr(x: Untyped) -> bool: ... diff --git a/scipy-stubs/sparse/_data.pyi b/scipy-stubs/sparse/_data.pyi index 6aed91f2..672b97f8 100644 --- a/scipy-stubs/sparse/_data.pyi +++ b/scipy-stubs/sparse/_data.pyi @@ -1,24 +1,16 @@ -from ._base import _spbase, sparray as sparray -from ._sputils import isscalarlike as isscalarlike, validateaxis as validateaxis +import numpy as np +import numpy.typing as npt from scipy._typing import Untyped +from ._base import _spbase + +__all__: list[str] = [] class _data_matrix(_spbase): - def __init__(self, arg1, *, maxprint: Untyped | None = None): ... + def __init__(self, arg1: Untyped, *, maxprint: Untyped | None = None) -> None: ... @property - def dtype(self) -> Untyped: ... + def dtype(self) -> np.dtype[np.generic]: ... @dtype.setter - def dtype(self, newtype): ... - def __abs__(self) -> Untyped: ... - def __round__(self, ndigits: int = 0) -> Untyped: ... - def __neg__(self) -> Untyped: ... - def __imul__(self, other) -> Untyped: ... - def __itruediv__(self, other) -> Untyped: ... - 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 + def dtype(self, newtype: npt.DTypeLike) -> None: ... 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 657f03c9..fc523bc1 100644 --- a/scipy-stubs/sparse/_dia.pyi +++ b/scipy-stubs/sparse/_dia.pyi @@ -1,42 +1,27 @@ -from .._lib._util import copy_if_needed as copy_if_needed -from ._base import issparse as issparse, sparray as sparray -from ._data import _data_matrix -from ._matrix import spmatrix as spmatrix -from ._sparsetools import dia_matvec as dia_matvec -from ._sputils import ( - check_shape as check_shape, - get_sum_dtype as get_sum_dtype, - getdtype as getdtype, - isshape as isshape, - upcast_char as upcast_char, - validateaxis as validateaxis, -) +from typing_extensions import override + from scipy._typing import Untyped +from ._base import sparray, spmatrix +from ._data import _data_matrix -__docformat__: str +__all__ = ["dia_array", "dia_matrix", "isspmatrix_dia"] class _dia_base(_data_matrix): data: Untyped offsets: Untyped def __init__( self, - arg1, + arg1: Untyped, shape: Untyped | None = None, dtype: Untyped | None = None, copy: bool = False, *, maxprint: Untyped | None = None, - ): ... - def count_nonzero(self, axis: Untyped | None = None) -> Untyped: ... - def sum(self, axis: Untyped | None = None, dtype: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... - def todia(self, copy: bool = False) -> Untyped: ... - def transpose(self, axes: Untyped | None = None, copy: bool = False) -> Untyped: ... - def diagonal(self, k: int = 0) -> Untyped: ... - def tocsc(self, copy: bool = False) -> Untyped: ... - def tocoo(self, copy: bool = False) -> Untyped: ... - def resize(self, *shape): ... - -def isspmatrix_dia(x) -> Untyped: ... + ) -> None: ... + @override + def resize(self, *shape: int): ... # type: ignore[override] class dia_array(_dia_base, sparray): ... class dia_matrix(spmatrix, _dia_base): ... + +def isspmatrix_dia(x: Untyped) -> bool: ... diff --git a/scipy-stubs/sparse/_dok.pyi b/scipy-stubs/sparse/_dok.pyi index 57067534..6f3359ea 100644 --- a/scipy-stubs/sparse/_dok.pyi +++ b/scipy-stubs/sparse/_dok.pyi @@ -1,77 +1,51 @@ -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, -) +# 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 -__docformat__: str +__all__ = ["dok_array", "dok_matrix", "isspmatrix_dok"] -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): ... - 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) -> Untyped: ... - def __truediv__(self, other) -> Untyped: ... - def __itruediv__(self, other) -> Untyped: ... - 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) -> Untyped: ... +def isspmatrix_dok(x: Untyped) -> bool: ... diff --git a/scipy-stubs/sparse/_extract.pyi b/scipy-stubs/sparse/_extract.pyi index 7487c335..e328ead0 100644 --- a/scipy-stubs/sparse/_extract.pyi +++ b/scipy-stubs/sparse/_extract.pyi @@ -1,6 +1,6 @@ +from scipy._typing import Untyped from ._base import sparray as sparray from ._coo import coo_array as coo_array, coo_matrix as coo_matrix -from scipy._typing import Untyped __docformat__: str diff --git a/scipy-stubs/sparse/_index.pyi b/scipy-stubs/sparse/_index.pyi index 0e2c6222..273155a7 100644 --- a/scipy-stubs/sparse/_index.pyi +++ b/scipy-stubs/sparse/_index.pyi @@ -1,9 +1,6 @@ -from ._base import issparse as issparse, sparray as sparray -from ._sputils import isintlike as isintlike +import optype.numpy as onpt from scipy._typing import Untyped -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 7378cebf..e07fbdb8 100644 --- a/scipy-stubs/sparse/_lil.pyi +++ b/scipy-stubs/sparse/_lil.pyi @@ -1,17 +1,11 @@ -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, -) +from typing_extensions import override + from scipy._typing import Untyped +from ._base import _spbase, sparray +from ._index import IndexMixin +from ._matrix import spmatrix -__docformat__: str +__all__ = ["isspmatrix_lil", "lil_array", "lil_matrix"] class _lil_base(_spbase, IndexMixin): dtype: Untyped @@ -19,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) -> Untyped: ... - def __isub__(self, other) -> Untyped: ... - def __imul__(self, other) -> Untyped: ... - 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 0a460dc6..aee27530 100644 --- a/scipy-stubs/sparse/_matrix.pyi +++ b/scipy-stubs/sparse/_matrix.pyi @@ -1,18 +1,20 @@ from scipy._typing import Untyped +__all__ = ["spmatrix"] + class spmatrix: - def __mul__(self, other) -> Untyped: ... - def __rmul__(self, other) -> Untyped: ... - def __pow__(self, power) -> Untyped: ... - __dict__: Untyped - def set_shape(self, shape): ... - def get_shape(self) -> Untyped: ... - shape: Untyped + @property + def shape(self) -> tuple[int, ...]: ... + def __mul__(self, other: Untyped, /) -> Untyped: ... + def __rmul__(self, other: Untyped, /) -> Untyped: ... + def __pow__(self, power: Untyped, /) -> Untyped: ... + def set_shape(self, shape: Untyped) -> None: ... + def get_shape(self) -> tuple[int, ...]: ... def asfptype(self) -> Untyped: ... def getmaxprint(self) -> Untyped: ... def getformat(self) -> Untyped: ... def getnnz(self, axis: Untyped | None = None) -> Untyped: ... def getH(self) -> Untyped: ... - def getcol(self, j) -> Untyped: ... - def getrow(self, i) -> Untyped: ... + def getcol(self, j: int) -> Untyped: ... + def getrow(self, i: int) -> Untyped: ... def todense(self, order: Untyped | None = None, out: Untyped | None = None) -> Untyped: ... diff --git a/scipy-stubs/sparse/_spfuncs.pyi b/scipy-stubs/sparse/_spfuncs.pyi index 946ff991..878d1141 100644 --- a/scipy-stubs/sparse/_spfuncs.pyi +++ b/scipy-stubs/sparse/_spfuncs.pyi @@ -1,7 +1,6 @@ -from ._base import issparse as issparse -from ._csr import csr_array as csr_array -from ._sparsetools import csr_count_blocks as csr_count_blocks from scipy._typing import Untyped -def estimate_blocksize(A, efficiency: float = 0.7) -> Untyped: ... -def count_blocks(A, blocksize) -> Untyped: ... +__all__ = ["count_blocks", "estimate_blocksize"] + +def estimate_blocksize(A: Untyped, efficiency: float = 0.7) -> Untyped: ... +def count_blocks(A: Untyped, blocksize: tuple[int, int]) -> Untyped: ... diff --git a/scipy-stubs/sparse/_sputils.pyi b/scipy-stubs/sparse/_sputils.pyi index 1af0555d..9c1912c1 100644 --- a/scipy-stubs/sparse/_sputils.pyi +++ b/scipy-stubs/sparse/_sputils.pyi @@ -1,10 +1,9 @@ from typing import Any, Literal import numpy as np - 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 +from scipy._typing import Untyped, UntypedArray supported_dtypes: Untyped @@ -14,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/__init__.pyi b/scipy-stubs/sparse/csgraph/__init__.pyi index c5683d9b..1487cdef 100644 --- a/scipy-stubs/sparse/csgraph/__init__.pyi +++ b/scipy-stubs/sparse/csgraph/__init__.pyi @@ -1,35 +1,19 @@ -from ._flow import maximum_flow as maximum_flow -from ._laplacian import laplacian as laplacian -from ._matching import ( - maximum_bipartite_matching as maximum_bipartite_matching, - min_weight_full_bipartite_matching as min_weight_full_bipartite_matching, -) -from ._min_spanning_tree import minimum_spanning_tree as minimum_spanning_tree -from ._reordering import reverse_cuthill_mckee as reverse_cuthill_mckee, structural_rank as structural_rank -from ._shortest_path import ( - NegativeCycleError as NegativeCycleError, - bellman_ford as bellman_ford, - dijkstra as dijkstra, - floyd_warshall as floyd_warshall, - johnson as johnson, - shortest_path as shortest_path, - yen as yen, -) -from ._tools import ( - construct_dist_matrix as construct_dist_matrix, - csgraph_from_dense as csgraph_from_dense, - csgraph_from_masked as csgraph_from_masked, - csgraph_masked_from_dense as csgraph_masked_from_dense, - csgraph_to_dense as csgraph_to_dense, - csgraph_to_masked as csgraph_to_masked, - reconstruct_path as reconstruct_path, -) -from ._traversal import ( - breadth_first_order as breadth_first_order, - breadth_first_tree as breadth_first_tree, - connected_components as connected_components, - depth_first_order as depth_first_order, - depth_first_tree as depth_first_tree, -) +from . import _flow, _laplacian, _matching, _min_spanning_tree, _reordering, _shortest_path, _tools, _traversal +from ._flow import * +from ._laplacian import * +from ._matching import * +from ._min_spanning_tree import * +from ._reordering import * +from ._shortest_path import * +from ._tools import * +from ._traversal import * -__docformat__: str +__all__: list[str] = [] +__all__ += _flow.__all__ +__all__ += _laplacian.__all__ +__all__ += _matching.__all__ +__all__ += _min_spanning_tree.__all__ +__all__ += _reordering.__all__ +__all__ += _shortest_path.__all__ +__all__ += _tools.__all__ +__all__ += _traversal.__all__ diff --git a/scipy-stubs/sparse/csgraph/_flow.pyi b/scipy-stubs/sparse/csgraph/_flow.pyi new file mode 100644 index 00000000..72b4785b --- /dev/null +++ b/scipy-stubs/sparse/csgraph/_flow.pyi @@ -0,0 +1,6 @@ +# TODO +from scipy._typing import Untyped + +__all__ = ["maximum_flow"] + +def maximum_flow(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/sparse/csgraph/_laplacian.pyi b/scipy-stubs/sparse/csgraph/_laplacian.pyi index 8f5890b7..31b18a27 100644 --- a/scipy-stubs/sparse/csgraph/_laplacian.pyi +++ b/scipy-stubs/sparse/csgraph/_laplacian.pyi @@ -1,13 +1,10 @@ +# TODO 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, - is_pydata_spmatrix as is_pydata_spmatrix, -) -from scipy.sparse.linalg import LinearOperator as LinearOperator + +__all__ = ["laplacian"] def laplacian( - csgraph, + csgraph: Untyped, normed: bool = False, return_diag: bool = False, use_out_degree: bool = False, diff --git a/scipy-stubs/sparse/csgraph/_matching.pyi b/scipy-stubs/sparse/csgraph/_matching.pyi new file mode 100644 index 00000000..693954eb --- /dev/null +++ b/scipy-stubs/sparse/csgraph/_matching.pyi @@ -0,0 +1,7 @@ +# TODO +from scipy._typing import Untyped + +__all__ = ["maximum_bipartite_matching", "min_weight_full_bipartite_matching"] + +def maximum_bipartite_matching(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def min_weight_full_bipartite_matching(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/sparse/csgraph/_min_spanning_tree.pyi b/scipy-stubs/sparse/csgraph/_min_spanning_tree.pyi new file mode 100644 index 00000000..c900876f --- /dev/null +++ b/scipy-stubs/sparse/csgraph/_min_spanning_tree.pyi @@ -0,0 +1,6 @@ +# TODO +from scipy._typing import Untyped + +__all__ = ["minimum_spanning_tree"] + +def minimum_spanning_tree(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/sparse/csgraph/_reordering.pyi b/scipy-stubs/sparse/csgraph/_reordering.pyi new file mode 100644 index 00000000..2b6db6ec --- /dev/null +++ b/scipy-stubs/sparse/csgraph/_reordering.pyi @@ -0,0 +1,7 @@ +# TODO +from scipy._typing import Untyped + +__all__ = ["reverse_cuthill_mckee", "structural_rank"] + +def reverse_cuthill_mckee(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def structural_rank(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/sparse/csgraph/_shortest_path.pyi b/scipy-stubs/sparse/csgraph/_shortest_path.pyi new file mode 100644 index 00000000..d6462178 --- /dev/null +++ b/scipy-stubs/sparse/csgraph/_shortest_path.pyi @@ -0,0 +1,13 @@ +# TODO +from scipy._typing import Untyped + +__all__ = ["NegativeCycleError", "bellman_ford", "dijkstra", "floyd_warshall", "johnson", "shortest_path", "yen"] + +class NegativeCycleError(Exception): ... + +def bellman_ford(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def dijkstra(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def floyd_warshall(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def johnson(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def shortest_path(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def yen(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/sparse/csgraph/_tools.pyi b/scipy-stubs/sparse/csgraph/_tools.pyi new file mode 100644 index 00000000..1603f2a2 --- /dev/null +++ b/scipy-stubs/sparse/csgraph/_tools.pyi @@ -0,0 +1,20 @@ +# TODO +from scipy._typing import Untyped + +__all__ = [ + "construct_dist_matrix", + "csgraph_from_dense", + "csgraph_from_masked", + "csgraph_masked_from_dense", + "csgraph_to_dense", + "csgraph_to_masked", + "reconstruct_path", +] + +def construct_dist_matrix(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def csgraph_from_dense(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def csgraph_from_masked(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def csgraph_masked_from_dense(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def csgraph_to_dense(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def csgraph_to_masked(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def reconstruct_path(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/sparse/csgraph/_traversal.pyi b/scipy-stubs/sparse/csgraph/_traversal.pyi new file mode 100644 index 00000000..4bd40937 --- /dev/null +++ b/scipy-stubs/sparse/csgraph/_traversal.pyi @@ -0,0 +1,10 @@ +# TODO +from scipy._typing import Untyped + +__all__ = ["breadth_first_order", "breadth_first_tree", "connected_components", "depth_first_order", "depth_first_tree"] + +def breadth_first_order(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def breadth_first_tree(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def connected_components(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def depth_first_order(*args: Untyped, **kwargs: Untyped) -> Untyped: ... +def depth_first_tree(*args: Untyped, **kwargs: Untyped) -> Untyped: ... diff --git a/scipy-stubs/sparse/csgraph/_validation.pyi b/scipy-stubs/sparse/csgraph/_validation.pyi index 815ebc59..5f308a1f 100644 --- a/scipy-stubs/sparse/csgraph/_validation.pyi +++ b/scipy-stubs/sparse/csgraph/_validation.pyi @@ -1,25 +1,21 @@ +from typing import Final + +import numpy as np +import numpy.typing as npt from scipy._typing import Untyped -from scipy.sparse import csr_matrix as csr_matrix, issparse as issparse -from scipy.sparse._sputils import convert_pydata_sparse_to_scipy as convert_pydata_sparse_to_scipy -from scipy.sparse.csgraph._tools import ( - csgraph_from_dense as csgraph_from_dense, - csgraph_from_masked as csgraph_from_masked, - csgraph_masked_from_dense as csgraph_masked_from_dense, - csgraph_to_dense as csgraph_to_dense, -) -DTYPE: Untyped +DTYPE: Final = np.float64 def validate_graph( - csgraph, - directed, - dtype=..., + csgraph: Untyped, + directed: Untyped, + dtype: npt.DTypeLike = ..., csr_output: bool = True, dense_output: bool = True, copy_if_dense: bool = False, copy_if_sparse: bool = False, null_value_in: int = 0, - null_value_out=..., + null_value_out: Untyped = ..., infinity_null: bool = True, nan_null: bool = True, ) -> Untyped: ... diff --git a/scipy-stubs/sparse/linalg/_dsolve/__init__.pyi b/scipy-stubs/sparse/linalg/_dsolve/__init__.pyi index e6729baf..851d409c 100644 --- a/scipy-stubs/sparse/linalg/_dsolve/__init__.pyi +++ b/scipy-stubs/sparse/linalg/_dsolve/__init__.pyi @@ -1,3 +1,6 @@ -from . import linsolve as linsolve -from ._superlu import SuperLU as SuperLU +from . import linsolve +from ._superlu import SuperLU from .linsolve import * + +__all__ = ["SuperLU"] +__all__ += linsolve.__all__ 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 new file mode 100644 index 00000000..06fb3009 --- /dev/null +++ b/scipy-stubs/sparse/linalg/_dsolve/_superlu.pyi @@ -0,0 +1,18 @@ +from typing import Any + +import numpy as np +import numpy.typing as npt +import optype.numpy as onpt +from scipy.sparse import csc_matrix + +__all__ = ["SuperLU"] + +class SuperLU: + L: csc_matrix + U: csc_matrix + nnz: int + perm_r: onpt.Array[tuple[int], np.intp] + perm_c: onpt.Array[tuple[int], np.intp] + shape: tuple[int, ...] + + def solve(self, /, rhs: npt.NDArray[np.number[Any]]) -> npt.NDArray[np.number[Any]]: ... diff --git a/scipy-stubs/sparse/linalg/_dsolve/linsolve.pyi b/scipy-stubs/sparse/linalg/_dsolve/linsolve.pyi index ae695c51..b96d5dcf 100644 --- a/scipy-stubs/sparse/linalg/_dsolve/linsolve.pyi +++ b/scipy-stubs/sparse/linalg/_dsolve/linsolve.pyi @@ -1,19 +1,6 @@ from scipy._typing import Untyped -from scipy.linalg import LinAlgError as LinAlgError -from scipy.sparse import ( - SparseEfficiencyWarning as SparseEfficiencyWarning, - csc_matrix as csc_matrix, - diags as diags, - 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, -) -noScikit: bool -useUmfpack: Untyped +__all__ = ["MatrixRankWarning", "factorized", "spilu", "splu", "spsolve", "spsolve_triangular", "use_solver"] class MatrixRankWarning(UserWarning): ... @@ -40,5 +27,10 @@ def spilu( ) -> Untyped: ... def factorized(A) -> Untyped: ... def spsolve_triangular( - A, b, lower: bool = True, overwrite_A: bool = False, overwrite_b: bool = False, unit_diagonal: bool = False + A, + b, + lower: bool = True, + overwrite_A: bool = False, + overwrite_b: bool = False, + unit_diagonal: bool = False, ) -> Untyped: ... 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 fef6cdf0..c32b077b 100644 --- a/scipy-stubs/sparse/linalg/_eigen/_svds.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/_svds.pyi @@ -1,11 +1,11 @@ -from . import eigsh as eigsh 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 596b3f22..f7e0a17f 100644 --- a/scipy-stubs/sparse/linalg/_eigen/arpack/arpack.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/arpack/arpack.pyi @@ -1,29 +1,22 @@ -from scipy._lib._threadsafety import ReentrancyLock as ReentrancyLock +from typing import Final + from scipy._typing import Untyped -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 +from scipy.sparse.linalg._interface import LinearOperator + +__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: ... @@ -94,7 +87,6 @@ class _SymmetricArpackParams(_ArpackParams): tol: int = 0, ): ... converged: bool - def iterate(self): ... def extract(self, return_eigenvectors) -> Untyped: ... class _UnsymmetricArpackParams(_ArpackParams): @@ -127,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): ... @@ -158,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 046c0a5a..00000000 --- a/scipy-stubs/sparse/linalg/_eigen/arpack/tests/test_arpack.pyi +++ /dev/null @@ -1,76 +0,0 @@ -from scipy._lib._gcutils import IS_PYPY as IS_PYPY, assert_deallocated as assert_deallocated -from scipy._typing import Untyped -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 8a0d4faa..a705a0ba 100644 --- a/scipy-stubs/sparse/linalg/_eigen/lobpcg/__init__.pyi +++ b/scipy-stubs/sparse/linalg/_eigen/lobpcg/__init__.pyi @@ -1,5 +1,5 @@ -from .lobpcg import * 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/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 e95deae1..00000000 --- a/scipy-stubs/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.pyi +++ /dev/null @@ -1,37 +0,0 @@ -from scipy import sparse as sparse -from scipy._lib._util import np_long as np_long, np_ulong as np_ulong -from scipy._typing import Untyped -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 5f1476d8..b9d75ba1 100644 --- a/scipy-stubs/sparse/linalg/_expm_multiply.pyi +++ b/scipy-stubs/sparse/linalg/_expm_multiply.pyi @@ -1,9 +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 a7730532..920e33f5 100644 --- a/scipy-stubs/sparse/linalg/_interface.pyi +++ b/scipy-stubs/sparse/linalg/_interface.pyi @@ -1,38 +1,52 @@ -from scipy._typing import Untyped -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, -) +from collections.abc import Sequence +from typing import ClassVar, Final, Literal +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 @@ -47,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/iterative.pyi b/scipy-stubs/sparse/linalg/_isolve/iterative.pyi index 3f1d78a7..eb9c1bf9 100644 --- a/scipy-stubs/sparse/linalg/_isolve/iterative.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/iterative.pyi @@ -1,7 +1,7 @@ -from .utils import make_system as make_system 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 def bicg( A, diff --git a/scipy-stubs/sparse/linalg/_isolve/lgmres.pyi b/scipy-stubs/sparse/linalg/_isolve/lgmres.pyi index 5879cf34..9ebee379 100644 --- a/scipy-stubs/sparse/linalg/_isolve/lgmres.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/lgmres.pyi @@ -1,6 +1,6 @@ -from .utils import make_system as make_system from scipy._typing import Untyped from scipy.linalg import get_blas_funcs as get_blas_funcs +from .utils import make_system as make_system def lgmres( A, diff --git a/scipy-stubs/sparse/linalg/_isolve/minres.pyi b/scipy-stubs/sparse/linalg/_isolve/minres.pyi index 78b85bc8..683bf473 100644 --- a/scipy-stubs/sparse/linalg/_isolve/minres.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/minres.pyi @@ -1,5 +1,5 @@ -from .utils import make_system as make_system from scipy._typing import Untyped +from .utils import make_system as make_system def minres( A, diff --git a/scipy-stubs/sparse/linalg/_isolve/tfqmr.pyi b/scipy-stubs/sparse/linalg/_isolve/tfqmr.pyi index ed530c82..26c1bb36 100644 --- a/scipy-stubs/sparse/linalg/_isolve/tfqmr.pyi +++ b/scipy-stubs/sparse/linalg/_isolve/tfqmr.pyi @@ -1,5 +1,5 @@ -from .utils import make_system as make_system from scipy._typing import Untyped +from .utils import make_system as make_system def tfqmr( A, diff --git a/scipy-stubs/sparse/linalg/_matfuncs.pyi b/scipy-stubs/sparse/linalg/_matfuncs.pyi index a7fef360..481ce62d 100644 --- a/scipy-stubs/sparse/linalg/_matfuncs.pyi +++ b/scipy-stubs/sparse/linalg/_matfuncs.pyi @@ -1,30 +1,19 @@ +from typing import Final + from scipy._typing import Untyped -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 +from scipy.sparse.linalg._interface import 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 96ecc20e..510ddec7 100644 --- a/scipy-stubs/sparse/linalg/_norm.pyi +++ b/scipy-stubs/sparse/linalg/_norm.pyi @@ -1,6 +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 98f17609..049a3484 100644 --- a/scipy-stubs/sparse/linalg/_onenormest.pyi +++ b/scipy-stubs/sparse/linalg/_onenormest.pyi @@ -1,5 +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 e7ea69ab..7025ea5b 100644 --- a/scipy-stubs/sparse/linalg/_special_sparse_arrays.pyi +++ b/scipy-stubs/sparse/linalg/_special_sparse_arrays.pyi @@ -1,6 +1,7 @@ from scipy._typing import Untyped -from scipy.sparse import dia_array as dia_array, eye as eye, kron as kron -from scipy.sparse.linalg import LinearOperator as LinearOperator +from scipy.sparse.linalg import LinearOperator + +__all__ = ["LaplacianNd"] class LaplacianNd(LinearOperator): grid_shape: Untyped @@ -13,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: ... @@ -21,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/spatial/__init__.pyi b/scipy-stubs/spatial/__init__.pyi index 67594687..7b902e35 100644 --- a/scipy-stubs/spatial/__init__.pyi +++ b/scipy-stubs/spatial/__init__.pyi @@ -1,3 +1,5 @@ +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 @@ -6,7 +8,5 @@ from ._plotutils import * from ._procrustes import procrustes as procrustes from ._qhull import * from ._spherical_voronoi import SphericalVoronoi as SphericalVoronoi -from scipy._lib._testutils import PytestTester as PytestTester -from scipy._typing import Untyped test: Untyped diff --git a/scipy-stubs/spatial/_ckdtree.pyi b/scipy-stubs/spatial/_ckdtree.pyi index 5f974df2..fa084fc2 100644 --- a/scipy-stubs/spatial/_ckdtree.pyi +++ b/scipy-stubs/spatial/_ckdtree.pyi @@ -1,14 +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 @@ -34,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: ... @@ -109,15 +109,27 @@ class cKDTree(Generic[_BoxT]): return_length: bool = ..., ) -> Any: ... def query_ball_tree( - self, other: cKDTree[npt.NDArray[np.float64] | None], r: float, p: float, eps: float = ..., + self, + other: cKDTree[npt.NDArray[np.float64] | None], + r: float, + p: float, + eps: float = ..., ) -> list[list[int]]: ... @overload def query_pairs( - self, r: float, p: float = ..., eps: float = ..., output_type: Literal["set"] = ..., + self, + r: float, + p: float = ..., + eps: float = ..., + output_type: Literal["set"] = ..., ) -> set[tuple[int, int]]: ... @overload def query_pairs( - self, r: float, p: float = ..., eps: float = ..., output_type: Literal["ndarray"] = ..., + self, + r: float, + p: float = ..., + eps: float = ..., + output_type: Literal["ndarray"] = ..., ) -> npt.NDArray[np.intp]: ... @overload def count_neighbors( @@ -145,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, @@ -154,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 f63d2eee..e244a4f3 100644 --- a/scipy-stubs/spatial/_geometric_slerp.pyi +++ b/scipy-stubs/spatial/_geometric_slerp.pyi @@ -1,6 +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 c1a1e29a..6d30994a 100644 --- a/scipy-stubs/spatial/_kdtree.pyi +++ b/scipy-stubs/spatial/_kdtree.pyi @@ -1,15 +1,14 @@ from typing import TypeVar +from typing_extensions import override import numpy as np import numpy.typing as npt - -from ._ckdtree import cKDTree as cKDTree, cKDTreeNode as cKDTreeNode from scipy._typing import Untyped +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 @@ -22,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 @@ -42,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 @@ -50,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/_qhull.pyi b/scipy-stubs/spatial/_qhull.pyi index d99d33cd..641e6222 100644 --- a/scipy-stubs/spatial/_qhull.pyi +++ b/scipy-stubs/spatial/_qhull.pyi @@ -1,8 +1,8 @@ from typing import Any, TypeAlias +from typing_extensions import final import numpy as np import numpy.typing as npt -from typing_extensions import final __all__ = ["ConvexHull", "Delaunay", "HalfspaceIntersection", "QhullError", "Voronoi", "tsearch"] diff --git a/scipy-stubs/spatial/transform/_rotation_spline.pyi b/scipy-stubs/spatial/transform/_rotation_spline.pyi index 6869fa20..cc86cbd5 100644 --- a/scipy-stubs/spatial/transform/_rotation_spline.pyi +++ b/scipy-stubs/spatial/transform/_rotation_spline.pyi @@ -1,8 +1,7 @@ import numpy as np import numpy.typing as npt - -from ._rotation import Rotation from scipy.interpolate import PPoly +from ._rotation import Rotation __all__ = ["RotationSpline"] diff --git a/scipy-stubs/special/_add_newdocs.pyi b/scipy-stubs/special/_add_newdocs.pyi index 7c0824fa..da950482 100644 --- a/scipy-stubs/special/_add_newdocs.pyi +++ b/scipy-stubs/special/_add_newdocs.pyi @@ -1,5 +1,4 @@ from typing import Final - from typing_extensions import LiteralString __all__ = () diff --git a/scipy-stubs/special/_basic.pyi b/scipy-stubs/special/_basic.pyi index 2af8a46a..12328e30 100644 --- a/scipy-stubs/special/_basic.pyi +++ b/scipy-stubs/special/_basic.pyi @@ -2,10 +2,9 @@ from typing import Literal import numpy as np import numpy.typing as npt -from numpy import sinc - -from ._ufuncs import psi as digamma +from numpy import sinc # noqa: ICN003 from scipy._typing import Untyped +from ._ufuncs import psi as digamma __all__ = [ "ai_zeros", @@ -92,7 +91,6 @@ def fresnelc_zeros(nt: int) -> Untyped: ... def fresnels_zeros(nt: int) -> Untyped: ... def fresnel_zeros(nt: int) -> Untyped: ... def assoc_laguerre(x: float | npt.NDArray[np.float64], n: int, k: float = ...) -> Untyped: ... - def polygamma(n: npt.ArrayLike, x: npt.ArrayLike) -> Untyped: ... def mathieu_even_coef(m: int, q: float) -> Untyped: ... def mathieu_odd_coef(m: int, q: float) -> Untyped: ... 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/_orthogonal.pyi b/scipy-stubs/special/_orthogonal.pyi index 5cc752fa..adc946d6 100644 --- a/scipy-stubs/special/_orthogonal.pyi +++ b/scipy-stubs/special/_orthogonal.pyi @@ -3,7 +3,6 @@ from typing import Literal, TypeAlias, overload import numpy as np import numpy.typing as npt - import scipy._typing as spt _PointsWeights: TypeAlias = tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]] diff --git a/scipy-stubs/special/cython_special.pyi b/scipy-stubs/special/cython_special.pyi index e63d5803..2c9e9e69 100644 --- a/scipy-stubs/special/cython_special.pyi +++ b/scipy-stubs/special/cython_special.pyi @@ -1,6 +1,5 @@ from collections.abc import Callable, Mapping from typing import Final, TypeAlias - from typing_extensions import CapsuleType __all__ = [ diff --git a/scipy-stubs/stats/_binned_statistic.pyi b/scipy-stubs/stats/_binned_statistic.pyi index 22f7adee..b17e70d0 100644 --- a/scipy-stubs/stats/_binned_statistic.pyi +++ b/scipy-stubs/stats/_binned_statistic.pyi @@ -3,7 +3,6 @@ from typing import Literal, NamedTuple, TypeAlias import numpy as np import numpy.typing as npt - from scipy._typing import Untyped __all__ = ["binned_statistic", "binned_statistic_2d", "binned_statistic_dd"] 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/_censored_data.pyi b/scipy-stubs/stats/_censored_data.pyi index ae053f6b..3f76bccf 100644 --- a/scipy-stubs/stats/_censored_data.pyi +++ b/scipy-stubs/stats/_censored_data.pyi @@ -1,6 +1,7 @@ +from typing_extensions import Self + import numpy.typing as npt import optype.numpy as onpt -from typing_extensions import Self __all__ = ["CensoredData"] @@ -16,9 +17,7 @@ class CensoredData: def __sub__(self, other: object, /) -> CensoredData: ... def __truediv__(self, other: object, /) -> CensoredData: ... def __len__(self) -> int: ... - def num_censored(self) -> int: ... - @classmethod def right_censored(cls, x: npt.ArrayLike, censored: onpt.AnyBoolArray) -> Self: ... @classmethod diff --git a/scipy-stubs/stats/_continuous_distns.pyi b/scipy-stubs/stats/_continuous_distns.pyi index 2de954ce..8c947a30 100644 --- a/scipy-stubs/stats/_continuous_distns.pyi +++ b/scipy-stubs/stats/_continuous_distns.pyi @@ -1,5 +1,4 @@ from typing import Final - from typing_extensions import deprecated from ._distn_infrastructure import rv_continuous diff --git a/scipy-stubs/stats/_covariance.pyi b/scipy-stubs/stats/_covariance.pyi index 3472d426..2aae1422 100644 --- a/scipy-stubs/stats/_covariance.pyi +++ b/scipy-stubs/stats/_covariance.pyi @@ -1,10 +1,10 @@ from collections.abc import Sequence from typing import Any, Final, Generic, Protocol, TypeAlias, overload, type_check_only +from typing_extensions import TypeVar import numpy as np import numpy.typing as npt import optype.numpy as onpt -from typing_extensions import TypeVar __all__ = ["Covariance"] diff --git a/scipy-stubs/stats/_distn_infrastructure.pyi b/scipy-stubs/stats/_distn_infrastructure.pyi index 0a53ee9c..94d63c26 100644 --- a/scipy-stubs/stats/_distn_infrastructure.pyi +++ b/scipy-stubs/stats/_distn_infrastructure.pyi @@ -1,12 +1,11 @@ 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 -from typing_extensions import LiteralString, Self, TypeVar, Unpack, override - import scipy._typing as spt __all__ = [ @@ -150,8 +149,8 @@ class rv_discrete_frozen(rv_frozen[_RVD_co], Generic[_RVD_co]): def logpmf(self, /, k: _AnyArray_f8_in) -> _AnyArray_f8_out: ... _ParamT = TypeVar("_ParamT", bound=_Scalar_uif) -_LocT = TypeVar("_LocT", bound=_Scalar_uif) -_ScaleT = TypeVar("_ScaleT", bound=_Scalar_uif) +# _LocT = TypeVar("_LocT", bound=_Scalar_uif) +# _ScaleT = TypeVar("_ScaleT", bound=_Scalar_uif) class rv_generic: # TODO: private methods @@ -193,24 +192,63 @@ class rv_generic: **kwargs: _AnyArray_f8_in, ) -> tuple[_AnyArray_f8_out | None, _AnyArray_f8_out | None, _AnyArray_f8_out | None, _AnyArray_f8_out | None]: ... def _munp(self, /, n: onpt.AnyIntegerArray, *args: _AnyScalar_f8_in) -> npt.NDArray[np.float64]: ... + # TODO: see: https://github.com/KotlinIsland/basedmypy/issues/747 + # ruff: noqa: ERA001 + # @overload + # def _argcheck_rvs( + # self, + # /, + # # NOTE: This `Unpack` trick is only understood by pyright; mypy (still) doesn't fully support `Unpack` (`mypy<=1.11.1`) + # *args: Unpack[tuple[Unpack[tuple[_ParamT, ...]], _LocT, _ScaleT]], + # size: onpt.AnyIntegerArray | None = None, + # ) -> tuple[ + # list[npt.NDArray[_ParamT]], + # npt.NDArray[_LocT], + # npt.NDArray[_ScaleT], + # tuple[int, ...] | tuple[np.intp, ...], + # ]: ... + # @overload + # def _argcheck_rvs( + # self, + # /, + # *args: Unpack[tuple[Unpack[tuple[int, ...]], int, int]], + # size: onpt.AnyIntegerArray | None = None, + # ) -> tuple[ + # list[npt.NDArray[np.intp]], + # npt.NDArray[np.intp], + # npt.NDArray[np.intp], + # tuple[int, ...] | tuple[np.intp, ...], + # ]: ... + # @overload + # def _argcheck_rvs( + # self, + # /, + # *args: Unpack[tuple[Unpack[tuple[float, ...]], float, float]], + # size: onpt.AnyIntegerArray | None = None, + # ) -> tuple[ + # # NOTE: this first union type shouldn't be needed, but is required to work around a pyright bug + # list[npt.NDArray[np.intp]] | list[npt.NDArray[np.intp | np.float64]], + # npt.NDArray[np.intp | np.float64], + # npt.NDArray[np.intp | np.float64], + # tuple[int, ...] | tuple[np.intp, ...], + # ]: ... @overload def _argcheck_rvs( self, /, - # NOTE: This `Unpack` trickery is only understood by pyright; mypy (still) doesn't fully support `Unpack` (`mypy<=1.11.1`) - *args: Unpack[tuple[Unpack[tuple[_ParamT, ...]], _LocT, _ScaleT]], + *args: tuple[_ParamT, ...], size: onpt.AnyIntegerArray | None = None, ) -> tuple[ list[npt.NDArray[_ParamT]], - npt.NDArray[_LocT], - npt.NDArray[_ScaleT], + npt.NDArray[_ParamT], + npt.NDArray[_ParamT], tuple[int, ...] | tuple[np.intp, ...], ]: ... @overload def _argcheck_rvs( self, /, - *args: Unpack[tuple[Unpack[tuple[int, ...]], int, int]], + *args: tuple[int, ...], size: onpt.AnyIntegerArray | None = None, ) -> tuple[ list[npt.NDArray[np.intp]], @@ -222,7 +260,7 @@ class rv_generic: def _argcheck_rvs( self, /, - *args: Unpack[tuple[Unpack[tuple[float, ...]], float, float]], + *args: tuple[float, ...], size: onpt.AnyIntegerArray | None = None, ) -> tuple[ # NOTE: this first union type shouldn't be needed, but is required to work around a pyright bug diff --git a/scipy-stubs/stats/_distr_params.pyi b/scipy-stubs/stats/_distr_params.pyi index 6bd14de9..865bd443 100644 --- a/scipy-stubs/stats/_distr_params.pyi +++ b/scipy-stubs/stats/_distr_params.pyi @@ -1,35 +1,42 @@ from typing import Final - from typing_extensions import LiteralString __all__ = "distcont", "distdiscrete", "invdistcont", "invdistdiscrete" -distcont: Final[list[ - tuple[ - LiteralString, - # 0 - 4 parameters (`'gausshyper'`) - tuple[()] | tuple[float] | tuple[float, float] | tuple[float, float, float] | tuple[float, float, float, float], +distcont: Final[ + list[ + tuple[ + LiteralString, + # 0 - 4 parameters (`'gausshyper'`) + tuple[()] | tuple[float] | tuple[float, float] | tuple[float, float, float] | tuple[float, float, float, float], + ] ] -]] -invdistcont: Final[list[ - tuple[ - LiteralString, - # 0 - 4 parameters (`'gausshyper'`) - tuple[()] | tuple[float] | tuple[float, float] | tuple[float, float, float] | tuple[float, float, float, float], +] +invdistcont: Final[ + list[ + tuple[ + LiteralString, + # 0 - 4 parameters (`'gausshyper'`) + tuple[()] | tuple[float] | tuple[float, float] | tuple[float, float, float] | tuple[float, float, float, float], + ] ] -]] +] -distdiscrete: Final[list[ - tuple[ - LiteralString, - # 1 - 4 parameters (`'nchypergeom_fisher'` and `'nchypergeom_wallenius'`) - tuple[float] | tuple[float, float] | tuple[int, float, float] | tuple[int, int, int, float], +distdiscrete: Final[ + list[ + tuple[ + LiteralString, + # 1 - 4 parameters (`'nchypergeom_fisher'` and `'nchypergeom_wallenius'`) + tuple[float] | tuple[float, float] | tuple[int, float, float] | tuple[int, int, int, float], + ] ] -]] -invdistdiscrete: Final[list[ - tuple[ - LiteralString, - # 1 - 4 parameters (`'nchypergeom_fisher'` and `'nchypergeom_wallenius'`) - tuple[float] | tuple[float, float] | tuple[int, float, float] | tuple[int, int, int, float], +] +invdistdiscrete: Final[ + list[ + tuple[ + LiteralString, + # 1 - 4 parameters (`'nchypergeom_fisher'` and `'nchypergeom_wallenius'`) + tuple[float] | tuple[float, float] | tuple[int, float, float] | tuple[int, int, int, float], + ] ] -]] +] diff --git a/scipy-stubs/stats/_hypotests.pyi b/scipy-stubs/stats/_hypotests.pyi index 5889b4ef..38e1a53c 100644 --- a/scipy-stubs/stats/_hypotests.pyi +++ b/scipy-stubs/stats/_hypotests.pyi @@ -2,53 +2,58 @@ from dataclasses import dataclass from typing import NamedTuple import numpy as np - +from scipy._typing import Untyped, UntypedArray from . import distributions as distributions from ._common import ConfidenceInterval as ConfidenceInterval from ._continuous_distns import norm as norm -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 -class Epps_Singleton_2sampResult(NamedTuple): - statistic: Untyped - pvalue: Untyped - -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: ... +__all__ = [ + "barnard_exact", + "boschloo_exact", + "cramervonmises", + "cramervonmises_2samp", + "epps_singleton_2samp", + "poisson_means_test", + "somersd", + "tukey_hsd", +] -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/_kde.pyi b/scipy-stubs/stats/_kde.pyi index 99fb399e..72d51a34 100644 --- a/scipy-stubs/stats/_kde.pyi +++ b/scipy-stubs/stats/_kde.pyi @@ -1,11 +1,7 @@ -from ._stats import ( - gaussian_kernel_estimate as gaussian_kernel_estimate, - gaussian_kernel_estimate_log as gaussian_kernel_estimate_log, -) -from scipy import linalg as linalg, special as special -from scipy._lib._util import check_random_state as check_random_state from scipy._typing import Untyped +__all__ = ["gaussian_kde"] + class gaussian_kde: dataset: Untyped def __init__(self, dataset, bw_method: Untyped | None = None, weights: Untyped | None = None): ... diff --git a/scipy-stubs/stats/_levy_stable.pyi b/scipy-stubs/stats/_levy_stable.pyi index 05707a85..43d97022 100644 --- a/scipy-stubs/stats/_levy_stable.pyi +++ b/scipy-stubs/stats/_levy_stable.pyi @@ -3,7 +3,6 @@ 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/_mgc.pyi b/scipy-stubs/stats/_mgc.pyi index 27ac9f08..2d7a516a 100644 --- a/scipy-stubs/stats/_mgc.pyi +++ b/scipy-stubs/stats/_mgc.pyi @@ -1,7 +1,7 @@ -from . import distributions as distributions 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 class _ParallelP: x: Untyped diff --git a/scipy-stubs/stats/_morestats.pyi b/scipy-stubs/stats/_morestats.pyi index 909640b8..b6d08e9d 100644 --- a/scipy-stubs/stats/_morestats.pyi +++ b/scipy-stubs/stats/_morestats.pyi @@ -1,20 +1,40 @@ from typing import NamedTuple -from . import distributions as distributions -from ._ansari_swilk_statistics import gscale as gscale, swilk as swilk -from ._distn_infrastructure import rv_generic as rv_generic -from ._fit import FitResult as FitResult -from ._stats_py import SignificanceResult as SignificanceResult, find_repeats as find_repeats -from .contingency import chi2_contingency as chi2_contingency -from scipy import interpolate as interpolate, optimize as optimize, special as special, stats as stats -from scipy._lib._array_api import ( - array_namespace as array_namespace, - xp_moveaxis_to_end as xp_moveaxis_to_end, - xp_size as xp_size, - xp_vector_norm as xp_vector_norm, -) from scipy._typing import Untyped +__all__ = [ + "anderson", + "anderson_ksamp", + "ansari", + "bartlett", + "bayes_mvs", + "boxcox", + "boxcox_llf", + "boxcox_normmax", + "boxcox_normplot", + "circmean", + "circstd", + "circvar", + "directional_stats", + "false_discovery_control", + "fligner", + "kstat", + "kstatvar", + "levene", + "median_test", + "mood", + "mvsdist", + "ppcc_max", + "ppcc_plot", + "probplot", + "shapiro", + "wilcoxon", + "yeojohnson", + "yeojohnson_llf", + "yeojohnson_normmax", + "yeojohnson_normplot", +] + class Mean(NamedTuple): statistic: Untyped minmax: Untyped @@ -32,7 +52,12 @@ def mvsdist(data) -> Untyped: ... def kstat(data, n: int = 2, *, axis: Untyped | None = None) -> Untyped: ... def kstatvar(data, n: int = 2, *, axis: Untyped | None = None) -> Untyped: ... def probplot( - x, sparams=(), dist: str = "norm", fit: bool = True, plot: Untyped | None = None, rvalue: bool = False + x, + sparams=(), + dist: str = "norm", + fit: bool = True, + plot: Untyped | None = None, + rvalue: bool = False, ) -> Untyped: ... def ppcc_max(x, brack=(0.0, 1.0), dist: str = "tukeylambda") -> Untyped: ... def ppcc_plot(x, a, b, dist: str = "tukeylambda", plot: Untyped | None = None, N: int = 80) -> Untyped: ... @@ -42,7 +67,12 @@ def boxcox(x, lmbda: Untyped | None = None, alpha: Untyped | None = None, optimi class _BigFloat: ... def boxcox_normmax( - x, brack: Untyped | None = None, method: str = "pearsonr", optimizer: Untyped | None = None, *, ymax=... + x, + brack: Untyped | None = None, + method: str = "pearsonr", + optimizer: Untyped | None = None, + *, + ymax=..., ) -> Untyped: ... def boxcox_normplot(x, la, lb, plot: Untyped | None = None, N: int = 80) -> Untyped: ... def yeojohnson(x, lmbda: Untyped | None = None) -> Untyped: ... @@ -119,12 +149,22 @@ def wilcoxon( MedianTestResult: Untyped def median_test( - *samples, ties: str = "below", correction: bool = True, lambda_: int = 1, nan_policy: str = "propagate" + *samples, + ties: str = "below", + correction: bool = True, + lambda_: int = 1, + nan_policy: str = "propagate", ) -> Untyped: ... def circmean(samples, high=..., low: int = 0, axis: Untyped | None = None, nan_policy: str = "propagate") -> Untyped: ... def circvar(samples, high=..., low: int = 0, axis: Untyped | None = None, nan_policy: str = "propagate") -> Untyped: ... def circstd( - samples, high=..., low: int = 0, axis: Untyped | None = None, nan_policy: str = "propagate", *, normalize: bool = False + samples, + high=..., + low: int = 0, + axis: Untyped | None = None, + nan_policy: str = "propagate", + *, + normalize: bool = False, ) -> Untyped: ... class DirectionalStats: diff --git a/scipy-stubs/stats/_mstats_basic.pyi b/scipy-stubs/stats/_mstats_basic.pyi index 27303699..9af1ce10 100644 --- a/scipy-stubs/stats/_mstats_basic.pyi +++ b/scipy-stubs/stats/_mstats_basic.pyi @@ -1,7 +1,7 @@ from typing import NamedTuple -from . import distributions as distributions from scipy._typing import Untyped +from . import distributions as distributions def argstoarray(*args) -> Untyped: ... def find_repeats(arr) -> Untyped: ... @@ -10,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: ... @@ -24,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: ... @@ -87,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: ... @@ -151,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/_multicomp.pyi b/scipy-stubs/stats/_multicomp.pyi index 0f9e0706..a9d23150 100644 --- a/scipy-stubs/stats/_multicomp.pyi +++ b/scipy-stubs/stats/_multicomp.pyi @@ -3,17 +3,16 @@ 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 b84a045e..27c77fe2 100644 --- a/scipy-stubs/stats/_multivariate.pyi +++ b/scipy-stubs/stats/_multivariate.pyi @@ -1,17 +1,16 @@ 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 -from typing_extensions import Self, TypeVar, override - import scipy._typing as spt +from scipy.stats import _covariance from ._covariance import Covariance from ._distn_infrastructure import _RNG, _Seed -from scipy.stats import _covariance __all__ = [ "dirichlet", diff --git a/scipy-stubs/stats/_odds_ratio.pyi b/scipy-stubs/stats/_odds_ratio.pyi index 21b3c430..8f07b20a 100644 --- a/scipy-stubs/stats/_odds_ratio.pyi +++ b/scipy-stubs/stats/_odds_ratio.pyi @@ -1,8 +1,8 @@ -from ._common import ConfidenceInterval as ConfidenceInterval -from ._discrete_distns import nchypergeom_fisher as nchypergeom_fisher 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 +from ._discrete_distns import nchypergeom_fisher as nchypergeom_fisher class OddsRatioResult: statistic: Untyped diff --git a/scipy-stubs/stats/_page_trend_test.pyi b/scipy-stubs/stats/_page_trend_test.pyi index a3ec73a0..9dd17060 100644 --- a/scipy-stubs/stats/_page_trend_test.pyi +++ b/scipy-stubs/stats/_page_trend_test.pyi @@ -1,7 +1,7 @@ from dataclasses import dataclass -from ._continuous_distns import norm as norm from scipy._typing import Untyped +from ._continuous_distns import norm as norm @dataclass class PageTrendTestResult: diff --git a/scipy-stubs/stats/_qmc.pyi b/scipy-stubs/stats/_qmc.pyi index 0346952c..57d02ab6 100644 --- a/scipy-stubs/stats/_qmc.pyi +++ b/scipy-stubs/stats/_qmc.pyi @@ -1,34 +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._lib._util import DecimalNumber, IntNumber, SeedType +from scipy._typing import Untyped, UntypedArray -from scipy._lib._util import ( - DecimalNumber as DecimalNumber, - GeneratorType as GeneratorType, - IntNumber as IntNumber, - SeedType as SeedType, - rng_integers as rng_integers, -) -from scipy._typing import Untyped -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 +__all__ = [ + "Halton", + "LatinHypercube", + "MultinomialQMC", + "MultivariateNormalQMC", + "PoissonDisk", + "QMCEngine", + "Sobol", + "discrepancy", + "geometric_discrepancy", + "scale", + "update_discrepancy", +] + +_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, @@ -39,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 @@ -49,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, @@ -60,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: ... @@ -104,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: ... @@ -128,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: @@ -143,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 2aca8599..4afd0153 100644 --- a/scipy-stubs/stats/_relative_risk.pyi +++ b/scipy-stubs/stats/_relative_risk.pyi @@ -1,8 +1,8 @@ from dataclasses import dataclass -from ._common import ConfidenceInterval as ConfidenceInterval from scipy._typing import Untyped from scipy.special import ndtri as ndtri +from ._common import ConfidenceInterval as ConfidenceInterval @dataclass class RelativeRiskResult: diff --git a/scipy-stubs/stats/_resampling.pyi b/scipy-stubs/stats/_resampling.pyi index 86223692..66790838 100644 --- a/scipy-stubs/stats/_resampling.pyi +++ b/scipy-stubs/stats/_resampling.pyi @@ -1,23 +1,50 @@ from dataclasses import dataclass -import numpy as np +from scipy._typing import Untyped, UntypedArray +from ._common import ConfidenceInterval -from ._common import ConfidenceInterval as ConfidenceInterval -from ._warnings_errors import DegenerateDataWarning as DegenerateDataWarning -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._typing import Untyped -from scipy.special import comb as comb, factorial as factorial, ndtr as ndtr, ndtri as ndtri +__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, @@ -34,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, @@ -51,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, @@ -67,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, @@ -85,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 d79458ba..98b3901d 100644 --- a/scipy-stubs/stats/_sampling.pyi +++ b/scipy-stubs/stats/_sampling.pyi @@ -1,8 +1,9 @@ -from ._qmc import Halton as Halton, QMCEngine as QMCEngine -from ._unuran.unuran_wrapper import NumericalInversePolynomial as NumericalInversePolynomial 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"] def argus_pdf(x, chi) -> Untyped: ... def argus_gamma_trf(x, chi) -> Untyped: ... diff --git a/scipy-stubs/stats/_sensitivity_analysis.pyi b/scipy-stubs/stats/_sensitivity_analysis.pyi index 8948fa07..d7367fe2 100644 --- a/scipy-stubs/stats/_sensitivity_analysis.pyi +++ b/scipy-stubs/stats/_sensitivity_analysis.pyi @@ -1,20 +1,26 @@ -from collections.abc import Callable from dataclasses import dataclass -from typing import Literal, Protocol +from collections.abc import Callable +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 @@ -22,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 4c0cf160..df13816c 100644 --- a/scipy-stubs/stats/_stats_mstats_common.pyi +++ b/scipy-stubs/stats/_stats_mstats_common.pyi @@ -1,5 +1,5 @@ -from . import distributions as distributions from scipy._typing import Untyped +from . import distributions as distributions TheilslopesResult: Untyped SiegelslopesResult: Untyped diff --git a/scipy-stubs/stats/_stats_py.pyi b/scipy-stubs/stats/_stats_py.pyi index 62a92083..f022984b 100644 --- a/scipy-stubs/stats/_stats_py.pyi +++ b/scipy-stubs/stats/_stats_py.pyi @@ -1,41 +1,78 @@ from dataclasses import dataclass from typing import NamedTuple -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 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._typing import Untyped -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 ._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 @@ -45,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: ... @@ -94,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 @@ -157,7 +202,9 @@ class ConfidenceInterval(NamedTuple): low: Untyped high: Untyped -PearsonRResultBase: Untyped +class PearsonRResultBase(NamedTuple): + statistic: Untyped + pvalue: Untyped class PearsonRResult(PearsonRResultBase): correlation: Untyped @@ -167,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__( @@ -200,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, @@ -220,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: ... @@ -268,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 73638bfe..fee40ff9 100644 --- a/scipy-stubs/stats/_survival.pyi +++ b/scipy-stubs/stats/_survival.pyi @@ -3,7 +3,6 @@ from typing import Literal import numpy as np import numpy.typing as npt - 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 @@ -11,11 +10,11 @@ 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 @@ -27,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/_variation.pyi b/scipy-stubs/stats/_variation.pyi index 69242b89..4234eb0d 100644 --- a/scipy-stubs/stats/_variation.pyi +++ b/scipy-stubs/stats/_variation.pyi @@ -1,4 +1,3 @@ -from scipy._lib._array_api import array_namespace as array_namespace, xp_copysign as xp_copysign from scipy._typing import Untyped 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/contingency.pyi b/scipy-stubs/stats/contingency.pyi index 7b583ef9..f1d66c9f 100644 --- a/scipy-stubs/stats/contingency.pyi +++ b/scipy-stubs/stats/contingency.pyi @@ -1,8 +1,8 @@ +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 from ._stats_py import power_divergence as power_divergence -from scipy._typing import Untyped def margins(a) -> Untyped: ... def expected_freq(observed) -> Untyped: ... diff --git a/scipy-stubs/stats/mstats.pyi b/scipy-stubs/stats/mstats.pyi index ce073755..36622762 100644 --- a/scipy-stubs/stats/mstats.pyi +++ b/scipy-stubs/stats/mstats.pyi @@ -1,3 +1,3 @@ +from scipy.stats import chisquare as chisquare, gmean as gmean, hmean as hmean, zmap as zmap, zscore as zscore from ._mstats_basic import * from ._mstats_extras import * -from scipy.stats import chisquare as chisquare, gmean as gmean, hmean as hmean, zmap as zmap, zscore as zscore diff --git a/scipy-stubs/stats/sampling.pyi b/scipy-stubs/stats/sampling.pyi index 87d5531f..15603118 100644 --- a/scipy-stubs/stats/sampling.pyi +++ b/scipy-stubs/stats/sampling.pyi @@ -1,10 +1,3 @@ -from ._sampling import FastGeneratorInversion as FastGeneratorInversion, RatioUniforms as RatioUniforms -from ._unuran.unuran_wrapper import ( - DiscreteAliasUrn as DiscreteAliasUrn, - DiscreteGuideTable as DiscreteGuideTable, - NumericalInverseHermite as NumericalInverseHermite, - NumericalInversePolynomial as NumericalInversePolynomial, - SimpleRatioUniforms as SimpleRatioUniforms, - TransformedDensityRejection as TransformedDensityRejection, - UNURANError as UNURANError, -) +from ._sampling import FastGeneratorInversion, RatioUniforms + +__all__ = ["FastGeneratorInversion", "RatioUniforms"]