Skip to content

Commit 394a9f8

Browse files
committed
MAINT: exclude min, max and round from np.__all__
This is a workaround for breakage in downstream packages that do `from numpy import *`, see numpygh-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 numpygh-24229
1 parent 0497378 commit 394a9f8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

numpy/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@
235235
__all__.extend(lib.__all__)
236236
__all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])
237237

238+
# Remove min and max from __all__ to avoid `from numpy import *` override
239+
# the builtins min/max. Temporary fix for 1.25.x/1.26.x, see gh-24229.
240+
__all__.remove('min')
241+
__all__.remove('max')
242+
__all__.remove('round')
243+
238244
# Remove one of the two occurrences of `issubdtype`, which is exposed as
239245
# both `numpy.core.issubdtype` and `numpy.lib.issubdtype`.
240246
__all__.remove('issubdtype')

0 commit comments

Comments
 (0)