Skip to content

Fix all stub-body-multiple-statements (PYI048) #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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 @@ -33,6 +33,7 @@ extend-select = [
"PYI", # flake8-pyi
"UP", # pyupgrade
"W", # pycodestyle Warning
"PIE790", # unnecessary-placeholder
]
ignore = [
###
Expand All @@ -55,7 +56,6 @@ ignore = [
"F401",

# TODO: Investigate and fix or configure
"PYI048",
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
]
[tool.ruff.lint.per-file-ignores]
Expand Down
4 changes: 0 additions & 4 deletions stubs/sklearn/cluster/_k_means_elkan.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def init_bounds_dense(
n_threads : int
The number of threads to be used by openmp.
"""
...

def init_bounds_sparse(
X: spmatrix,
Expand Down Expand Up @@ -83,7 +82,6 @@ def init_bounds_sparse(
n_threads : int
The number of threads to be used by openmp.
"""
...

def elkan_iter_chunked_dense(
X: np.ndarray,
Expand Down Expand Up @@ -141,7 +139,6 @@ def elkan_iter_chunked_dense(
the algorithm. This is useful especially when calling predict on a
fitted model.
"""
...

def elkan_iter_chunked_sparse(
X: spmatrix,
Expand Down Expand Up @@ -199,4 +196,3 @@ def elkan_iter_chunked_sparse(
the algorithm. This is useful especially when calling predict on a
fitted model.
"""
...
2 changes: 0 additions & 2 deletions stubs/sklearn/cluster/_k_means_lloyd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def lloyd_iter_chunked_dense(
the algorithm. This is useful especially when calling predict on a
fitted model.
"""
...

def lloyd_iter_chunked_sparse(
X: np.ndarray,
Expand Down Expand Up @@ -90,4 +89,3 @@ def lloyd_iter_chunked_sparse(
the algorithm. This is useful especially when calling predict on a
fitted model.
"""
...
1 change: 0 additions & 1 deletion stubs/sklearn/decomposition/_online_lda_fast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ def mean_change(arr_1: np.ndarray, arr_2: np.ndarray) -> float:

Equivalent to np.abs(arr_1 - arr2).mean().
"""
...

def psi(x: float) -> float: ...
2 changes: 0 additions & 2 deletions stubs/sklearn/ensemble/_gradient_boosting.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ def predict_stages(estimators: np.ndarray, X, scale: float, out: np.ndarray) ->
Each estimator is scaled by ``scale`` before its prediction
is added to ``out``.
"""
...

def predict_stage(estimators: np.ndarray, stage: int, X, scale: float, out: np.ndarray) -> None:
"""Add predictions of ``estimators[stage]`` to ``out``.
Each estimator in the stage is scaled by ``scale`` before
its prediction is added to ``out``.
"""
...
2 changes: 0 additions & 2 deletions stubs/sklearn/ensemble/_hist_gradient_boosting/histogram.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class HistogramBuilder:
histograms : ndarray of HISTOGRAM_DTYPE, shape (n_features, n_bins)
The computed histograms of the current node.
"""
...

def compute_histograms_subtraction(
self,
Expand All @@ -85,4 +84,3 @@ class HistogramBuilder:
histograms : ndarray of HISTOGRAM_DTYPE, shape(n_features, n_bins)
The computed histograms of the current node.
"""
...
2 changes: 0 additions & 2 deletions stubs/sklearn/ensemble/_hist_gradient_boosting/splitting.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ class Splitter:
right_child_position : int
The position of the right child in ``sample_indices``.
"""
...

def find_node_split(
self,
Expand Down Expand Up @@ -208,4 +207,3 @@ class Splitter:
best_split_info : SplitInfo
The info about the best possible split among all features.
"""
...
1 change: 0 additions & 1 deletion stubs/sklearn/feature_extraction/_hashing_fast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ def transform(
indices, indptr, values : lists
For constructing a scipy.sparse.csr_matrix.
"""
...
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def sqeuclidean_row_norms(X: np.ndarray | csr_matrix, num_threads: int) -> np.nd
sqeuclidean_row_norms : ndarray of shape (n_samples,)
Arrays containing the squared euclidean norm of each row of X.
"""
...

class BaseDistancesReductionDispatcher:
"""Abstract base dispatcher for pairwise distance computation & reduction.
Expand Down Expand Up @@ -53,7 +52,6 @@ class BaseDistancesReductionDispatcher:
-------
True if the dispatcher can be used, else False.
"""
...

@classmethod
@abstractmethod
Expand Down Expand Up @@ -170,7 +168,6 @@ class ArgKmin(BaseDistancesReductionDispatcher):
for the concrete implementation are therefore freed when this classmethod
returns.
"""
...

class RadiusNeighbors(BaseDistancesReductionDispatcher):
"""Compute radius-based neighbors for two sets of vectors.
Expand Down Expand Up @@ -286,4 +283,3 @@ class RadiusNeighbors(BaseDistancesReductionDispatcher):
for the concrete implementation are therefore freed when this classmethod
returns.
"""
...
1 change: 0 additions & 1 deletion stubs/sklearn/utils/arrayfuncs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ def min_pos(X: np.ndarray) -> float:
Returns the maximum representable value of the input dtype if none of the
values are positive.
"""
...

def cholesky_delete(L: np.ndarray, go_out: int) -> None: ...
7 changes: 0 additions & 7 deletions stubs/sklearn/utils/sparsefuncs_fast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ from scipy.sparse import csc_matrix, csr_matrix

def csr_row_norms(X: np.ndarray) -> np.ndarray:
"""Squared L2 norm of each row in CSR matrix X."""
...

def csr_mean_variance_axis0(
X: csr_matrix, weights: np.ndarray | None = None, return_sum_weights: bool = False
Expand All @@ -29,7 +28,6 @@ def csr_mean_variance_axis0(
sum_weights : ndarray of shape (n_features,), dtype=floating
Returned if return_sum_weights is True.
"""
...

def csc_mean_variance_axis0(
X: csc_matrix, weights: np.ndarray | None = None, return_sum_weights: bool = False
Expand All @@ -55,7 +53,6 @@ def csc_mean_variance_axis0(
sum_weights : ndarray of shape (n_features,), dtype=floating
Returned if return_sum_weights is True.
"""
...

def incr_mean_variance_axis0(
X: csr_matrix | csc_matrix, last_mean: np.ndarray, last_var: np.ndarray, last_n: np.ndarray, weights: np.ndarray | None = None
Expand Down Expand Up @@ -86,15 +83,12 @@ def incr_mean_variance_axis0(
updated_n : int array with shape (n_features,)
Updated number of samples seen
"""
...

def inplace_csr_row_normalize_l1(X: np.ndarray) -> None:
"""Inplace row normalize using the l1 norm"""
...

def inplace_csr_row_normalize_l2(X: np.ndarray) -> None:
"""Inplace row normalize using the l2 norm"""
...

def assign_rows_csr(
X: csr_matrix,
Expand All @@ -112,4 +106,3 @@ def assign_rows_csr(
out_rows : array, dtype=np.intp, shape=n_rows
out : array, shape=(arbitrary, n_features)
"""
...