10000 MAINT: add test to prevent new public-looking modules being added by rgommers · Pull Request #14454 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: add test to prevent new public-looking modules being added #14454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MAINT: add missing 'Arrayterator' to numpy.lib.__all__
Also finish the TODO about figuring out which np.lib.<submodule>'s
are public.

This is a giant mess ...
  • Loading branch information
rgommers committed Sep 19, 2019
commit d072f12354d1802aa6ac7a3bfa92a24fa5df613d
6 changes: 6 additions & 0 deletions numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@
from .core import *
from . import compat
from . import lib
# FIXME: why have numpy.lib if everything is imported here??
from .lib import *

from . import linalg
from . import fft
from . import polynomial
Expand Down Expand Up @@ -174,6 +176,10 @@
__all__.extend(lib.__all__)
__all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])

# Remove things that are in the numpy.lib but not in the numpy namespace
__all__.remove('Arrayterator')
del Arrayterator

# Filter out Cython harmless warnings
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
Expand Down
10 changes: 7 additions & 3 deletions numpy/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@
from .info import __doc__
from numpy.version import version as __version__

# Public submodules
# Note: recfunctions and (maybe) format are public too, but not imported
from . import mixins
from . import scimath as emath

# Private submodules
from .type_check import *
from .index_tricks import *
from .function_base import *
from . import mixins # public
from .nanfunctions import *
from .shape_base import *
from .stride_tricks import *
from .twodim_base import *
from .ufunclike import *
from .histograms import *

from . import scimath as emath
from .polynomial import *
from .utils import *
from .arraysetops import *
Expand All @@ -27,7 +31,7 @@
from ._version import *
from numpy.core._multiarray_umath import tracemalloc_domain

__all__ = ['emath', 'math', 'tracemalloc_domain']
__all__ = ['emath', 'math', 'tracemalloc_domain', 'Arrayterator']
__all__ += type_check.__all__
__all__ += index_tricks.__all__
__all__ += function_base.__all__
Expand Down
11 changes: 6 additions & 5 deletions numpy/tests/test_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def check_dir(module, module_name=None):
sys.version_info[0] < 3,
reason="NumPy exposes slightly different functions on Python 2")
def test_numpy_namespace():
# None of these objects are publicly documented.
# None of these objects are publicly documented to be part of the main
# NumPy namespace (some are useful though, others need to be cleaned up)
undocumented = {
'Tester': 'numpy.testing._private.nosetester.NoseTester',
'_add_newdoc_ufunc': 'numpy.core._multiarray_umath._add_newdoc_ufunc',
Expand Down Expand Up @@ -144,9 +145,8 @@ def test_NPY_NO_EXPORT():
"f2py",
"fft",
"lib",
"lib.format",
"lib.format", # was this meant to be public?
"lib.mixins",
"lib.npyio",
"lib.recfunctions",
"lib.scimath",
"linalg",
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_NPY_NO_EXPORT():
"fft.info",
"fft.pocketfft",
"fft.pocketfft_internal",
"lib.arraypad", # TODO: figure out which numpy.lib submodules are public
"lib.arraypad",
"lib.arraysetops",
"lib.arrayterator",
"lib.financial",
Expand All @@ -285,13 +285,14 @@ def test_NPY_NO_EXPORT():
"lib.index_tricks",
"lib.info",
"lib.nanfunctions",
"lib.npyio",
"lib.polynomial",
"lib.shape_base",
"lib.stride_tricks",
"lib.twodim_base",
"lib.type_check",
"lib.ufunclike",
"lib.user_array",
"lib.user_array", # note: not in np.lib, but probably should just be deleted
"lib.utils",
"linalg.info",
"linalg.lapack_lite",
Expand Down
0