diff options
author | Nathan Goldbaum <nathan.goldbaum@gmail.com> | 2023-04-07 13:04:11 -0600 |
---|---|---|
committer | Nathan Goldbaum <nathan.goldbaum@gmail.com> | 2023-04-07 13:29:45 -0600 |
commit | 79a292bb9ba6cc0a5de77c84e961f87194f17fcb (patch) | |
tree | 2890f5259d3412dd608b30035dde6cdd4ce78fed /numpy/lib | |
parent | 3e77f904a9cc82e03d20824425e30edcd8088484 (diff) | |
download | numpy-79a292bb9ba6cc0a5de77c84e961f87194f17fcb.tar.gz |
DEP: deprecate np.math and np.lib.math
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/__init__.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py index 58166d4b1..d3cc9fee4 100644 --- a/numpy/lib/__init__.py +++ b/numpy/lib/__init__.py @@ -11,7 +11,6 @@ Most contains basic functions that are used by several submodules and are useful to have in the main name-space. """ -import math from numpy.version import version as __version__ @@ -58,7 +57,7 @@ from .arraypad import * from ._version import * from numpy.core._multiarray_umath import tracemalloc_domain -__all__ = ['emath', 'math', 'tracemalloc_domain', 'Arrayterator'] +__all__ = ['emath', 'tracemalloc_domain', 'Arrayterator'] __all__ += type_check.__all__ __all__ += index_tricks.__all__ __all__ += function_base.__all__ @@ -77,3 +76,19 @@ __all__ += histograms.__all__ from numpy._pytesttester import PytestTester test = PytestTester(__name__) del PytestTester + +def __getattr__(attr): + # Warn for reprecated attributes + import math + import warnings + + if attr == 'math': + warnings.warn( + "`np.lib.math` is a deprecated alias for the standard library " + "`math` module (Deprecated Numpy 1.25). Replace usages of " + "`numpy.lib.math` with `math`", DeprecationWarning, stacklevel=2) + return math + else: + raise AttributeError("module {!r} has no attribute " + "{!r}".format(__name__, attr)) + |