Skip to content

Commit eb5e7c6

Browse files
BUG: Fix duplication of names in 'numpy.__all__'.
Closes numpygh-10198.
1 parent c3fb434 commit eb5e7c6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

numpy/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@
233233
__all__.extend(lib.__all__)
234234
__all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])
235235

236+
# Remove one of the two occurrences of `issubdtype`, which is exposed as
237+
# both `numpy.core.issubdtype` and `numpy.lib.issubdtype`.
238+
__all__.remove('issubdtype')
239+
236240
# These are exported by np.core, but are replaced by the builtins below
237241
# remove them to ensure that we don't end up with `np.long == np.int_`,
238242
# which would be a breaking change.

numpy/core/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106

107107
__all__ = ['char', 'rec', 'memmap']
108108
__all__ += numeric.__all__
109-
__all__ += fromnumeric.__all__
110109
__all__ += ['record', 'recarray', 'format_parser']
111110
__all__ += ['chararray']
112111
__all__ += function_base.__all__

numpy/tests/test__all__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
import collections
3+
import numpy as np
4+
5+
6+
def test_no_duplicates_in_np__all__():
7+
# Regression test for gh-10198.
8+
dups = {k: v for k, v in collections.Counter(np.__all__).items() if v > 1}
9+
assert len(dups) == 0

0 commit comments

Comments
 (0)