Undocumented
Class | _Deprecate |
Decorator class to deprecate old functions. |
Function | _get_indent |
Determines the leading whitespace that could be removed from all the lines. |
Function | _getmembers |
Undocumented |
Function | _info |
Provide information about ndarray obj. |
Function | _lookfor_generate_cache |
Generate docstring cache for given module. |
Function | _makenamedict |
Undocumented |
Function | _median_nancheck |
Utility function to check median result from data for NaN values at the end and return NaN in that case. Input result can also be a MaskedArray. |
Function | _opt_info |
Returns a string contains the supported CPU features by the current build. |
Function | _set_function_name |
Undocumented |
Function | _split_line |
Undocumented |
Function | byte_bounds |
Returns pointers to the end-points of an array. |
Function | deprecate |
Issues a DeprecationWarning, adds warning to old_name 's docstring, rebinds old_name.__name__ and returns the new function object. |
Function | deprecate_with_doc |
Deprecates a function and includes the deprecation in its docstring. |
Function | get_include |
Return the directory that contains the NumPy *.h header files. |
Function | info |
Get help information for a function, class, or module. |
Function | issubclass_ |
Determine if a class is a subclass of a second class. |
Function | issubsctype |
Determine if the first argument is a subclass of the second argument. |
Function | lookfor |
Do a keyword search on docstrings. |
Function | safe_eval |
Protected string evaluation. |
Function | source |
Print or write to a file the source code for a NumPy object. |
Function | who |
Print the NumPy arrays in the given dictionary. |
Variable | _dictlist |
Undocumented |
Variable | _function_signature_re |
Undocumented |
Variable | _lookfor_caches |
Undocumented |
Variable | _namedict |
Undocumented |
Provide information about ndarray obj.
Copied over from the numarray module prior to its removal. Adapted somewhat as only numpy is an option now.
Called by info.
Generate docstring cache for given module.
Utility function to check median result from data for NaN values at the end and return NaN in that case. Input result can also be a MaskedArray.
Returns a string contains the supported CPU features by the current build.
*
.?
.Returns pointers to the end-points of an array.
a
is not
contiguous it will not use every byte between the (low
, high
)
values.>>> I = np.eye(2, dtype='f'); I.dtype dtype('float32') >>> low, high = np.byte_bounds(I) >>> high - low == I.size*I.itemsize True >>> I = np.eye(2); I.dtype dtype('float64') >>> low, high = np.byte_bounds(I) >>> high - low == I.size*I.itemsize True
Issues a DeprecationWarning, adds warning to old_name
's
docstring, rebinds old_name.__name__ and returns the new
function object.
This function may also be used as a decorator.
func
is used.old_name
is deprecated. If given, the
deprecation message is that old_name
is deprecated and new_name
should be used instead.Note that olduint returns a value after printing Deprecation Warning:
>>> olduint = np.deprecate(np.uint) DeprecationWarning: `uint64` is deprecated! # may vary >>> olduint(6) 6
Deprecates a function and includes the deprecation in its docstring.
This function is used as a decorator. It returns an object that can be used to issue a DeprecationWarning, by passing the to-be decorated function as argument, this adds warning to the to-be decorated function's docstring and returns the new function object.
deprecate : Decorate a function such that it issues a DeprecationWarning
obj : object
Return the directory that contains the NumPy *.h header files.
Extension modules that need to compile against NumPy should use this function to locate the appropriate include directory.
When using distutils, for example in setup.py.
import numpy as np ... Extension('extension_name', ... include_dirs=[np.get_include()]) ...
Get help information for a function, class, or module.
object
is a
numpy object, its docstring is given. If it is a string, available
modules are searched for matching objects. If None, information
about info
itself is returned.source, lookfor
When used interactively with an object, np.info(obj) is equivalent to help(obj) on the Python prompt or obj? on the IPython prompt.
>>> np.info(np.polyval) # doctest: +SKIP polyval(p, x) Evaluate the polynomial p at x. ...
When using a string for object
it is possible to get multiple results.
>>> np.info('fft') # doctest: +SKIP *** Found in numpy *** Core FFT routines ... *** Found in numpy.fft *** fft(a, n=None, axis=-1) ... *** Repeat reference found in numpy.fft.fftpack *** *** Total of 3 references found. ***
Determine if a class is a subclass of a second class.
issubclass_
is equivalent to the Python built-in issubclass,
except that it returns False instead of raising a TypeError if one
of the arguments is not a class.
arg1
is a subclass of arg2
.arg1
is a
subclass of any of the tuple elements.arg1
is a subclass of arg2
or not.issubsctype, issubdtype, issctype
>>> np.issubclass_(np.int32, int) False >>> np.issubclass_(np.int32, float) False >>> np.issubclass_(np.float64, float) True
Determine if the first argument is a subclass of the second argument.
issctype, issubdtype, obj2sctype
>>> np.issubsctype('S8', str) False >>> np.issubsctype(np.array([1]), int) True >>> np.issubsctype(np.array([1]), float) False
Do a keyword search on docstrings.
A list of objects that matched the search is displayed, sorted by relevance. All given keywords need to be found in the docstring for it to be returned as a result, but the order does not matter.
source, info
Relevance is determined only roughly, by checking if the keywords occur in the function name, at the start of a docstring, etc.
>>> np.lookfor('binary representation') # doctest: +SKIP Search results for 'binary representation' ------------------------------------------ numpy.binary_repr Return the binary representation of the input number as a string. numpy.core.setup_common.long_double_representation Given a binary dump as given by GNU od -b, look for long double numpy.base_repr Return a string representation of a number in the given base system. ...
Protected string evaluation.
Evaluate a string containing a Python literal expression without allowing the execution of arbitrary non-literal code.
source
.>>> np.safe_eval('1') 1 >>> np.safe_eval('[1, 2, 3]') [1, 2, 3] >>> np.safe_eval('{"foo": ("bar", 10.0)}') {'foo': ('bar', 10.0)}
>>> np.safe_eval('import os') Traceback (most recent call last): ... SyntaxError: invalid syntax
>>> np.safe_eval('open("/home/user/.ssh/id_dsa").read()') Traceback (most recent call last): ... ValueError: malformed node or string: <_ast.Call object at 0x...>
Print or write to a file the source code for a NumPy object.
The source code is only returned for objects written in Python. Many functions and classes are defined in C and will therefore not return useful information.
output
not supplied then source code is printed to screen
(sys.stdout). File object must be created with either write 'w' or
append 'a' modes.lookfor, info
>>> np.source(np.interp) #doctest: +SKIP In file: /usr/lib/python2.6/dist-packages/numpy/lib/function_base.py def interp(x, xp, fp, left=None, right=None): """.... (full docstring printed)""" if isinstance(x, (float, int, number)): return compiled_interp([x], xp, fp, left, right).item() else: return compiled_interp(x, xp, fp, left, right)
The source code is only returned for objects written in Python.
>>> np.source(np.array) #doctest: +SKIP Not available for this object.
Print the NumPy arrays in the given dictionary.
If there is no dictionary passed in or vardict
is None then returns
NumPy arrays in the globals() dictionary (all NumPy arrays in the
namespace).
Prints out the name, shape, bytes and type of all of the ndarrays
present in vardict
.
>>> a = np.arange(10) >>> b = np.ones(20) >>> np.who() Name Shape Bytes Type =========================================================== a 10 80 int64 b 20 160 float64 Upper bound on total bytes = 240
>>> d = {'x': np.arange(2.0), 'y': np.arange(3.0), 'txt': 'Some str', ... 'idx':5} >>> np.who(d) Name Shape Bytes Type =========================================================== x 2 16 float64 y 3 24 float64 Upper bound on total bytes = 40