Skip to content

Commit

Permalink
fixed all (!) stubtest errors (the non-stubtest ones)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenham committed Aug 30, 2024
1 parent 95dc313 commit 3980bdc
Show file tree
Hide file tree
Showing 251 changed files with 1,354 additions and 1,592 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,33 @@ pip install scipy-stubs
| Module | Stubs status |
|---------------------------------- |---------------- |
| `scipy` | 1: skeleton |
| `scipy._lib` | 1: skeleton |
| `scipy._lib.uarray` | 1: skeleton |
| `scipy._lib.array_api_compat` | 1: partial |
| `scipy._lib` | 2: partial |
| `scipy._lib.uarray` | 2: ready |
| `scipy._lib.array_api_compat` | 2: partial |
| `scipy.cluster` | 1: skeleton |
| `scipy.constants` | 3: ready |
| `scipy.datasets` | 1: skeleton |
| `scipy.fft` | 1: skeleton |
| `scipy.fft._pocketfft` | 1: skeleton |
| `scipy.fft._pocketfft` | 1: partial |
| `scipy.fftpack` | 1: skeleton |
| `scipy.integrate` | 1: skeleton |
| `scipy.integrate._ivp` | 1: skeleton |
| `scipy.interpolate` | 1: skeleton |
| `scipy.integrate` | 2: partial |
| `scipy.integrate._ivp` | 1: partial |
| `scipy.interpolate` | 2: partial |
| `scipy.io` | 1: skeleton |
| `scipy.io.arff` | 1: skeleton |
| `scipy.io.matlab` | 1: skeleton |
| `scipy.io.matlab` | 2: partial |
| `scipy.linalg` | 3: ready |
| `scipy.misc` | 0: missing |
| `scipy.ndimage` | 1: skeleton |
| `scipy.odr` | 1: skeleton |
| `scipy.optimize` | 1: skeleton |
| `scipy.optimize` | 2: partial |
| `scipy.optimize.cython_optimize` | 0: missing |
| `scipy.optimize.zeros` | 0: missing |
| `scipy.signal` | 1: skeleton |
| `scipy.signal` | 1: partial |
| `scipy.signal.windows` | 1: skeleton |
| `scipy.sparse` | 1: skeleton |
| `scipy.sparse.csgraph` | 1: skeleton |
| `scipy.sparse.linalg` | 1: skeleton |
| `scipy.sparse` | 2: partial |
| `scipy.sparse.csgraph` | 2: partial |
| `scipy.sparse.linalg` | 2: partial |
| `scipy.spatial` | 2: partial |
| `scipy.spatial.distance` | 3: ready |
| `scipy.special` | 3: ready |
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,18 @@ banned-from = [
[tool.ruff.lint.isort]
combine-as-imports = true
known-first-party = ["scipy"]
no-lines-before = ["local-folder"]
no-lines-before = ["typing", "first-party", "local-folder"]
section-order = [
"standard-library",
"typing",
"third-party",
"typing-extra",
"first-party",
"local-folder",
]
split-on-trailing-comma = true

[tool.ruff.lint.isort.sections]
typing = ["collections.abc", "types", "typing", "typing_extensions"]
typing-extra = ["optype", "optype.numpy", "numpy.typing", "scipy._typing"]

[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
Expand Down
3 changes: 1 addition & 2 deletions scipy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from scipy._typing import Untyped

from scipy._lib._ccallback import LowLevelCallable as LowLevelCallable
from scipy._lib._testutils import PytestTester as PytestTester
from scipy._typing import Untyped

msg: str
np_minversion: str
Expand Down
3 changes: 1 addition & 2 deletions scipy-stubs/_lib/_array_api.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from types import ModuleType
from typing import Any, Literal

from scipy._typing import Untyped

from scipy._lib.array_api_compat import device, size
from scipy._typing import Untyped

__all__ = ["_asarray", "array_namespace", "device", "size"]

Expand Down
1 change: 0 additions & 1 deletion scipy-stubs/_lib/_ccallback.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ctypes as ct
from _ctypes import CFuncPtr as PyCFuncPtr

from types import ModuleType
from typing import ClassVar, Generic, Literal, TypeAlias
from typing_extensions import CapsuleType, Self, TypeVar
Expand Down
54 changes: 29 additions & 25 deletions scipy-stubs/_lib/_pep440.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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: ...
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scipy-stubs/_lib/_uarray/_backend.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Callable, Generator
from typing import TypeAlias

from scipy._typing import Untyped
from scipy._typing import Untyped, UntypedCallable

__all__ = [
"BackendNotImplementedError",
Expand Down Expand Up @@ -49,7 +49,7 @@ def generate_multimethod(
argument_extractor: ArgumentExtractorType,
argument_replacer: ArgumentReplacerType,
domain: str,
default: typing.Callable | None = None,
default: UntypedCallable | None = None,
): ...
def set_backend(backend, coerce: bool = False, only: bool = False) -> Untyped: ...
def skip_backend(backend) -> Untyped: ...
Expand Down
1 change: 0 additions & 1 deletion scipy-stubs/_lib/_util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ from typing import Any, NamedTuple, TypeAlias
from typing_extensions import TypeVar, override

import numpy as np

from scipy._typing import Untyped

AxisError: type[Exception]
Expand Down
1 change: 0 additions & 1 deletion scipy-stubs/_lib/array_api_compat/common/_helpers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ from types import ModuleType
from typing_extensions import TypeIs

import numpy as np

from ._typing import Array, Device

__all__ = [
Expand Down
2 changes: 0 additions & 2 deletions scipy-stubs/_lib/array_api_compat/common/_typing.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import array as _array
import mmap

from typing import Any, Literal, Protocol, TypeAlias, TypeVar
from typing_extensions import Buffer

import numpy as np

import optype as op

__all__ = ["NestedSequence", "SupportsBufferProtocol"]
Expand Down
14 changes: 6 additions & 8 deletions scipy-stubs/_lib/decorator.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from contextlib import GeneratorContextManager as _GeneratorContextManager

from contextlib import _GeneratorContextManager
from typing import NamedTuple

from scipy._typing import Untyped
from scipy._typing import Untyped, UntypedCallable

__version__: str

Expand Down Expand Up @@ -52,18 +51,17 @@ class FunctionMaker:
**attrs,
) -> Untyped: ...

def decorate(func, caller) -> Untyped: ...
def decorator(caller, _func: Untyped | None = None) -> Untyped: ...
def decorate(func: UntypedCallable, caller) -> Untyped: ...
def decorator(caller, _func: UntypedCallable | None = None) -> UntypedCallable: ...

class ContextManager(_GeneratorContextManager):
def __call__(self, func) -> Untyped: ...
class ContextManager(_GeneratorContextManager[Untyped]): ...

init: Untyped
n_args: Untyped

def __init__(self, g, *a, **k): ...

contextmanager: Untyped
contextmanager: UntypedCallable

def append(a, vancestors): ...
def dispatch_on(*dispatch_args) -> Untyped: ...
20 changes: 16 additions & 4 deletions scipy-stubs/_lib/deprecation.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
15 changes: 13 additions & 2 deletions scipy-stubs/_typing.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Helper types for internal use (type-check only).
from collections.abc import Callable
from typing import Literal, Protocol, TypeAlias, type_check_only
from typing_extensions import LiteralString, TypeVar

import numpy as np

import numpy.typing as npt
import optype.numpy as onpt

__all__ = [
"AnyBool",
Expand All @@ -17,11 +18,21 @@ __all__ = [
"CorrelateMode",
"Seed",
"Untyped",
"UntypedArray",
"UntypedCallable",
"UntypedDict",
"UntypedList",
"UntypedTuple",
"_FortranFunction",
]

# placeholder for missing annotations
# placeholders for missing annotations
Untyped: TypeAlias = object
UntypedTuple: TypeAlias = tuple[Untyped, ...]
UntypedList: TypeAlias = list[Untyped]
UntypedDict: TypeAlias = dict[Untyped, Untyped]
UntypedCallable: TypeAlias = Callable[..., Untyped]
UntypedArray: TypeAlias = onpt.Array[tuple[int, ...], np.generic]

_SCT = TypeVar("_SCT", bound=np.generic, default=np.generic)
Array0D: TypeAlias = np.ndarray[tuple[()], np.dtype[_SCT]]
Expand Down
3 changes: 1 addition & 2 deletions scipy-stubs/cluster/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from scipy._typing import Untyped

from scipy._lib._testutils import PytestTester as PytestTester
from scipy._typing import Untyped
from . import hierarchy as hierarchy, vq as vq
39 changes: 36 additions & 3 deletions scipy-stubs/cluster/hierarchy.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
from scipy._lib._disjoint_set import DisjointSet
from scipy._typing import Untyped

from scipy._lib._array_api import array_namespace as array_namespace, is_jax as is_jax, xp_copy as xp_copy
from scipy._lib._disjoint_set import DisjointSet as DisjointSet
__all__ = [
"ClusterNode",
"DisjointSet",
"average",
"centroid",
"complete",
"cophenet",
"correspond",
"cut_tree",
"dendrogram",
"fcluster",
"fclusterdata",
"from_mlab_linkage",
"inconsistent",
"is_isomorphic",
"is_monotonic",
"is_valid_im",
"is_valid_linkage",
"leaders",
"leaves_list",
"linkage",
"maxRstat",
"maxdists",
"maxinconsts",
"median",
"num_obs_linkage",
"optimal_leaf_ordering",
"set_link_color_palette",
"single",
"to_mlab_linkage",
"to_tree",
"ward",
"weighted",
]

class ClusterWarning(UserWarning): ...

Expand All @@ -24,7 +57,7 @@ class ClusterNode:
def __init__(self, id, left: Untyped | None = None, right: Untyped | None = None, dist: int = 0, count: int = 1): ...
def __lt__(self, node) -> Untyped: ...
def __gt__(self, node) -> Untyped: ...
def __eq__(self, node) -> Untyped: ...
def __eq__(self, node) -> Untyped: ... # type: ignore[override]
def get_id(self) -> Untyped: ...
def get_count(self) -> Untyped: ...
def get_left(self) -> Untyped: ...
Expand Down
Loading

0 comments on commit 3980bdc

Please sign in to comment.