Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
__init__.py98 linesDownload Raw Back to lib
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 is public, but not imported
13from numpy._core._multiarray_umath import add_docstring, tracemalloc_domain
14from numpy._core.function_base import add_newdoc
15
16# Private submodules
17# load module names. See https://github.com/networkx/networkx/issues/5838
18from . import (
19    _arraypad_impl,
20    _arraysetops_impl,
21    _arrayterator_impl,
22    _function_base_impl,
23    _histograms_impl,
24    _index_tricks_impl,
25    _nanfunctions_impl,
26    _npyio_impl,
27    _polynomial_impl,
28    _shape_base_impl,
29    _stride_tricks_impl,
30    _twodim_base_impl,
31    _type_check_impl,
32    _ufunclike_impl,
33    _utils_impl,
34    _version,
35    array_utils,
36    format,
37    introspect,
38    mixins,
39    npyio,
40    scimath,
41    stride_tricks,
42)
43
44# numpy.lib namespace members
45from ._arrayterator_impl import Arrayterator
46from ._version import NumpyVersion
47
48__all__ = [
49    "Arrayterator", "add_docstring", "add_newdoc", "array_utils",
50    "format", "introspect", "mixins", "NumpyVersion", "npyio", "scimath",
51    "stride_tricks", "tracemalloc_domain",
52]
53
54add_newdoc.__module__ = "numpy.lib"
55
56from numpy._pytesttester import PytestTester
57
58test = PytestTester(__name__)
59del PytestTester
60
61def __getattr__(attr):
62    # Warn for deprecated/removed aliases
63    import math
64    import warnings
65
66    if attr == "math":
67        warnings.warn(
68            "`np.lib.math` is a deprecated alias for the standard library "
69            "`math` module (Deprecated Numpy 1.25). Replace usages of "
70            "`numpy.lib.math` with `math`", DeprecationWarning, stacklevel=2)
71        return math
72    elif attr == "emath":
73        raise AttributeError(
74            "numpy.lib.emath was an alias for emath module that was removed "
75            "in NumPy 2.0. Replace usages of numpy.lib.emath with "
76            "numpy.emath.",
77            name=None
78        )
79    elif attr in (
80        "histograms", "type_check", "nanfunctions", "function_base",
81        "arraypad", "arraysetops", "ufunclike", "utils", "twodim_base",
82        "shape_base", "polynomial", "index_tricks",
83    ):
84        raise AttributeError(
85            f"numpy.lib.{attr} is now private. If you are using a public "
86            "function, it should be available in the main numpy namespace, "
87            "otherwise check the NumPy 2.0 migration guide.",
88            name=None
89        )
90    elif attr == "arrayterator":
91        raise AttributeError(
92            "numpy.lib.arrayterator submodule is now private. To access "
93            "Arrayterator class use numpy.lib.Arrayterator.",
94            name=None
95        )
96    else:
97        raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")
98 
codekingpro/portable-devtools · Team Ai