Warning
This documentation is work-in-progress and unorganized.
Various utilities that don’t have another home.
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).
Parameters : | vardict : dict, optional
|
---|---|
Returns : | out : None
|
Notes
Prints out the name, shape, bytes and type of all of the ndarrays present in vardict.
Examples
>>> a = np.arange(10)
>>> b = np.ones(20)
>>> np.who()
Name Shape Bytes Type
===========================================================
a 10 40 int32
b 20 160 float64
Upper bound on total bytes = 200
>>> d = {'x': np.arange(2.0), 'y': np.arange(3.0), 'txt': 'Some str',
... 'idx':5}
>>> np.whos(d)
Name Shape Bytes Type
===========================================================
y 3 24 float64
x 2 16 float64
Upper bound on total bytes = 40
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.
Parameters : | object : numpy object
output : file object, optional
|
---|
See also
lookfor, info
Examples
>>> np.source(np.interp)
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)
Not available for this object.
Get help information for a function, class, or module.
Parameters : | object : object or str, optional
maxwidth : int, optional
output : file like object, optional
toplevel : str, optional
|
---|
See also
source, lookfor
Notes
When used interactively with an object, np.info(obj) is equivalent to help(obj) on the Python prompt or obj? on the IPython prompt.
Examples
>>> np.info(np.polyval)
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')
*** 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. ***
Return a copy of a PIL image as a numpy array.
Parameters : | im : PIL image
flatten : bool
|
---|---|
Returns : | img_array : ndarray
|
Takes a numpy array and returns a PIL image. The mode of the PIL image depends on the array shape, the pal keyword, and the mode keyword.
For 2-D arrays, if pal is a valid (N,3) byte-array giving the RGB values (from 0 to 255) then mode=’P’, otherwise mode=’L’, unless mode is given as ‘F’ or ‘I’ in which case a float and/or integer array is made
if the
The numpy array must be either 2 dimensional or 3 dimensional.
Save an array to an image file.
Parameters : | im : PIL image
flatten : bool
|
---|---|
Returns : | img_array : ndarray
|
Read an image file from a filename.
Parameters : | name : str
flatten : bool, optional
|
---|---|
Returns : | : nd_array :
|
Notes
The image is flattened by calling convert(‘F’) on the resulting image object.
Parameters : | im : PIL image
flatten : bool
|
---|---|
Returns : | img_array : ndarray
|
Rotate an image counter-clockwise by angle degrees.
Parameters : | arr : nd_array
angle : float
interp : str, optional
|
---|---|
Returns : | : nd_array :
|
Notes
Interpolation methods can be: * ‘nearest’ : for nearest neighbor * ‘bilinear’ : for bilinear * ‘cubic’ : cubic * ‘bicubic’ : for bicubic
Resize an image.
Parameters : | arr : nd_array
size : int, float or tuple
|
---|---|
Returns : | : nd_array :
|
Simple showing of an image through an external viewer.
Simple filtering of an image.
Parameters : | arr : ndarray
ftype : str
|
---|---|
Returns : | res : nd_array
|
Raises : | ValueError :
|
n! = special.gamma(n+1)
If exact==0, then floating point precision is used, otherwise exact long integer is computed.
Double factorial.
This is the factorial with every second value is skipped, i.e., 7!! = 7 * 5 * 3 * 1. It can be approximated numerically as:
n!! = special.gamma(n/2+1)*2**((m+1)/2)/sqrt(pi) n odd
= 2**(n/2) * (n/2)! n even
Parameters : | n : int, array-like
exact : bool, optional
|
---|---|
Returns : | nff : float or int
|
References
[R89] | Wikipedia, “Double Factorial”, http://en.wikipedia.org/wiki/Factorial#Double_factorial |
n(!!...!) = multifactorial of order k k times
Parameters : | n : int, array-like
exact : bool, optional
|
---|---|
Returns : | val : int
|
Raises : | NotImplementedError :
|
Combinations of N things taken k at a time.
Parameters : | N : int, array
k : int, array
exact : int, optional
|
---|---|
Returns : | val : int, array
|
Notes
Return weights for an Np-point central derivative of order ndiv assuming equally-spaced function points.
If weights are in the vector w, then derivative is w[0] * f(x-ho*dx) + ... + w[-1] * f(x+h0*dx)
Notes
Can be inaccurate for large number of points.
Find the n-th derivative of a function at point x0.
Given a function, use a central difference formula with spacing dx to compute the n-th derivative at x0.
Parameters : | func : function
x0 : float
dx : int, optional
n : int, optional
args : tuple, optional
order : int, optional
|
---|
Notes
Decreasing the step size too small can result in round-off error.
Given Taylor series coefficients in an, return a Pade approximation to the function as the ratio of two polynomials p / q where the order of q is m.