Blame numpy/__init__.py

Packit 7a8e5e
"""
Packit 7a8e5e
NumPy
Packit 7a8e5e
=====
Packit 7a8e5e
Packit 7a8e5e
Provides
Packit 7a8e5e
  1. An array object of arbitrary homogeneous items
Packit 7a8e5e
  2. Fast mathematical operations over arrays
Packit 7a8e5e
  3. Linear Algebra, Fourier Transforms, Random Number Generation
Packit 7a8e5e
Packit 7a8e5e
How to use the documentation
Packit 7a8e5e
----------------------------
Packit 7a8e5e
Documentation is available in two forms: docstrings provided
Packit 7a8e5e
with the code, and a loose standing reference guide, available from
Packit 7a8e5e
`the NumPy homepage <http://www.scipy.org>`_.
Packit 7a8e5e
Packit 7a8e5e
We recommend exploring the docstrings using
Packit 7a8e5e
`IPython <http://ipython.scipy.org>`_, an advanced Python shell with
Packit 7a8e5e
TAB-completion and introspection capabilities.  See below for further
Packit 7a8e5e
instructions.
Packit 7a8e5e
Packit 7a8e5e
The docstring examples assume that `numpy` has been imported as `np`::
Packit 7a8e5e
Packit 7a8e5e
  >>> import numpy as np
Packit 7a8e5e
Packit 7a8e5e
Code snippets are indicated by three greater-than signs::
Packit 7a8e5e
Packit 7a8e5e
  >>> x = 42
Packit 7a8e5e
  >>> x = x + 1
Packit 7a8e5e
Packit 7a8e5e
Use the built-in ``help`` function to view a function's docstring::
Packit 7a8e5e
Packit 7a8e5e
  >>> help(np.sort)
Packit 7a8e5e
  ... # doctest: +SKIP
Packit 7a8e5e
Packit 7a8e5e
For some objects, ``np.info(obj)`` may provide additional help.  This is
Packit 7a8e5e
particularly true if you see the line "Help on ufunc object:" at the top
Packit 7a8e5e
of the help() page.  Ufuncs are implemented in C, not Python, for speed.
Packit 7a8e5e
The native Python help() does not know how to view their help, but our
Packit 7a8e5e
np.info() function does.
Packit 7a8e5e
Packit 7a8e5e
To search for documents containing a keyword, do::
Packit 7a8e5e
Packit 7a8e5e
  >>> np.lookfor('keyword')
Packit 7a8e5e
  ... # doctest: +SKIP
Packit 7a8e5e
Packit 7a8e5e
General-purpose documents like a glossary and help on the basic concepts
Packit 7a8e5e
of numpy are available under the ``doc`` sub-module::
Packit 7a8e5e
Packit 7a8e5e
  >>> from numpy import doc
Packit 7a8e5e
  >>> help(doc)
Packit 7a8e5e
  ... # doctest: +SKIP
Packit 7a8e5e
Packit 7a8e5e
Available subpackages
Packit 7a8e5e
---------------------
Packit 7a8e5e
doc
Packit 7a8e5e
    Topical documentation on broadcasting, indexing, etc.
Packit 7a8e5e
lib
Packit 7a8e5e
    Basic functions used by several sub-packages.
Packit 7a8e5e
random
Packit 7a8e5e
    Core Random Tools
Packit 7a8e5e
linalg
Packit 7a8e5e
    Core Linear Algebra Tools
Packit 7a8e5e
fft
Packit 7a8e5e
    Core FFT routines
Packit 7a8e5e
polynomial
Packit 7a8e5e
    Polynomial tools
Packit 7a8e5e
testing
Packit 7a8e5e
    NumPy testing tools
Packit 7a8e5e
f2py
Packit 7a8e5e
    Fortran to Python Interface Generator.
Packit 7a8e5e
distutils
Packit 7a8e5e
    Enhancements to distutils with support for
Packit 7a8e5e
    Fortran compilers support and more.
Packit 7a8e5e
Packit 7a8e5e
Utilities
Packit 7a8e5e
---------
Packit 7a8e5e
test
Packit 7a8e5e
    Run numpy unittests
Packit 7a8e5e
show_config
Packit 7a8e5e
    Show numpy build configuration
Packit 7a8e5e
dual
Packit 7a8e5e
    Overwrite certain functions with high-performance Scipy tools
Packit 7a8e5e
matlib
Packit 7a8e5e
    Make everything matrices.
Packit 7a8e5e
__version__
Packit 7a8e5e
    NumPy version string
Packit 7a8e5e
Packit 7a8e5e
Viewing documentation using IPython
Packit 7a8e5e
-----------------------------------
Packit 7a8e5e
Start IPython with the NumPy profile (``ipython -p numpy``), which will
Packit 7a8e5e
import `numpy` under the alias `np`.  Then, use the ``cpaste`` command to
Packit 7a8e5e
paste examples into the shell.  To see which functions are available in
Packit 7a8e5e
`numpy`, type ``np.<TAB>`` (where ``<TAB>`` refers to the TAB key), or use
Packit 7a8e5e
``np.*cos*?<ENTER>`` (where ``<ENTER>`` refers to the ENTER key) to narrow
Packit 7a8e5e
down the list.  To view the docstring for a function, use
Packit 7a8e5e
``np.cos?<ENTER>`` (to view the docstring) and ``np.cos??<ENTER>`` (to view
Packit 7a8e5e
the source code).
Packit 7a8e5e
Packit 7a8e5e
Copies vs. in-place operation
Packit 7a8e5e
-----------------------------
Packit 7a8e5e
Most of the functions in `numpy` return a copy of the array argument
Packit 7a8e5e
(e.g., `np.sort`).  In-place versions of these functions are often
Packit 7a8e5e
available as array methods, i.e. ``x = np.array([1,2,3]); x.sort()``.
Packit 7a8e5e
Exceptions to this rule are documented.
Packit 7a8e5e
Packit 7a8e5e
"""
Packit 7a8e5e
from __future__ import division, absolute_import, print_function
Packit 7a8e5e
Packit 7a8e5e
import sys
Packit 7a8e5e
import warnings
Packit 7a8e5e
Packit 7a8e5e
from ._globals import ModuleDeprecationWarning, VisibleDeprecationWarning
Packit 7a8e5e
from ._globals import _NoValue
Packit 7a8e5e
Packit 7a8e5e
# We first need to detect if we're being called as part of the numpy setup
Packit 7a8e5e
# procedure itself in a reliable manner.
Packit 7a8e5e
try:
Packit 7a8e5e
    __NUMPY_SETUP__
Packit 7a8e5e
except NameError:
Packit 7a8e5e
    __NUMPY_SETUP__ = False
Packit 7a8e5e
Packit 7a8e5e
if __NUMPY_SETUP__:
Packit 7a8e5e
    sys.stderr.write('Running from numpy source directory.\n')
Packit 7a8e5e
else:
Packit 7a8e5e
    try:
Packit 7a8e5e
        from numpy.__config__ import show as show_config
Packit 7a8e5e
    except ImportError:
Packit 7a8e5e
        msg = """Error importing numpy: you should not try to import numpy from
Packit 7a8e5e
        its source directory; please exit the numpy source tree, and relaunch
Packit 7a8e5e
        your python interpreter from there."""
Packit 7a8e5e
        raise ImportError(msg)
Packit 7a8e5e
Packit 7a8e5e
    from .version import git_revision as __git_revision__
Packit 7a8e5e
    from .version import version as __version__
Packit 7a8e5e
Packit 7a8e5e
    from ._import_tools import PackageLoader
Packit 7a8e5e
Packit 7a8e5e
    def pkgload(*packages, **options):
Packit 7a8e5e
        loader = PackageLoader(infunc=True)
Packit 7a8e5e
        return loader(*packages, **options)
Packit 7a8e5e
Packit 7a8e5e
    from . import add_newdocs
Packit 7a8e5e
    __all__ = ['add_newdocs',
Packit 7a8e5e
               'ModuleDeprecationWarning',
Packit 7a8e5e
               'VisibleDeprecationWarning']
Packit 7a8e5e
Packit 7a8e5e
    pkgload.__doc__ = PackageLoader.__call__.__doc__
Packit 7a8e5e
Packit 7a8e5e
    # We don't actually use this ourselves anymore, but I'm not 100% sure that
Packit 7a8e5e
    # no-one else in the world is using it (though I hope not)
Packit 7a8e5e
    from .testing import Tester, _numpy_tester
Packit 7a8e5e
    test = _numpy_tester().test
Packit 7a8e5e
    bench = _numpy_tester().bench
Packit 7a8e5e
Packit 7a8e5e
    # Allow distributors to run custom init code
Packit 7a8e5e
    from . import _distributor_init
Packit 7a8e5e
Packit 7a8e5e
    from . import core
Packit 7a8e5e
    from .core import *
Packit 7a8e5e
    from . import compat
Packit 7a8e5e
    from . import lib
Packit 7a8e5e
    from .lib import *
Packit 7a8e5e
    from . import linalg
Packit 7a8e5e
    from . import fft
Packit 7a8e5e
    from . import polynomial
Packit 7a8e5e
    from . import random
Packit 7a8e5e
    from . import ctypeslib
Packit 7a8e5e
    from . import ma
Packit 7a8e5e
    from . import matrixlib as _mat
Packit 7a8e5e
    from .matrixlib import *
Packit 7a8e5e
    from .compat import long
Packit 7a8e5e
Packit 7a8e5e
    # Make these accessible from numpy name-space
Packit 7a8e5e
    # but not imported in from numpy import *
Packit 7a8e5e
    if sys.version_info[0] >= 3:
Packit 7a8e5e
        from builtins import bool, int, float, complex, object, str
Packit 7a8e5e
        unicode = str
Packit 7a8e5e
    else:
Packit 7a8e5e
        from __builtin__ import bool, int, float, complex, object, unicode, str
Packit 7a8e5e
Packit 7a8e5e
    from .core import round, abs, max, min
Packit 7a8e5e
Packit 7a8e5e
    __all__.extend(['__version__', 'pkgload', 'PackageLoader',
Packit 7a8e5e
               'show_config'])
Packit 7a8e5e
    __all__.extend(core.__all__)
Packit 7a8e5e
    __all__.extend(_mat.__all__)
Packit 7a8e5e
    __all__.extend(lib.__all__)
Packit 7a8e5e
    __all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])
Packit 7a8e5e
Packit 7a8e5e
Packit 7a8e5e
    # Filter annoying Cython warnings that serve no good purpose.
Packit 7a8e5e
    warnings.filterwarnings("ignore", message="numpy.dtype size changed")
Packit 7a8e5e
    warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
Packit 7a8e5e
    warnings.filterwarnings("ignore", message="numpy.ndarray size changed")
Packit 7a8e5e
Packit 7a8e5e
    # oldnumeric and numarray were removed in 1.9. In case some packages import
Packit 7a8e5e
    # but do not use them, we define them here for backward compatibility.
Packit 7a8e5e
    oldnumeric = 'removed'
Packit 7a8e5e
    numarray = 'removed'