Skip to content

Commit 4eabb0e

Browse files
ogriselglemaitrelorentzenchr
authored
MAINT hide numpy warning when using _array_api_for_tests (scikit-learn#27384)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> Co-authored-by: Christian Lorentzen <lorentzen.ch@gmail.com>
1 parent 8faa920 commit 4eabb0e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sklearn/utils/_testing.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,13 @@ def fit_transform(self, X, y=None):
10641064

10651065
def _array_api_for_tests(array_namespace, device, dtype):
10661066
try:
1067-
array_mod = importlib.import_module(array_namespace)
1067+
if array_namespace == "numpy.array_api":
1068+
# FIXME: once it is not experimental anymore
1069+
with ignore_warnings(category=UserWarning):
1070+
# UserWarning: numpy.array_api submodule is still experimental.
1071+
array_mod = importlib.import_module(array_namespace)
1072+
else:
1073+
array_mod = importlib.import_module(array_namespace)
10681074
except ModuleNotFoundError:
10691075
raise SkipTest(
10701076
f"{array_namespace} is not installed: not checking array_api input"

0 commit comments

Comments
 (0)