Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.9/dist-packages/numpy/lib/__init__.py: 88%

43 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-09 06:12 +0000

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 

51from numpy._pytesttester import PytestTester 

52test = PytestTester(__name__) 

53del PytestTester 

54 

55def __getattr__(attr): 

56 # Warn for reprecated attributes 

57 import math 

58 import warnings 

59 

60 if attr == "math": 

61 warnings.warn( 

62 "`np.lib.math` is a deprecated alias for the standard library " 

63 "`math` module (Deprecated Numpy 1.25). Replace usages of " 

64 "`numpy.lib.math` with `math`", DeprecationWarning, stacklevel=2) 

65 return math 

66 elif attr == "emath": 

67 raise AttributeError( 

68 "numpy.lib.emath was an alias for emath module that was removed " 

69 "in NumPy 2.0. Replace usages of numpy.lib.emath with " 

70 "numpy.emath." 

71 ) 

72 elif attr in ( 

73 "histograms", "type_check", "nanfunctions", "function_base", 

74 "arraypad", "arraysetops", "ufunclike", "utils", "twodim_base", 

75 "shape_base", "polynomial", "index_tricks", 

76 ): 

77 raise AttributeError( 

78 f"numpy.lib.{attr} is now private. If you are using a public " 

79 "function, it should be available in the main numpy namespace, " 

80 "otherwise check the NumPy 2.0 migration guide." 

81 ) 

82 elif attr == "arrayterator": 

83 raise AttributeError( 

84 "numpy.lib.arrayterator submodule is now private. To access " 

85 "Arrayterator class use numpy.lib.Arrayterator." 

86 ) 

87 else: 

88 raise AttributeError("module {!r} has no attribute " 

89 "{!r}".format(__name__, attr))