Skip to content

Commit

Permalink
Complete scipy.special stiubs (excluding cython_special)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenham committed Aug 22, 2024
1 parent ca5141d commit a7d26cd
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 603 deletions.
18 changes: 14 additions & 4 deletions scipy-stubs/_typing.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Helper types for internal use (type-check only).

from typing import TypeAlias

import numpy as np
import numpy.typing as npt
from typing_extensions import TypeVar

__all__ = ("ArrayLike0D", "Untyped")
__all__ = "AnyBool", "AnyChar", "AnyComplex", "AnyInt", "AnyReal", "AnyScalar", "Array0D", "Untyped"

# placeholder for missing annotations
Untyped: TypeAlias = object

# keep in sync with `numpy.typing._scalar_like._ScalarLike`
ArrayLike0D: TypeAlias = bool | int | float | complex | str | bytes | np.generic
_SCT = TypeVar("_SCT", bound=np.generic, default=np.generic)
Array0D: TypeAlias = np.ndarray[tuple[()], np.dtype[_SCT]]

# keep in sync with `numpy._typing._scalars`
AnyBool: TypeAlias = bool | np.bool_
AnyInt: TypeAlias = int | np.integer[npt.NBitBase] | np.bool_
AnyReal: TypeAlias = int | float | np.floating[npt.NBitBase] | np.integer[npt.NBitBase] | np.bool_
AnyComplex: TypeAlias = int | float | complex | np.number[npt.NBitBase] | np.bool_
AnyChar: TypeAlias = str | bytes
AnyScalar: TypeAlias = int | float | complex | AnyChar | np.generic
6 changes: 3 additions & 3 deletions scipy-stubs/spatial/_ckdtree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from typing import Any, Generic, Literal, TypeAlias, TypeVar, overload
import numpy as np
import numpy.typing as npt

from scipy._typing import ArrayLike0D
from scipy._typing import AnyScalar
from scipy.sparse import coo_matrix, dok_matrix

__all__ = ["cKDTree"]
Expand Down Expand Up @@ -123,7 +123,7 @@ class cKDTree(Generic[_BoxT]):
def count_neighbors(
self,
other: cKDTree[npt.NDArray[np.float64] | None],
r: ArrayLike0D,
r: AnyScalar,
p: float = ...,
weights: None | tuple[None, None] = ...,
cumulative: bool = ...,
Expand All @@ -132,7 +132,7 @@ class cKDTree(Generic[_BoxT]):
def count_neighbors(
self,
other: cKDTree[npt.NDArray[np.float64] | None],
r: ArrayLike0D,
r: AnyScalar,
p: float = ...,
weights: _Weights = ...,
cumulative: bool = ...,
Expand Down
Loading

0 comments on commit a7d26cd

Please sign in to comment.