Skip to content

FIX avoid warning in input validation with array_api_strict #29086

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
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
4 changes: 2 additions & 2 deletions sklearn/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ def _assert_all_finite(
):
"""Like assert_all_finite, but only for ndarray."""

xp, _ = get_namespace(X)
xp, is_array_api = get_namespace(X)

if _get_config()["assume_finite"]:
return

X = xp.asarray(X)

# for object dtype data, we only check for NaNs (GH-13254)
if X.dtype == np.dtype("object") and not allow_nan:
if not is_array_api and X.dtype == np.dtype("object") and not allow_nan:
if _object_dtype_isnan(X).any():
raise ValueError("Input contains NaN")

Expand Down
Loading