Skip to content

Commit

Permalink
Use check_array to validate y (#25089)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
closes #25073
  • Loading branch information
betatim committed Dec 15, 2022
1 parent 205f3b7 commit a0829ac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sklearn/utils/validation.py
Expand Up @@ -1176,7 +1176,15 @@ def column_or_1d(y, *, dtype=None, warn=False):
If `y` is not a 1D array or a 2D array with a single row or column.
"""
xp, _ = get_namespace(y)
y = xp.asarray(y, dtype=dtype)
y = check_array(
y,
ensure_2d=False,
dtype=dtype,
input_name="y",
force_all_finite=False,
ensure_min_samples=0,
)

shape = y.shape
if len(shape) == 1:
return _asarray_with_order(xp.reshape(y, -1), order="C", xp=xp)
Expand Down

0 comments on commit a0829ac

Please sign in to comment.