__init__.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. """
  2. **Note:** almost all functions in the ``numpy.lib`` namespace
  3. are also present in the main ``numpy`` namespace. Please use the
  4. functions as ``np.<funcname>`` where possible.
  5. ``numpy.lib`` is mostly a space for implementing functions that don't
  6. belong in core or in another NumPy submodule with a clear purpose
  7. (e.g. ``random``, ``fft``, ``linalg``, ``ma``).
  8. Most contains basic functions that are used by several submodules and are
  9. useful to have in the main name-space.
  10. """
  11. # Public submodules
  12. # Note: recfunctions and (maybe) format are public too, but not imported
  13. from . import mixins
  14. from . import scimath as emath
  15. # Private submodules
  16. # load module names. See https://github.com/networkx/networkx/issues/5838
  17. from . import type_check
  18. from . import index_tricks
  19. from . import function_base
  20. from . import nanfunctions
  21. from . import shape_base
  22. from . import stride_tricks
  23. from . import twodim_base
  24. from . import ufunclike
  25. from . import histograms
  26. from . import polynomial
  27. from . import utils
  28. from . import arraysetops
  29. from . import npyio
  30. from . import arrayterator
  31. from . import arraypad
  32. from . import _version
  33. from .type_check import *
  34. from .index_tricks import *
  35. from .function_base import *
  36. from .nanfunctions import *
  37. from .shape_base import *
  38. from .stride_tricks import *
  39. from .twodim_base import *
  40. from .ufunclike import *
  41. from .histograms import *
  42. from .polynomial import *
  43. from .utils import *
  44. from .arraysetops import *
  45. from .npyio import *
  46. from .arrayterator import Arrayterator
  47. from .arraypad import *
  48. from ._version import *
  49. from numpy.core._multiarray_umath import tracemalloc_domain
  50. __all__ = ['emath', 'tracemalloc_domain', 'Arrayterator']
  51. __all__ += type_check.__all__
  52. __all__ += index_tricks.__all__
  53. __all__ += function_base.__all__
  54. __all__ += shape_base.__all__
  55. __all__ += stride_tricks.__all__
  56. __all__ += twodim_base.__all__
  57. __all__ += ufunclike.__all__
  58. __all__ += arraypad.__all__
  59. __all__ += polynomial.__all__
  60. __all__ += utils.__all__
  61. __all__ += arraysetops.__all__
  62. __all__ += npyio.__all__
  63. __all__ += nanfunctions.__all__
  64. __all__ += histograms.__all__
  65. from numpy._pytesttester import PytestTester
  66. test = PytestTester(__name__)
  67. del PytestTester
  68. def __getattr__(attr):
  69. # Warn for reprecated attributes
  70. import math
  71. import warnings
  72. if attr == 'math':
  73. warnings.warn(
  74. "`np.lib.math` is a deprecated alias for the standard library "
  75. "`math` module (Deprecated Numpy 1.25). Replace usages of "
  76. "`numpy.lib.math` with `math`", DeprecationWarning, stacklevel=2)
  77. return math
  78. else:
  79. raise AttributeError("module {!r} has no attribute "
  80. "{!r}".format(__name__, attr))