Skip to content

Commit

Permalink
Use check_array to validate y (scikit-learn#25089)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
closes scikit-learn#25073
  • Loading branch information
betatim authored and jjerphan committed Jan 20, 2023
1 parent 38bd459 commit b559fd3
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 b559fd3

Please sign in to comment.