Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ line-length = 130
[tool.ruff.lint]
preview = true
select = ["ALL"]
ignore = ["D", "FBT", "COM812", "CPY", "EM", "TD", "FIX", "DOC"]
ignore = ["D", "FBT", "COM812", "CPY", "EM", "TD", "FIX", "DOC", "PYI041"]

[tool.ruff.lint.per-file-ignores]
"*.pyi" = ["F", "E741", "N", "A", "PYI054", "PLC2701", "PLW3201", "PLR", "FURB"]
Expand Down
14 changes: 7 additions & 7 deletions scipy-stubs/_lib/_ccallback.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class _CFFIBackendType(Protocol):
kind: Literal[
"primitive",
"bool",
"int",
"float",
"int | bool",
"float | int | bool",
"char",
"byte",
"pointer",
Expand All @@ -40,7 +40,7 @@ class _CFFIType(Protocol):

def is_integer_type(self, /) -> bool: ...
def has_c_name(self, /) -> bool: ...
def get_c_name(self, /, replace_with: str = "", context: str = "a C file", quals: int = 0) -> str: ...
def get_c_name(self, /, replace_with: str = "", context: str = "a C file", quals: int | bool = 0) -> str: ...
def get_cached_btype(self, /, ffi: object, finishlist: list[object], can_delay: bool = False) -> _CFFIBackendType: ...

# virtual
Expand All @@ -67,8 +67,8 @@ class _CFFIFunc(_CFFIType, Protocol[_CT_co, Unpack[_CTs]]):
@property
def ellipsis(self, /) -> bool: ...
@property
def abi(self, /) -> int | str | None: ...
def __init__(self, /, args: tuple[Unpack[_CTs]], result: _CT_co, ellipsis: bool, abi: int | None = None) -> None: ...
def abi(self, /) -> int | bool | str | None: ...
def __init__(self, /, args: tuple[Unpack[_CTs]], result: _CT_co, ellipsis: bool, abi: int | bool | None = None) -> None: ...

@type_check_only
@final
Expand All @@ -86,8 +86,8 @@ class _CFFIPointerType(_CFFIType, Protocol[_CT_co]):
@property
def totype(self, /) -> _CT_co: ...
@property
def quals(self, /) -> int: ...
def __init__(self, /, totype: _CT_co, quals: int = 0) -> None: ...
def quals(self, /) -> int | bool: ...
def __init__(self, /, totype: _CT_co, quals: int | bool = 0) -> None: ...

_CFFIVoidP: TypeAlias = _CFFIPointerType[_CFFIVoid]

Expand Down
8 changes: 4 additions & 4 deletions scipy-stubs/_lib/_disjoint_set.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import optype as op
_T = TypeVar("_T", bound=op.CanHash, default=object)

class DisjointSet(Generic[_T]):
n_subsets: int
n_subsets: int | bool

def __init__(self, /, elements: _T | None = None) -> None: ...
def __iter__(self, /) -> Iterator[_T]: ...
def __len__(self, /) -> int: ...
def __len__(self, /) -> int | bool: ...
def __contains__(self, x: object, /) -> bool: ...
def __getitem__(self, x: _T, /) -> int: ...
def __getitem__(self, x: _T, /) -> int | bool: ...
def add(self, /, x: _T) -> None: ...
def merge(self, /, x: _T, y: _T) -> bool: ...
def connected(self, /, x: _T, y: _T) -> bool: ...
def subset(self, /, x: _T) -> set[_T]: ...
def subset_size(self, /, x: _T) -> int: ...
def subset_size(self, /, x: _T) -> int | bool: ...
def subsets(self, /) -> list[set[_T]]: ...
4 changes: 2 additions & 2 deletions scipy-stubs/_lib/_docscrape.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Reader:
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 peek(self, /, n: int | bool = 0) -> str: ...
def is_empty(self, /) -> bool: ...

class NumpyDocString(Mapping[str, _SectionValue]):
Expand All @@ -37,7 +37,7 @@ class NumpyDocString(Mapping[str, _SectionValue]):
@override
def __str__(self, /, func_role: str = "") -> str: ...
@override
def __len__(self, /) -> int: ...
def __len__(self, /) -> int | bool: ...
@override
def __iter__(self, /) -> op.CanIterSelf[str]: ...
@override
Expand Down
10 changes: 5 additions & 5 deletions scipy-stubs/_lib/_elementwise_iterative_method.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _FuncRealT = TypeVar("_FuncRealT", bound=Callable[Concatenate[onp.ArrayND[np.flo
_ModuleT = TypeVar("_ModuleT", bound=ModuleType, default=ModuleType)
_WorkT = TypeVar("_WorkT", bound=Mapping[str, Any])
_ResT = TypeVar("_ResT", bound=_RichResult, default=_RichResult)
_ToShapeT = TypeVar("_ToShapeT", bound=op.CanIndex | tuple[op.CanIndex, ...], default=tuple[int, ...])
_ToShapeT = TypeVar("_ToShapeT", bound=op.CanIndex | tuple[op.CanIndex, ...], default=tuple[int | bool, ...])

_Ignored: TypeAlias = _ResT

Expand All @@ -31,7 +31,7 @@ _EINPUTERR: Final = -5
_ECONVERGED: Final = 0
_EINPROGRESS: Final = 1

# TODO: complex
# TODO: complex | float | int | bool
def _initialize(
func: _FuncRealT,
xs: Sequence[onp.ToFloat1D],
Expand All @@ -54,15 +54,15 @@ def _loop(
work: _ResT,
callback: Callable[[_ResT], _Ignored],
shape: Sequence[op.CanIndex],
maxiter: int,
maxiter: int | bool,
func: Callable[[onp.Array[_ShapeT, _FloatT]], onp.ToComplexND],
args: tuple[onp.ArrayND[np.floating[Any]], ...],
dtype: np.inexact[Any],
pre_func_eval: Callable[[_ResT], onp.Array[_ShapeT, _FloatT]],
post_func_eval: Callable[[onp.Array[_ShapeT, _FloatT], onp.Array[_ShapeT, np.floating[Any]], _ResT], _Ignored],
check_termination: Callable[[_ResT], onp.Array[_ShapeT, np.bool_]],
post_termination_check: Callable[[_ResT], _Ignored],
customize_result: Callable[[_ResT, _ToShapeT], tuple[int, ...]],
customize_result: Callable[[_ResT, _ToShapeT], tuple[int | bool, ...]],
res_work_pairs: Iterable[tuple[str, str]],
xp: ModuleType,
preserve_shape: bool | None = False,
Expand Down Expand Up @@ -97,7 +97,7 @@ def _prepare_result(
res_work_pairs: Iterable[tuple[str, str]],
active: onp.Array[_ShapeT, np.integer[Any]],
shape: _ToShapeT,
customize_result: Callable[[_ResT, _ToShapeT], tuple[int, ...]],
customize_result: Callable[[_ResT, _ToShapeT], tuple[int | bool, ...]],
preserve_shape: bool | None,
xp: ModuleType,
) -> _ResT: ...
6 changes: 3 additions & 3 deletions scipy-stubs/_lib/_finite_differences.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ _T = TypeVar("_T", bound=np.floating[Any] | onp.ArrayND[np.floating[Any]])

###

def _central_diff_weights(Np: int, ndiv: int = 1) -> onp.Array1D[np.float64]: ...
def _central_diff_weights(Np: int | bool, ndiv: int | bool = 1) -> onp.Array1D[np.float64]: ...

#
@overload
def _derivative(
func: Callable[Concatenate[float, ...], onp.ToFloat],
x0: float,
func: Callable[Concatenate[float | int | bool, ...], onp.ToFloat],
x0: float | int | bool,
dx: onp.ToFloat = 1.0,
n: onp.ToInt = 1,
args: tuple[object, ...] = (),
Expand Down
12 changes: 6 additions & 6 deletions scipy-stubs/_lib/_pep440.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ NegativeInfinity: Final[_NegativeInfinityType] = ...
class InvalidVersion(ValueError): ...

class _Version(NamedTuple):
epoch: int
release: tuple[int, ...]
dev: tuple[str, int]
pre: tuple[str, int]
post: tuple[str, int]
local: tuple[str | int, ...]
epoch: int | bool
release: tuple[int | bool, ...]
dev: tuple[str, int | bool]
pre: tuple[str, int | bool]
post: tuple[str, int | bool]
local: tuple[str | int | bool, ...]

class _BaseVersion:
def __lt__(self, other: _BaseVersion, /) -> bool: ...
Expand Down
12 changes: 6 additions & 6 deletions scipy-stubs/_lib/_testutils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ class PytestTester:
self,
/,
label: Literal["fast", "full"] = "fast",
verbose: int = 1,
verbose: int | bool = 1,
extra_argv: Iterable[str] | None = None,
doctests: bool = False,
coverage: bool = False,
tests: Iterable[str] | None = None,
parallel: int | None = None,
parallel: int | bool | None = None,
) -> bool: ...

class _TestPythranFunc:
ALL_INTEGER: ClassVar[list[np.int8 | np.int16 | np.int32 | np.int64 | np.intc | np.intp]]
ALL_FLOAT: ClassVar[list[np.float32 | np.float64]]
ALL_COMPLEX: ClassVar[list[np.complex64 | np.complex128]]
arguments: dict[int, tuple[onp.Array, list[np.generic]]]
arguments: dict[int | bool, tuple[onp.Array, list[np.generic]]]
partialfunc: Callable[..., object] | None
expected: object | None
def setup_method(self, /) -> None: ...
def get_optional_args(self, /, func: Callable[..., object]) -> dict[str, object]: ...
def get_max_dtype_list_length(self, /) -> int: ...
def get_dtype(self, /, dtype_list: Sequence[np.generic], dtype_idx: int) -> np.generic: ...
def get_max_dtype_list_length(self, /) -> int | bool: ...
def get_dtype(self, /, dtype_list: Sequence[np.generic], dtype_idx: int | bool) -> np.generic: ...
def test_all_dtypes(self, /) -> None: ...
def test_views(self, /) -> None: ...
def test_strided(self, /) -> None: ...

def check_free_memory(free_mb: float) -> None: ...
def check_free_memory(free_mb: float | int | bool) -> None: ...
18 changes: 9 additions & 9 deletions scipy-stubs/_lib/_util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ np_ulong: Final[type[np.uint32 | np.uint64]] = ... # `np.ulong` on `numpy>=2`,
copy_if_needed: Final[Literal[False] | None] = ... # `None` on `numpy>=2`, otherwise `False`

# NOTE: These aliases are implictly exported at runtime
IntNumber: TypeAlias = int | npc.integer
DecimalNumber: TypeAlias = float | npc.floating | npc.integer
IntNumber: TypeAlias = int | bool | npc.integer
DecimalNumber: TypeAlias = float | int | bool | npc.floating | npc.integer
_RNG: TypeAlias = np.random.Generator | np.random.RandomState
SeedType: TypeAlias = IntNumber | _RNG | None
GeneratorType = TypeVar("GeneratorType", bound=_RNG) # noqa: PYI001 # oof
Expand All @@ -43,12 +43,12 @@ class VisibleDeprecationWarning(UserWarning): ...

class AxisError(ValueError, IndexError):
_msg: Final[str | None]
axis: Final[int | None]
axis: Final[int | bool | None]
ndim: Final[onp.NDim | None]
@overload
def __init__(self, /, axis: str, ndim: None = None, msg_prefix: None = None) -> None: ...
@overload
def __init__(self, /, axis: int, ndim: onp.NDim, msg_prefix: str | None = None) -> None: ...
def __init__(self, /, axis: int | bool, ndim: onp.NDim, msg_prefix: str | None = None) -> None: ...

class FullArgSpec(NamedTuple):
args: list[str]
Expand All @@ -69,9 +69,9 @@ class _FunctionWrapper(Generic[_T_contra, _T_co]):
def __call__(self, /, x: _T_contra) -> _T_co: ...

class MapWrapper(EnterSelfMixin):
pool: int | mpp.Pool | None
pool: int | bool | mpp.Pool | None

def __init__(self, /, pool: Callable[[Callable[[_VT], _RT], Iterable[_VT]], Iterable[_RT]] | int = 1) -> None: ...
def __init__(self, /, pool: Callable[[Callable[[_VT], _RT], Iterable[_VT]], Iterable[_RT]] | int | bool = 1) -> None: ...
def __call__(self, /, func: Callable[[_VT], _RT], iterable: Iterable[_VT]) -> Iterable[_RT]: ...
def terminate(self, /) -> None: ...
def join(self, /) -> None: ...
Expand All @@ -83,7 +83,7 @@ class _RichResult(dict[str, _T]):
def __setattr__(self, name: str, value: _T, /) -> None: ...

#
def float_factorial(n: op.CanIndex) -> float: ... # will be `np.inf` if `n >= 171`
def float_factorial(n: op.CanIndex) -> float | int | bool: ... # will be `np.inf` if `n >= 171`

#
def getfullargspec_no_self(func: Callable[..., object]) -> FullArgSpec: ...
Expand Down Expand Up @@ -116,8 +116,8 @@ def rng_integers(

#
@overload
def normalize_axis_index(axis: int, ndim: onp.NDim) -> onp.NDim: ...
def normalize_axis_index(axis: int | bool, ndim: onp.NDim) -> onp.NDim: ...
@overload
def normalize_axis_index(axis: int | _AxisT, ndim: _AxisT) -> _AxisT: ...
def normalize_axis_index(axis: int | bool | _AxisT, ndim: _AxisT) -> _AxisT: ...
@overload
def normalize_axis_index(axis: _AxisT, ndim: onp.NDim | _AxisT) -> _AxisT: ...
2 changes: 1 addition & 1 deletion scipy-stubs/_lib/deprecation.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _F = TypeVar("_F", bound=Callable[..., object])
class _DeprecationHelperStr:
def __init__(self, /, content: str, message: str) -> None: ...

def _deprecated(msg: str, stacklevel: int = 2) -> Callable[[_F], _F]: ...
def _deprecated(msg: str, stacklevel: int | bool = 2) -> Callable[[_F], _F]: ...
def deprecate_cython_api(
module: ModuleType,
routine_name: str,
Expand Down
2 changes: 1 addition & 1 deletion scipy-stubs/_lib/doccer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def docformat(docstring: str, docdict: dict[str, str] | None = None) -> str: ...
def inherit_docstring_from(cls: type | object) -> Callable[[_F], _F]: ...
def extend_notes_in_docstring(cls: type | object, notes: str) -> Callable[[_F], _F]: ...
def replace_notes_in_docstring(cls: type | object, notes: str) -> Callable[[_F], _F]: ...
def indentcount_lines(lines: op.CanIter[op.CanNext[str]]) -> int: ...
def indentcount_lines(lines: op.CanIter[op.CanNext[str]]) -> int | bool: ...
def filldoc(docdict: dict[str, str], unindent_params: bool = True) -> Callable[[_F], _F]: ...
def unindent_dict(docdict: dict[str, str]) -> dict[str, str]: ...
def unindent_string(docstring: str) -> str: ...
Expand Down
1 change: 1 addition & 0 deletions scipy-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ RNG: TypeAlias = np.random.Generator | np.random.RandomState
# NOTE: This is less incorrect and more accurate than the current `np.random.default_rng` `seed` param annotation.
ToRNG: TypeAlias = (
int
| bool
| np.integer[Any]
| np.timedelta64
| onp.ArrayND[np.integer[Any] | np.timedelta64 | np.flexible | np.object_]
Expand Down
Loading
Loading