1"""
2``numpy.lib`` is mostly a space for implementing functions that don't
3belong in core or in another NumPy submodule with a clear purpose
4(e.g. ``random``, ``fft``, ``linalg``, ``ma``).
5
6``numpy.lib``'s private submodules contain basic functions that are used by
7other public modules and are useful to have in the main name-space.
8
9"""
10
11# Public submodules
12# Note: recfunctions and (maybe) format are public too, but not imported
13from . import array_utils
14from . import introspect
15from . import mixins
16from . import npyio
17from . import scimath
18from . import stride_tricks
19
20# Private submodules
21# load module names. See https://github.com/networkx/networkx/issues/5838
22from . import _type_check_impl
23from . import _index_tricks_impl
24from . import _nanfunctions_impl
25from . import _function_base_impl
26from . import _stride_tricks_impl
27from . import _shape_base_impl
28from . import _twodim_base_impl
29from . import _ufunclike_impl
30from . import _histograms_impl
31from . import _utils_impl
32from . import _arraysetops_impl
33from . import _polynomial_impl
34from . import _npyio_impl
35from . import _arrayterator_impl
36from . import _arraypad_impl
37from . import _version
38
39# numpy.lib namespace members
40from ._arrayterator_impl import Arrayterator
41from ._version import NumpyVersion
42from numpy._core._multiarray_umath import add_docstring, tracemalloc_domain
43from numpy._core.function_base import add_newdoc
44
45__all__ = [
46 "Arrayterator", "add_docstring", "add_newdoc", "array_utils",
47 "introspect", "mixins", "NumpyVersion", "npyio", "scimath",
48 "stride_tricks", "tracemalloc_domain"
49]
50
51add_newdoc.__module__ = "numpy.lib"
52
53from numpy._pytesttester import PytestTester
54test = PytestTester(__name__)
55del PytestTester
56
57def __getattr__(attr):
58 # Warn for deprecated/removed aliases
59 import math
60 import warnings
61
62 if attr == "math":
63 warnings.warn(
64 "`np.lib.math` is a deprecated alias for the standard library "
65 "`math` module (Deprecated Numpy 1.25). Replace usages of "
66 "`numpy.lib.math` with `math`", DeprecationWarning, stacklevel=2)
67 return math
68 elif attr == "emath":
69 raise AttributeError(
70 "numpy.lib.emath was an alias for emath module that was removed "
71 "in NumPy 2.0. Replace usages of numpy.lib.emath with "
72 "numpy.emath.",
73 name=None
74 )
75 elif attr in (
76 "histograms", "type_check", "nanfunctions", "function_base",
77 "arraypad", "arraysetops", "ufunclike", "utils", "twodim_base",
78 "shape_base", "polynomial", "index_tricks",
79 ):
80 raise AttributeError(
81 f"numpy.lib.{attr} is now private. If you are using a public "
82 "function, it should be available in the main numpy namespace, "
83 "otherwise check the NumPy 2.0 migration guide.",
84 name=None
85 )
86 elif attr == "arrayterator":
87 raise AttributeError(
88 "numpy.lib.arrayterator submodule is now private. To access "
89 "Arrayterator class use numpy.lib.Arrayterator.",
90 name=None
91 )
92 else:
93 raise AttributeError("module {!r} has no attribute "
94 "{!r}".format(__name__, attr))