Skip to content

Pass through non-ndarray object that support nep13 and nep18: vaex+sklearn out of core #14963

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

Closed
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
7 changes: 7 additions & 0 deletions sklearn/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ def check_array(array, accept_sparse=False, accept_large_sparse=True,
"removed in 0.23. Don't set `warn_on_dtype` to remove this "
"warning.",
DeprecationWarning, stacklevel=2)
# If a non-ndarray object supporting nep13 and nep18, we pass it through
# see https://numpy.org/neps/nep-0013-ufunc-overrides.html
# and https://numpy.org/neps/nep-0018-array-function-protocol.html
if not isinstance(array, np.ndarray) and\
hasattr(array, '__array_function__') and\
hasattr(array, '__array_ufunc__'):
return array

# store reference to original array to check if copy is needed when
# function returns
Expand Down