From 394a9f8b9dee06703ee7b98c8d6d8ae6732e401e Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Sat, 22 Jul 2023 17:12:12 +0200 Subject: [PATCH] MAINT: exclude min, max and round from `np.__all__` This is a workaround for breakage in downstream packages that do `from numpy import *`, see gh-24229. Note that there are other builtins that are contained in `__all__`: ``` >>> for s in dir(builtins): ... if s in np.__all__: ... print(s) ... all any divmod sum ``` Those were already there before the change in 1.25.0, and can stay. The downstream code should be fixed before the numpy 2.0 release. Closes gh-24229 --- numpy/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/numpy/__init__.py b/numpy/__init__.py index ae86313874eb..b4b33320b9f9 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -235,6 +235,12 @@ __all__.extend(lib.__all__) __all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma']) + # Remove min and max from __all__ to avoid `from numpy import *` override + # the builtins min/max. Temporary fix for 1.25.x/1.26.x, see gh-24229. + __all__.remove('min') + __all__.remove('max') + __all__.remove('round') + # Remove one of the two occurrences of `issubdtype`, which is exposed as # both `numpy.core.issubdtype` and `numpy.lib.issubdtype`. __all__.remove('issubdtype')