# scipy/scipy

MAINT: fix more Sphinx warnings.

• Loading branch information...
1 parent e98c18e commit 8be148e86f2c65b2bf4c897dac6f2ed89c404d55 rgommers committed Apr 22, 2012
 @@ -129,13 +129,9 @@ * Mathematica is a registered trademark of The Wolfram Research, Inc. -Copyright Notice ----------------- - -Copyright (C) Damian Eads, 2007-2008. New BSD License. - """ +# Copyright (C) Damian Eads, 2007-2008. New BSD License. # hierarchy.py (derived from cluster.py, http://scipy-cluster.googlecode.com) # @@ -171,13 +167,15 @@ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + import types import warnings import numpy as np import _hierarchy_wrap import scipy.spatial.distance as distance + _cpy_non_euclid_methods = {'single': 0, 'complete': 1, 'average': 2, 'weighted': 6} _cpy_euclid_methods = {'centroid': 3, 'median': 4, 'ward': 5}
 @@ -178,12 +178,12 @@ class LinearNDInterpolator(NDInterpolatorBase): Notes ----- The interpolant is constructed by triangulating the input data - with Qhull [Qhull]_, and on each triangle performing linear + with Qhull [1]_, and on each triangle performing linear barycentric interpolation. References ---------- - .. [Qhull] http://www.qhull.org/ + .. [1] http://www.qhull.org/ """ @@ -509,9 +509,9 @@ cdef \${CDTYPE} _clough_tocher_2d_single_\${DTYPE}(qhull.DelaunayInfo_t *d, Parameters ---------- - d + d : Delaunay info - isimplex + isimplex : int Triangle to evaluate on b : shape (3,) Barycentric coordinates of the point on the triangle @@ -522,7 +522,7 @@ cdef \${CDTYPE} _clough_tocher_2d_single_\${DTYPE}(qhull.DelaunayInfo_t *d, Returns ------- - w + w : Value of the interpolant at the given point References @@ -758,7 +758,7 @@ class CloughTocher2DInterpolator(NDInterpolatorBase): Notes ----- The interpolant is constructed by triangulating the input data - with Qhull [Qhull]_, and constructing a piecewise cubic + with Qhull [1]_, and constructing a piecewise cubic interpolating Bezier polynomial on each triangle, using a Clough-Tocher scheme [CT]_. The interpolant is guaranteed to be continuously differentiable. @@ -770,8 +770,7 @@ class CloughTocher2DInterpolator(NDInterpolatorBase): References ---------- - - .. [Qhull] http://www.qhull.org/ + .. [1] http://www.qhull.org/ .. [CT] See, for example, P. Alfeld,
 @@ -22,7 +22,8 @@ def use_solver( **kwargs ): """ - Valid keyword arguments with defaults (other ignored): + Valid keyword arguments with defaults (other ignored):: + useUmfpack = True assumeSortedIndices = False @@ -31,8 +32,9 @@ def use_solver( **kwargs ): based solver to be used. Umfpack requires a CSR/CSC matrix to have sorted column/row indices. If - sure that the matrix fulfills this, pass assumeSortedIndices=True + sure that the matrix fulfills this, pass ``assumeSortedIndices=True`` to gain some speed. + """ if 'useUmfpack' in kwargs: globals()['useUmfpack'] = kwargs['useUmfpack'] @@ -42,8 +44,7 @@ def use_solver( **kwargs ): def spsolve(A, b, permc_spec=None, use_umfpack=True): - """Solve the sparse linear system Ax=b - """ + """Solve the sparse linear system Ax=b """ if isspmatrix( b ): b = b.toarray() @@ -105,9 +106,8 @@ def splu(A, permc_spec=None, diag_pivot_thresh=None, Parameters ---------- - A + A : sparse matrix Sparse matrix to factorize. Should be in CSR or CSC format. - permc_spec : str, optional How to permute the columns of the matrix for sparsity preservation. (default: 'COLAMD') @@ -218,12 +218,7 @@ def spilu(A, drop_tol=None, fill_factor=None, drop_rule=None, permc_spec=None, This function uses the SuperLU library. - References - ---------- - .. [SLU] SuperLU http://crd.lbl.gov/~xiaoye/SuperLU/ - """ - if not isspmatrix_csc(A): A = csc_matrix(A) warn('splu requires CSC matrix format', SparseEfficiencyWarning)
 @@ -1072,47 +1072,40 @@ def eigs(A, k=6, M=None, sigma=None, which='LM', v0=None, Parameters ---------- - A : An N x N matrix, array, sparse matrix, or LinearOperator representing - the operation A * x, where A is a real or complex square matrix. - k : integer + A : ndarray, sparse matrix or LinearOperator + An array, sparse matrix, or LinearOperator representing + the operation ``A * x``, where A is a real or complex square matrix. + k : int, optional The number of eigenvalues and eigenvectors desired. `k` must be smaller than N. It is not possible to compute all eigenvectors of a matrix. - - Returns - ------- - w : array - Array of k eigenvalues. - v : array - An array of `k` eigenvectors. - ``v[:, i]`` is the eigenvector corresponding to the eigenvalue w[i]. - - Other Parameters - ---------------- - M : An N x N matrix, array, sparse matrix, or LinearOperator representing + M : ndarray, sparse matrix or LinearOperator, optional + An array, sparse matrix, or LinearOperator representing the operation M*x for the generalized eigenvalue problem - ``A * x = w * M * x`` + ``A * x = w * M * x``. M must represent a real, symmetric matrix if A is real, and must represent a complex, hermitian matrix if A is complex. For best results, the data type of M should be the same as that of A. Additionally: - * If sigma==None, M is positive definite - * If sigma is specified, M is positive semi-definite - If sigma==None, eigs requires an operator to compute the solution - of the linear equation `M * x = b`. This is done internally via a + + - If `sigma` is None, M is positive definite + - If sigma is specified, M is positive semi-definite + + If sigma is None, eigs requires an operator to compute the solution + of the linear equation ``M * x = b``. This is done internally via a (sparse) LU decomposition for an explicit matrix M, or via an iterative solver for a general linear operator. Alternatively, the user can supply the matrix or operator Minv, which gives - x = Minv * b = M^-1 * b - sigma : real or complex + ``x = Minv * b = M^-1 * b``. + sigma : real or complex, optional Find eigenvalues near sigma using shift-invert mode. This requires an operator to compute the solution of the linear system - `[A - sigma * M] * x = b`, where M is the identity matrix if + ``[A - sigma * M] * x = b``, where M is the identity matrix if unspecified. This is computed internally via a (sparse) LU decomposition for explicit matrices A & M, or via an iterative solver if either A or M is a general linear operator. Alternatively, the user can supply the matrix or operator OPinv, - which gives x = OPinv * b = [A - sigma * M]^-1 * b. + which gives ``x = OPinv * b = [A - sigma * M]^-1 * b``. For a real matrix A, shift-invert can either be done in imaginary mode or real mode, specified by the parameter OPpart ('r' or 'i'). Note that when sigma is specified, the keyword 'which' (below) @@ -1124,12 +1117,12 @@ def eigs(A, k=6, M=None, sigma=None, which='LM', v0=None, ``w'[i] = 1/2i * [1/(w[i]-sigma) - 1/(w[i]-conj(sigma))]``. - If A is complex, ``w'[i] = 1/(w[i]-sigma)``. - v0 : ndarray + v0 : ndarray, optional Starting vector for iteration. - ncv : int + ncv : int, optional The number of Lanczos vectors generated `ncv` must be greater than `k`; it is recommended that ``ncv > 2*k``. - which : str, ['LM' | 'SM' | 'LR' | 'SR' | 'LI' | 'SI'] + which : str, ['LM' | 'SM' | 'LR' | 'SR' | 'LI' | 'SI'], optional Which `k` eigenvectors and eigenvalues to find: - 'LM' : largest magnitude @@ -1143,20 +1136,28 @@ def eigs(A, k=6, M=None, sigma=None, which='LM', v0=None, (see discussion in 'sigma', above). ARPACK is generally better at finding large values than small values. If small eigenvalues are desired, consider using shift-invert mode for better performance. - maxiter : int + maxiter : int, optional Maximum number of Arnoldi update iterations allowed - tol : float + tol : float, optional Relative accuracy for eigenvalues (stopping criterion) The default value of 0 implies machine precision. - return_eigenvectors : bool + return_eigenvectors : bool, optional Return eigenvectors (True) in addition to eigenvalues - Minv : N x N matrix, array, sparse matrix, or linear operator + Minv : ndarray, sparse matrix or LinearOperator, optional See notes in M, above. - OPinv : N x N matrix, array, sparse matrix, or linear operator + OPinv : ndarray, sparse matrix or LinearOperator, optional See notes in sigma, above. - OPpart : 'r' or 'i'. + OPpart : {'r' or 'i'}, optional See notes in sigma, above + Returns + ------- + w : ndarray + Array of k eigenvalues. + v : ndarray + An array of `k` eigenvectors. + ``v[:, i]`` is the eigenvector corresponding to the eigenvalue w[i]. + Raises ------ ArpackNoConvergence @@ -1319,15 +1320,17 @@ def eigsh(A, k=6, M=None, sigma=None, which='LM', v0=None, represent a complex, hermitian matrix if A is complex. For best results, the data type of M should be the same as that of A. Additionally: - * If sigma == None, M is symmetric positive definite - * If sigma is specified, M is symmetric positive semi-definite - * In buckling mode, M is symmetric indefinite. - If sigma == None, eigsh requires an operator to compute the solution - of the linear equation `M * x = b`. This is done internally via a + + - If sigma is None, M is symmetric positive definite + - If sigma is specified, M is symmetric positive semi-definite + - In buckling mode, M is symmetric indefinite. + + If sigma is None, eigsh requires an operator to compute the solution + of the linear equation ``M * x = b``. This is done internally via a (sparse) LU decomposition for an explicit matrix M, or via an iterative solver for a general linear operator. Alternatively, the user can supply the matrix or operator Minv, which gives - x = Minv * b = M^-1 * b + ``x = Minv * b = M^-1 * b``. sigma : real Find eigenvalues near sigma using shift-invert mode. This requires an operator to compute the solution of the linear system @@ -1336,9 +1339,9 @@ def eigsh(A, k=6, M=None, sigma=None, which='LM', v0=None, decomposition for explicit matrices A & M, or via an iterative solver if either A or M is a general linear operator. Alternatively, the user can supply the matrix or operator OPinv, - which gives x = OPinv * b = [A - sigma * M]^-1 * b. + which gives ``x = OPinv * b = [A - sigma * M]^-1 * b``. Note that when sigma is specified, the keyword 'which' refers to - the shifted eigenvalues w'[i] where: + the shifted eigenvalues ``w'[i]`` where: - if mode == 'normal', ``w'[i] = 1 / (w[i] - sigma)``. - if mode == 'cayley', ``w'[i] = (w[i] + sigma) / (w[i] - sigma)``.
 @@ -59,56 +59,10 @@ sqeuclidean -- the squared Euclidean distance. yule -- the Yule dissimilarity (boolean). +""" -References ----------- - -.. [Sta07] "Statistics toolbox." API Reference Documentation. The MathWorks. - http://www.mathworks.com/access/helpdesk/help/toolbox/stats/. - Accessed October 1, 2007. - -.. [Mti07] "Hierarchical clustering." API Reference Documentation. - The Wolfram Research, Inc. - http://reference.wolfram.com/mathematica/HierarchicalClustering/tutorial/HierarchicalClustering.html. - Accessed October 1, 2007. - -.. [Gow69] Gower, JC and Ross, GJS. "Minimum Spanning Trees and Single Linkage - Cluster Analysis." Applied Statistics. 18(1): pp. 54--64. 1969. - -.. [War63] Ward Jr, JH. "Hierarchical grouping to optimize an objective - function." Journal of the American Statistical Association. 58(301): - pp. 236--44. 1963. - -.. [Joh66] Johnson, SC. "Hierarchical clustering schemes." Psychometrika. - 32(2): pp. 241--54. 1966. - -.. [Sne62] Sneath, PH and Sokal, RR. "Numerical taxonomy." Nature. 193: pp. - 855--60. 1962. - -.. [Bat95] Batagelj, V. "Comparing resemblance measures." Journal of - Classification. 12: pp. 73--90. 1995. - -.. [Sok58] Sokal, RR and Michener, CD. "A statistical method for evaluating - systematic relationships." Scientific Bulletins. 38(22): - pp. 1409--38. 1958. - -.. [Ede79] Edelbrock, C. "Mixture model tests of hierarchical clustering - algorithms: the problem of classifying everybody." Multivariate - Behavioral Research. 14: pp. 367--84. 1979. - -.. [Jai88] Jain, A., and Dubes, R., "Algorithms for Clustering Data." - Prentice-Hall. Englewood Cliffs, NJ. 1988. - -.. [Fis36] Fisher, RA "The use of multiple measurements in taxonomic - problems." Annals of Eugenics, 7(2): 179-188. 1936 - - -Copyright Notice ----------------- - -Copyright (C) Damian Eads, 2007-2008. New BSD License. +# Copyright (C) Damian Eads, 2007-2008. New BSD License. -""" import warnings import numpy as np
 @@ -616,14 +616,14 @@ def query_pairs(self, r, p=2., eps=0): ``1 <= p <= infinity``. eps : float, optional Approximate search. Branches of the tree are not explored - if their nearest points are further than r/(1+eps), and branches - are added in bulk if their furthest points are nearer than - ``r * (1+eps)``. `eps` has to be non-negative. + if their nearest points are further than ``r/(1+eps)``, and + branches are added in bulk if their furthest points are nearer + than ``r * (1+eps)``. `eps` has to be non-negative. Returns ------- results : set - Set of pairs ``(i,j)``, with ``i

#### 0 comments on commit `8be148e`

Please sign in to comment.