Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.9/dist-packages/scipy/__init__.py: 58%
36 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-03 06:39 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-03 06:39 +0000
1"""
2SciPy: A scientific computing package for Python
3================================================
5Documentation is available in the docstrings and
6online at https://docs.scipy.org.
8Subpackages
9-----------
10Using any of these subpackages requires an explicit import. For example,
11``import scipy.cluster``.
13::
15 cluster --- Vector Quantization / Kmeans
16 constants --- Physical and mathematical constants and units
17 datasets --- Dataset methods
18 fft --- Discrete Fourier transforms
19 fftpack --- Legacy discrete Fourier transforms
20 integrate --- Integration routines
21 interpolate --- Interpolation Tools
22 io --- Data input and output
23 linalg --- Linear algebra routines
24 misc --- Utilities that don't have another home.
25 ndimage --- N-D image package
26 odr --- Orthogonal Distance Regression
27 optimize --- Optimization Tools
28 signal --- Signal Processing Tools
29 sparse --- Sparse Matrices
30 spatial --- Spatial data structures and algorithms
31 special --- Special functions
32 stats --- Statistical Functions
34Public API in the main SciPy namespace
35--------------------------------------
36::
38 __version__ --- SciPy version string
39 LowLevelCallable --- Low-level callback function
40 show_config --- Show scipy build configuration
41 test --- Run scipy unittests
43"""
45import importlib as _importlib
47from numpy import __version__ as __numpy_version__
50try:
51 from scipy.__config__ import show as show_config
52except ImportError as e:
53 msg = """Error importing SciPy: you cannot import SciPy while
54 being in scipy source directory; please exit the SciPy source
55 tree first and relaunch your Python interpreter."""
56 raise ImportError(msg) from e
59from scipy.version import version as __version__
62# Allow distributors to run custom init code
63from . import _distributor_init
64del _distributor_init
67from scipy._lib import _pep440
68# In maintenance branch, change to np_maxversion N+3 if numpy is at N
69np_minversion = '1.22.4'
70np_maxversion = '9.9.99'
71if (_pep440.parse(__numpy_version__) < _pep440.Version(np_minversion) or
72 _pep440.parse(__numpy_version__) >= _pep440.Version(np_maxversion)):
73 import warnings
74 warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
75 f" is required for this version of SciPy (detected "
76 f"version {__numpy_version__})",
77 UserWarning, stacklevel=2)
78del _pep440
81# This is the first import of an extension module within SciPy. If there's
82# a general issue with the install, such that extension modules are missing
83# or cannot be imported, this is where we'll get a failure - so give an
84# informative error message.
85try:
86 from scipy._lib._ccallback import LowLevelCallable
87except ImportError as e:
88 msg = "The `scipy` install you are using seems to be broken, " + \
89 "(extension modules cannot be imported), " + \
90 "please try reinstalling."
91 raise ImportError(msg) from e
94from scipy._lib._testutils import PytestTester
95test = PytestTester(__name__)
96del PytestTester
99submodules = [
100 'cluster',
101 'constants',
102 'datasets',
103 'fft',
104 'fftpack',
105 'integrate',
106 'interpolate',
107 'io',
108 'linalg',
109 'misc',
110 'ndimage',
111 'odr',
112 'optimize',
113 'signal',
114 'sparse',
115 'spatial',
116 'special',
117 'stats'
118]
120__all__ = submodules + [
121 'LowLevelCallable',
122 'test',
123 'show_config',
124 '__version__',
125]
128def __dir__():
129 return __all__
132def __getattr__(name):
133 if name in submodules:
134 return _importlib.import_module(f'scipy.{name}')
135 else:
136 try:
137 return globals()[name]
138 except KeyError:
139 raise AttributeError(
140 f"Module 'scipy' has no attribute '{name}'"
141 )