__init__.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. """
  2. SciPy: A scientific computing package for Python
  3. ================================================
  4. Documentation is available in the docstrings and
  5. online at https://docs.scipy.org.
  6. Contents
  7. --------
  8. SciPy imports all the functions from the NumPy namespace, and in
  9. addition provides:
  10. Subpackages
  11. -----------
  12. Using any of these subpackages requires an explicit import. For example,
  13. ``import scipy.cluster``.
  14. ::
  15. cluster --- Vector Quantization / Kmeans
  16. fftpack --- Discrete Fourier Transform algorithms
  17. integrate --- Integration routines
  18. interpolate --- Interpolation Tools
  19. io --- Data input and output
  20. linalg --- Linear algebra routines
  21. linalg.blas --- Wrappers to BLAS library
  22. linalg.lapack --- Wrappers to LAPACK library
  23. misc --- Various utilities that don't have
  24. another home.
  25. ndimage --- n-dimensional image package
  26. odr --- Orthogonal Distance Regression
  27. optimize --- Optimization Tools
  28. signal --- Signal Processing Tools
  29. signal.windows --- Window functions
  30. sparse --- Sparse Matrices
  31. sparse.linalg --- Sparse Linear Algebra
  32. sparse.linalg.dsolve --- Linear Solvers
  33. sparse.linalg.dsolve.umfpack --- :Interface to the UMFPACK library:
  34. Conjugate Gradient Method (LOBPCG)
  35. sparse.linalg.eigen --- Sparse Eigenvalue Solvers
  36. sparse.linalg.eigen.lobpcg --- Locally Optimal Block Preconditioned
  37. Conjugate Gradient Method (LOBPCG)
  38. spatial --- Spatial data structures and algorithms
  39. special --- Special functions
  40. stats --- Statistical Functions
  41. Utility tools
  42. -------------
  43. ::
  44. test --- Run scipy unittests
  45. show_config --- Show scipy build configuration
  46. show_numpy_config --- Show numpy build configuration
  47. __version__ --- Scipy version string
  48. __numpy_version__ --- Numpy version string
  49. """
  50. from __future__ import division, print_function, absolute_import
  51. __all__ = ['test']
  52. from numpy import show_config as show_numpy_config
  53. if show_numpy_config is None:
  54. raise ImportError(
  55. "Cannot import scipy when running from numpy source directory.")
  56. from numpy import __version__ as __numpy_version__
  57. # Import numpy symbols to scipy name space
  58. import numpy as _num
  59. linalg = None
  60. from numpy import *
  61. from numpy.random import rand, randn
  62. from numpy.fft import fft, ifft
  63. from numpy.lib.scimath import *
  64. # Allow distributors to run custom init code
  65. from . import _distributor_init
  66. __all__ += _num.__all__
  67. __all__ += ['randn', 'rand', 'fft', 'ifft']
  68. del _num
  69. # Remove the linalg imported from numpy so that the scipy.linalg package can be
  70. # imported.
  71. del linalg
  72. __all__.remove('linalg')
  73. # We first need to detect if we're being called as part of the scipy
  74. # setup procedure itself in a reliable manner.
  75. try:
  76. __SCIPY_SETUP__
  77. except NameError:
  78. __SCIPY_SETUP__ = False
  79. if __SCIPY_SETUP__:
  80. import sys as _sys
  81. _sys.stderr.write('Running from scipy source directory.\n')
  82. del _sys
  83. else:
  84. try:
  85. from scipy.__config__ import show as show_config
  86. except ImportError:
  87. msg = """Error importing scipy: you cannot import scipy while
  88. being in scipy source directory; please exit the scipy source
  89. tree first, and relaunch your python interpreter."""
  90. raise ImportError(msg)
  91. from scipy.version import version as __version__
  92. from scipy._lib._version import NumpyVersion as _NumpyVersion
  93. if _NumpyVersion(__numpy_version__) < '1.8.2':
  94. import warnings
  95. warnings.warn("Numpy 1.8.2 or above is recommended for this version of "
  96. "scipy (detected version %s)" % __numpy_version__,
  97. UserWarning)
  98. del _NumpyVersion
  99. from scipy._lib._ccallback import LowLevelCallable
  100. from scipy._lib._testutils import PytestTester
  101. test = PytestTester(__name__)
  102. del PytestTester