From 320de475a2829ad2bfeca41adff072c5dcdf8a73 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 16 Aug 2023 11:57:00 +0200 Subject: [PATCH] MAINT: revert adding `distutils` and `array_api` to `np.__all__` This has turned out to be too disruptive; `from numpy import *` has to remain warning-free and these two modules emit a warning on import rather than when they're actually used. `array_api` we have to decide on for 2.0 (either remove the experimental warning or remove it), I'll open a separate issue to follow up on that. --- numpy/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/numpy/__init__.py b/numpy/__init__.py index 1947d71f3edf..e300879a6f35 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -220,15 +220,15 @@ asmatrix, bmat, mat, matrix ) - # public submodules are imported lazily, - # therefore are accessible from __getattr__ + # public submodules are imported lazily, therefore are accessible from + # __getattr__. Note that `distutils` (deprecated) and `array_api` + # (experimental label) are not added here, because `from numpy import *` + # must not raise any warnings - that's too disruptive. __numpy_submodules__ = { "linalg", "fft", "dtypes", "random", "polynomial", "ma", "exceptions", "lib", "ctypeslib", "testing", "typing", - "array_api", "f2py", "test" + "f2py", "test" } - if sys.version_info < (3, 12): - __numpy_submodules__.add('distutils') # We build warning messages for former attributes _msg = ( @@ -357,7 +357,7 @@ def __dir__(): ) public_symbols -= { "core", "matrixlib", "matlib", "tests", "conftest", "version", - "compat" + "compat", "distutils", "array_api" } return list(public_symbols)