summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@gmail.com>2023-04-08 23:02:55 +0200
committerGitHub <noreply@github.com>2023-04-08 23:02:55 +0200
commit6e26c3bff51ff35c2910e4d288fc02c5b80bad00 (patch)
tree77d07b72ddd8fc30f272fd91114a649f328b5d4f /numpy/lib
parentfc7c2cd6ca9138c84635efc73cb177b915ae2641 (diff)
parent79a292bb9ba6cc0a5de77c84e961f87194f17fcb (diff)
downloadnumpy-6e26c3bff51ff35c2910e4d288fc02c5b80bad00.tar.gz
Merge pull request #23555 from ngoldbaum/deprecate-np-math
DEP: deprecate np.math and np.lib.math [skip ci]
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/__init__.py19
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))
+