diff options
| author | Ross Barnowski <rossbar@berkeley.edu> | 2022-06-15 10:19:09 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-15 09:19:09 +0200 |
| commit | 118e6c433a9afdefbfad7652f56e2b97e23bc508 (patch) | |
| tree | 8bba333870b2dd0354d4c14d2844b0bbe3f9213f /numpy | |
| parent | 7c1438344914eab36dafb50edf349094cae47aae (diff) | |
| download | numpy-118e6c433a9afdefbfad7652f56e2b97e23bc508.tar.gz | |
MAINT: remove some names from main numpy namespace (#21403)
A small step towards numpy namespace cleanup. Removes a few names
from `__dir__` so that they are less discoverable when using
numpy interactively, e.g. in IPython or notebooks.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/__init__.py | 14 | ||||
| -rw-r--r-- | numpy/__init__.pyi | 1 |
2 files changed, 12 insertions, 3 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py index aae5c95ac..83487dc97 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -274,6 +274,7 @@ else: def __getattr__(attr): # Warn for expired attributes, and return a dummy function # that always raises an exception. + import warnings try: msg = __expired_functions__[attr] except KeyError: @@ -312,7 +313,11 @@ else: "{!r}".format(__name__, attr)) def __dir__(): - return list(globals().keys() | {'Tester', 'testing'}) + public_symbols = globals().keys() | {'Tester', 'testing'} + public_symbols -= { + "core", "matrixlib", + } + return list(public_symbols) # Pytest testing from numpy._pytesttester import PytestTester @@ -358,7 +363,6 @@ else: except ValueError: pass - import sys if sys.platform == "darwin": with warnings.catch_warnings(record=True) as w: _mac_os_check() @@ -414,6 +418,12 @@ else: from pathlib import Path return [str(Path(__file__).with_name("_pyinstaller").resolve())] + # Remove symbols imported for internal use + del os + # get the version using versioneer from .version import __version__, git_revision as __git_version__ + +# Remove symbols imported for internal use +del sys, warnings diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 2eb4a0634..d6faa9ca3 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -203,7 +203,6 @@ from numpy import ( lib as lib, linalg as linalg, ma as ma, - matrixlib as matrixlib, polynomial as polynomial, random as random, testing as testing, |
