Skip to content

sklearn-stubs/utils/validation.pyi/ "ensure_finite" needs updates in check_X_y and check_array for sklearn >= 1.8 #392

@gldlv

Description

@gldlv

In sklearn 1.8, the "enforce" arguments of check_X_y and check_array have been changed to "ensure" in order to reach a more coherent notation

"enforce" was deprecated as of 1.7, and has been dropped in 1.8.

As of now, the stub is :

def check_X_y(
    X: MatrixLike | ArrayLike,
    y: MatrixLike | ArrayLike,
    accept_sparse: Sequence[str] | tuple[str, str] | list[str] | str | bool = False,
    *,
    accept_large_sparse: bool = True,
    dtype: None | Sequence[type] | Literal["numeric"] | type = "numeric",
    order: Literal["F", "C"] | None = None,
    copy: bool = False,
    force_all_finite: str | bool = True, ### This is the offending line
    ensure_2d: bool = True,
    allow_nd: bool = False,
    multi_output: bool = False,
    ensure_min_samples: Int = 1,
    ensure_min_features: Int = 1,
    y_numeric: bool = False,
    estimator: None | str | BaseEstimator = None,
) -> tuple[Any, Any]: ...

When it should really be (for sklearn >=1.8) :

def check_X_y(
    X: MatrixLike | ArrayLike,
    y: MatrixLike | ArrayLike,
    accept_sparse: Sequence[str] | tuple[str, str] | list[str] | str | bool = False,
    *,
    accept_large_sparse: bool = True,
    dtype: None | Sequence[type] | Literal["numeric"] | type = "numeric",
    order: Literal["F", "C"] | None = None,
    copy: bool = False,
    ensure_all_finite: str | bool = True, ### This is the corrected line
    ensure_2d: bool = True,
    allow_nd: bool = False,
    multi_output: bool = False,
    ensure_min_samples: Int = 1,
    ensure_min_features: Int = 1,
    y_numeric: bool = False,
    estimator: None | str | BaseEstimator = None,
) -> tuple[Any, Any]: ...

Note : Same applies for check_array

This only applies from 1.8 and onwards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions