Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ran reindent

  • Loading branch information...
commit e835bd3c4f9c25c0e0b205fa8338523d1db47678 1 parent dd1eddb
@jarrodmillman jarrodmillman authored
Showing with 3,824 additions and 3,872 deletions.
  1. +87 −87 scipy/cluster/hierarchy.py
  2. +3 −3 scipy/cluster/tests/test_hierarchy.py
  3. +1 −1  scipy/fftpack/setupscons.py
  4. +13 −13 scipy/integrate/ode.py
  5. +1 −1  scipy/integrate/tests/test_integrate.py
  6. +5 −5 scipy/io/__init__.py
  7. +22 −22 scipy/io/arff/arffread.py
  8. +2 −2 scipy/io/arff/tests/test_data.py
  9. +1 −1  scipy/io/data_store.py
  10. +2 −2 scipy/io/matlab/mio4.py
  11. +0 −2  scipy/io/matlab/tests/test_mio.py
  12. +6 −6 scipy/io/mmio.py
  13. +2 −2 scipy/io/npfile.py
  14. +1 −1  scipy/io/pickler.py
  15. +23 −23 scipy/io/tests/test_mmio.py
  16. +1 −2  scipy/io/tests/test_recaster.py
  17. +1 −2  scipy/lib/blas/scons_support.py
  18. +1 −2  scipy/lib/lapack/scons_support.py
  19. +1 −2  scipy/lib/lapack/tests/test_lapack.py
  20. +1 −1  scipy/lib/setupscons.py
  21. +59 −59 scipy/linalg/basic.py
  22. +4 −5 scipy/linalg/benchmarks/bench_decom.py
  23. +1 −1  scipy/linalg/blas.py
  24. +89 −89 scipy/linalg/decomp.py
  25. +1 −1  scipy/linalg/iterative.py
  26. +14 −14 scipy/linalg/matfuncs.py
  27. +1 −2  scipy/linalg/scons_support.py
  28. +1 −1  scipy/linalg/tests/test_decomp.py
  29. +1,149 −1,149 scipy/ndimage/_registration.py
  30. +282 −282 scipy/ndimage/_segmenter.py
  31. +49 −49 scipy/ndimage/tests/test_segment.py
  32. +57 −57 scipy/optimize/slsqp.py
  33. +0 −1  scipy/sandbox/numexpr/__init__.py
  34. +11 −12 scipy/sparse/base.py
  35. +45 −46 scipy/sparse/bsr.py
  36. +37 −39 scipy/sparse/compressed.py
  37. +24 −25 scipy/sparse/construct.py
  38. +15 −16 scipy/sparse/coo.py
  39. +9 −10 scipy/sparse/csc.py
  40. +28 −29 scipy/sparse/csr.py
  41. +4 −5 scipy/sparse/data.py
  42. +10 −12 scipy/sparse/dia.py
  43. +1 −2  scipy/sparse/dok.py
  44. +2 −2 scipy/sparse/info.py
  45. +13 −14 scipy/sparse/lil.py
  46. +2 −3 scipy/sparse/linalg/dsolve/linsolve.py
  47. +1 −1  scipy/sparse/linalg/dsolve/setupscons.py
  48. +3 −4 scipy/sparse/linalg/dsolve/tests/test_linsolve.py
  49. +1 −1  scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py
  50. +28 −28 scipy/sparse/linalg/eigen/arpack/arpack.py
  51. +9 −9 scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py
  52. +10 −10 scipy/sparse/linalg/eigen/lobpcg/info.py
  53. +7 −7 scipy/sparse/linalg/eigen/lobpcg/lobpcg.py
  54. +9 −9 scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py
  55. +3 −3 scipy/sparse/linalg/eigen/setup.py
  56. +3 −3 scipy/sparse/linalg/eigen/setupscons.py
  57. +0 −1  scipy/sparse/linalg/isolve/__init__.py
  58. +1 −1  scipy/sparse/linalg/isolve/iterative.py
  59. +39 −40 scipy/sparse/linalg/isolve/minres.py
  60. +7 −7 scipy/sparse/linalg/isolve/tests/test_iterative.py
  61. +3 −5 scipy/sparse/linalg/isolve/utils.py
  62. +4 −4 scipy/sparse/linalg/setup.py
  63. +5 −5 scipy/sparse/linalg/setupscons.py
  64. +1 −1  scipy/sparse/linalg/tests/test_interface.py
  65. +1 −1  scipy/sparse/setupscons.py
  66. +0 −1  scipy/sparse/sparsetools/__init__.py
  67. +407 −408 scipy/sparse/sparsetools/bsr.py
  68. +90 −91 scipy/sparse/sparsetools/coo.py
  69. +290 −291 scipy/sparse/sparsetools/csc.py
  70. +475 −476 scipy/sparse/sparsetools/csr.py
  71. +35 −36 scipy/sparse/sparsetools/dia.py
  72. +1 −1  scipy/sparse/sparsetools/setupscons.py
  73. +2 −3 scipy/sparse/spfuncs.py
  74. +4 −5 scipy/sparse/sputils.py
  75. +17 −18 scipy/sparse/tests/bench_sparse.py
  76. +42 −42 scipy/sparse/tests/test_base.py
  77. +9 −10 scipy/sparse/tests/test_construct.py
  78. +11 −12 scipy/sparse/tests/test_spfuncs.py
  79. +2 −4 scipy/sparse/tests/test_sputils.py
  80. +0 −1  scipy/splinalg/__init__.py
  81. +9 −10 scipy/stats/mmorestats.py
  82. +3 −3 scipy/stats/models/contrast.py
  83. +10 −10 scipy/stats/models/formula.py
  84. +1 −1  scipy/stats/models/tests/test_formula.py
  85. +130 −130 scipy/stats/mstats.py
  86. +2 −2 scipy/stats/stats.py
  87. +3 −3 scipy/stats/tests/test_mmorestats.py
  88. +32 −32 scipy/stats/tests/test_mstats.py
  89. +2 −2 scipy/testing/decorators.py
  90. +2 −3 scipy/testing/examples/test_foo.py
  91. +12 −13 scipy/testing/nosetester.py
  92. +0 −1  scipy/testing/nulltester.py
  93. +1 −1  scipy/testing/pkgtester.py
  94. +0 −1  scipy/testing/utils.py
  95. +0 −1  scipy/weave/size_check.py
  96. +1 −1  scipy/weave/tests/test_blitz_tools.py
  97. +14 −14 scipy/weave/tests/test_c_spec.py
View
174 scipy/cluster/hierarchy.py
@@ -106,7 +106,7 @@
The Wolfram Research, Inc. http://reference.wolfram.com/...
...mathematica/HierarchicalClustering/tutorial/...
HierarchicalClustering.html. Accessed October 1, 2007.
-
+
[3] Gower, JC and Ross, GJS. "Minimum Spanning Trees and Single Linkage
Cluster Analysis." Applied Statistics. 18(1): pp. 54--64. 1969.
@@ -209,7 +209,7 @@ def _copy_array_if_base_present(a):
return numpy.float64(a)
else:
return a
-
+
def _copy_arrays_if_base_present(T):
"""
Accepts a tuple of arrays T. Copies the array T[i] if its base array
@@ -219,7 +219,7 @@ def _copy_arrays_if_base_present(T):
"""
l = [_copy_array_if_base_present(a) for a in T]
return l
-
+
def copying():
""" Displays the license for this package."""
@@ -286,7 +286,7 @@ def weighted(y):
def centroid(y):
"""
Z = centroid(y)
-
+
Performs centroid/UPGMC linkage on the condensed distance matrix Z.
See linkage for more information on the return structure and
algorithm.
@@ -297,7 +297,7 @@ def centroid(y):
Performs centroid/UPGMC linkage on the observation matrix X using
Euclidean distance as the distance metric. See linkage for more
- information on the return structure and algorithm.
+ information on the return structure and algorithm.
"""
return linkage(y, method='centroid', metric='euclidean')
@@ -314,7 +314,7 @@ def median(y):
Performs median/WPGMC linkage on the observation matrix X using
Euclidean distance as the distance metric. See linkage for more
- information on the return structure and algorithm.
+ information on the return structure and algorithm.
(a condensed alias for linkage)
"""
@@ -323,7 +323,7 @@ def median(y):
def ward(y):
"""
Z = ward(y)
-
+
Performs Ward's linkage on the condensed distance matrix Z. See
linkage for more information on the return structure and algorithm.
@@ -331,13 +331,13 @@ def ward(y):
Performs Ward's linkage on the observation matrix X using Euclidean
distance as the distance metric. See linkage for more information
- on the return structure and algorithm.
+ on the return structure and algorithm.
(a condensed alias for linkage)
"""
return linkage(y, method='ward', metric='euclidean')
-
+
def linkage(y, method='single', metric='euclidean'):
""" Z = linkage(y, method)
@@ -367,11 +367,11 @@ def linkage(y, method='single', metric='euclidean'):
A distance matrix is maintained at each iteration. The
d[i,j] entry corresponds to the distance between cluster
i and j in the original forest.
-
+
At each iteration, the algorithm must update the distance
matrix to reflect the distance of the newly formed cluster
u with the remaining clusters in the forest.
-
+
Suppose there are |u| original observations u[0], ..., u[|u|-1]
in cluster u and |v| original objects v[0], ..., v[|v|-1]
in cluster v. Recall s and t are combined to form cluster
@@ -380,7 +380,7 @@ def linkage(y, method='single', metric='euclidean'):
The following are methods for calculating the distance between
the newly formed cluster u and each v.
-
+
* method='single' assigns dist(u,v) = MIN(dist(u[i],v[j])
for all points i in cluster u and j in cluster v.
@@ -402,7 +402,7 @@ def linkage(y, method='single', metric='euclidean'):
* method='weighted' assigns
dist(u,v) = (dist(s,v) + dist(t,v))/2
-
+
where cluster u was formed with cluster s and t and v
is a remaining cluster in the forest. (also called WPGMA)
@@ -422,11 +422,11 @@ def linkage(y, method='single', metric='euclidean'):
the Euclidean distance between the centroid of u and the
centroid of a remaining cluster v in the forest.
(also called UPGMC)
-
+
* method='median' assigns dist(s,t) as above. When two clusters
s and t are combined into a new cluster u, the average of
centroids s and t give the new centroid u. (also called WPGMC)
-
+
* method='ward' uses the Ward variance minimization algorithm.
The new entry dist(u, v) is computed as follows,
@@ -452,7 +452,7 @@ def linkage(y, method='single', metric='euclidean'):
if type(y) != _array_type:
raise TypeError("Argument 'y' must be a numpy array.")
-
+
s = y.shape
if len(s) == 1:
is_valid_y(y, throw=True, name='y')
@@ -517,7 +517,7 @@ def __init__(self, id, left=None, right=None, dist=0, count=1):
def getId(self):
"""
i = nd.getId()
-
+
Returns the id number of the node nd. For 0 <= i < n, i
corresponds to original observation i. For n <= i < 2n - 1,
i corresponds to non-singleton cluster formed at iteration i-n.
@@ -560,24 +560,24 @@ def isLeaf(self):
def preOrder(self, func=(lambda x: x.id)):
"""
vlst = preOrder(func)
-
+
Performs preorder traversal without recursive function calls.
When a leaf node is first encountered, func is called with the
leaf node as its argument, and its result is appended to the
list vlst.
-
+
For example, the statement
-
+
ids = root.preOrder(lambda x: x.id)
-
+
returns a list of the node ids corresponding to the leaf
nodes of the tree as they appear from left to right.
"""
-
+
# Do a preorder traversal, caching the result. To avoid having to do
# recursion, we'll store the previous index we've visited in a vector.
n = self.count
-
+
curNode = [None] * (2 * n)
lvisited = numpy.zeros((2 * n,), dtype='bool')
rvisited = numpy.zeros((2 * n,), dtype='bool')
@@ -603,7 +603,7 @@ def preOrder(self, func=(lambda x: x.id)):
# node already, go up in the tree.
else:
k = k - 1
-
+
return preorder
_cnode_bare = cnode(0)
@@ -612,11 +612,11 @@ def preOrder(self, func=(lambda x: x.id)):
def totree(Z, rd=False):
"""
r = totree(Z)
-
+
Converts a hierarchical clustering encoded in the matrix Z
(by linkage) into an easy-to-use tree object. The reference r
to the root cnode object is returned.
-
+
Each cnode object has a left, right, dist, id, and count
attribute. The left and right attributes point to cnode
objects that were combined to generate the cluster. If
@@ -638,7 +638,7 @@ def totree(Z, rd=False):
"""
is_valid_linkage(Z, throw=True, name='Z')
-
+
# The number of original objects is equal to the number of rows minus
# 1.
n = Z.shape[0] + 1
@@ -690,7 +690,7 @@ def squareform(X, force="no", checks=True):
... = squareform(...)
Converts a vector-form distance vector to a square-form distance
- matrix, and vice-versa.
+ matrix, and vice-versa.
v = squareform(X)
@@ -719,7 +719,7 @@ def squareform(X, force="no", checks=True):
ignored any way so they do not disrupt the squareform
transformation.
"""
-
+
if type(X) is not _array_type:
raise TypeError('The parameter passed must be an array.')
@@ -739,7 +739,7 @@ def squareform(X, force="no", checks=True):
# Check that v is of valid dimensions.
if d * (d - 1) / 2 != int(s[0]):
raise ValueError('Incompatible vector size. It must be a binomial coefficient n choose 2 for some integer n >= 2.')
-
+
# Allocate memory for the distance matrix.
M = numpy.zeros((d, d), 'double')
@@ -766,7 +766,7 @@ def squareform(X, force="no", checks=True):
# One-side of the dimensions is set here.
d = s[0]
-
+
# Create a vector.
v = numpy.zeros(((d * (d - 1) / 2),), 'double')
@@ -785,7 +785,7 @@ def squareform(X, force="no", checks=True):
def minkowski(u, v, p):
"""
d = minkowski(u, v, p)
-
+
Returns the Minkowski distance between two vectors u and v,
||u-v||_p = (\sum {|u_i - v_i|^p})^(1/p).
@@ -797,7 +797,7 @@ def minkowski(u, v, p):
def euclidean(u, v):
"""
d = euclidean(u, v)
-
+
Computes the Euclidean distance between two n-vectors u and v, ||u-v||_2
"""
q=numpy.matrix(u-v)
@@ -825,7 +825,7 @@ def cosine(u, v):
def correlation(u, v):
"""
d = correlation(u, v)
-
+
Computes the correlation distance between two n-vectors u and v,
1 - (u - n|u|_1)(v - n|v|_1)^T
@@ -846,7 +846,7 @@ def correlation(u, v):
def hamming(u, v):
"""
d = hamming(u, v)
-
+
Computes the Hamming distance between two n-vectors u and v,
which is simply the proportion of disagreeing components in u
and v. If u and v are boolean vectors, the hamming distance is
@@ -904,7 +904,7 @@ def kulsinski(u, v):
def seuclidean(u, v, V):
"""
d = seuclidean(u, v, V)
-
+
Returns the standardized Euclidean distance between two
n-vectors u and v. V is a m-dimensional vector of component
variances. It is usually computed among a larger collection vectors.
@@ -925,7 +925,7 @@ def cityblock(u, v):
def mahalanobis(u, v, VI):
"""
d = mahalanobis(u, v, VI)
-
+
Computes the Mahalanobis distance between two n-vectors u and v,
(u-v)VI(u-v)^T
where VI is the inverse covariance matrix.
@@ -937,7 +937,7 @@ def mahalanobis(u, v, VI):
def chebyshev(u, v):
"""
d = chebyshev(u, v)
-
+
Computes the Chebyshev distance between two n-vectors u and v,
\max {|u_i-v_i|}.
"""
@@ -946,7 +946,7 @@ def chebyshev(u, v):
def braycurtis(u, v):
"""
d = braycurtis(u, v)
-
+
Computes the Bray-Curtis distance between two n-vectors u and v,
\sum{|u_i-v_i|} / \sum{|u_i+v_i|}.
"""
@@ -1018,7 +1018,7 @@ def matching(u, v):
def dice(u, v):
"""
d = dice(u, v)
-
+
Computes the Dice dissimilarity between two boolean n-vectors
u and v, which is
@@ -1039,7 +1039,7 @@ def dice(u, v):
def rogerstanimoto(u, v):
"""
d = rogerstanimoto(u, v)
-
+
Computes the Rogers-Tanimoto dissimilarity between two boolean
n-vectors u and v,
@@ -1062,7 +1062,7 @@ def rogerstanimoto(u, v):
def russellrao(u, v):
"""
d = russellrao(u, v)
-
+
Computes the Russell-Rao dissimilarity between two boolean n-vectors
u and v, (n - c_{TT}) / n where c_{ij} is the number of occurrences
of u[k] == i and v[k] == j for k < n.
@@ -1121,7 +1121,7 @@ def sokalsneath(u, v):
def pdist(X, metric='euclidean', p=2, V=None, VI=None):
""" Y = pdist(X, method='euclidean', p=2)
-
+
Computes the distance between m original observations in
n-dimensional space. Returns a condensed distance matrix Y.
For each i and j (i<j), the metric dist(u=X[i], v=X[j]) is
@@ -1163,7 +1163,7 @@ def pdist(X, metric='euclidean', p=2, V=None, VI=None):
6. Y = pdist(X, 'cosine')
Computes the cosine distance between vectors u and v,
-
+
1 - uv^T
-----------
|u|_2 |v|_2
@@ -1270,7 +1270,7 @@ def pdist(X, metric='euclidean', p=2, V=None, VI=None):
boolean vectors. (see sokalsneath function documentation)
21. Y = pdist(X, f)
-
+
Computes the distance between all pairs of vectors in X
using the user supplied 2-arity function f. For example,
Euclidean distance between the vectors could be computed
@@ -1297,7 +1297,7 @@ def pdist(X, metric='euclidean', p=2, V=None, VI=None):
# using the distance metric Y but with a more succint,
# verifiable, but less efficient implementation.
-
+
if type(X) is not _array_type:
raise TypeError('The parameter passed must be an array.')
@@ -1367,7 +1367,7 @@ def pdist(X, metric='euclidean', p=2, V=None, VI=None):
else:
raise TypeError('Invalid input array value type %s for jaccard.' % str(X.dtype))
elif mstr in set(['chebychev', 'chebyshev', 'cheby', 'cheb', 'ch']):
- _hierarchy_wrap.pdist_chebyshev_wrap(X, dm)
+ _hierarchy_wrap.pdist_chebyshev_wrap(X, dm)
elif mstr in set(['minkowski', 'mi', 'm']):
_hierarchy_wrap.pdist_minkowski_wrap(X, dm, p)
elif mstr in set(['seuclidean', 'se', 's']):
@@ -1511,7 +1511,7 @@ def cophenet(*args, **kwargs):
(c, d) = cophenet(Z, Y, [])
Also returns the cophenetic distance matrix in condensed form.
-
+
"""
nargs = len(args)
@@ -1535,7 +1535,7 @@ def cophenet(*args, **kwargs):
Y = args[1]
Ys = Y.shape
is_valid_y(Y, throw=True, name='Y')
-
+
z = zz.mean()
y = Y.mean()
Yy = Y - y
@@ -1555,7 +1555,7 @@ def cophenet(*args, **kwargs):
def inconsistent(Z, d=2):
"""
R = inconsistent(Z, d=2)
-
+
Calculates statistics on links up to d levels below each
non-singleton cluster defined in the (n-1)x4 linkage matrix Z.
@@ -1587,17 +1587,17 @@ def inconsistent(Z, d=2):
_hierarchy_wrap.inconsistent_wrap(Z, R, int(n), int(d));
return R
-
+
def from_mlab_linkage(Z):
"""
Z2 = from_mlab_linkage(Z)
-
+
Converts a linkage matrix Z generated by MATLAB(TM) to a new linkage
matrix Z2 compatible with this module. The conversion does two
things:
* the indices are converted from 1..N to 0..(N-1) form, and
-
+
* a fourth column Z[:,3] is added where Z[i,3] is equal to
the number of original observations (leaves) in the non-singleton
cluster i.
@@ -1625,13 +1625,13 @@ def to_mlab_linkage(Z):
1..N indexing.
"""
is_valid_linkage(Z, throw=True, name='Z')
-
+
return numpy.hstack([Z[:,0:2] + 1, Z[:,2]])
def is_monotonic(Z):
"""
is_monotonic(Z)
-
+
Returns True if the linkage Z is monotonic. The linkage is monotonic
if for every cluster s and t joined, the distance between them is
no less than the distance between any previously joined clusters.
@@ -1644,7 +1644,7 @@ def is_monotonic(Z):
def is_valid_im(R, warning=False, throw=False, name=None):
"""
is_valid_im(R)
-
+
Returns True if the inconsistency matrix passed is valid. It must
be a n by 4 numpy array of doubles. The standard deviations R[:,1]
must be nonnegative. The link counts R[:,2] must be positive and
@@ -1805,7 +1805,7 @@ def is_valid_y(y, warning=False, throw=False, name=None):
def is_valid_dm(D, t=0.0):
"""
is_valid_dm(D)
-
+
Returns True if the variable D passed is a valid distance matrix.
Distance matrices must be 2-dimensional numpy arrays containing
doubles. They must have a zero-diagonal, and they must be symmetric.
@@ -1889,7 +1889,7 @@ def numobs_linkage(Z):
def numobs_dm(D):
"""
numobs_dm(D)
-
+
Returns the number of original observations that correspond to a
square, non-condensed distance matrix D.
"""
@@ -1899,7 +1899,7 @@ def numobs_dm(D):
def numobs_y(Y):
"""
numobs_y(Y)
-
+
Returns the number of original observations that correspond to a
condensed distance matrix Y.
"""
@@ -1910,7 +1910,7 @@ def numobs_y(Y):
def Z_y_correspond(Z, Y):
"""
yesno = Z_y_correspond(Z, Y)
-
+
Returns True if a linkage matrix Z and condensed distance matrix
Y could possibly correspond to one another. They must have the same
number of original observations. This function is useful as a sanity
@@ -1931,7 +1931,7 @@ def fcluster(Z, t, criterion='inconsistent', depth=2, R=None, monocrit=None):
original observation i belongs.
The criterion parameter can be any of the following values,
-
+
* 'inconsistent': If a cluster node and all its decendents have an
inconsistent value less than or equal to c then all its leaf
descendents belong to the same flat cluster. When no non-singleton
@@ -1968,19 +1968,19 @@ def fcluster(Z, t, criterion='inconsistent', depth=2, R=None, monocrit=None):
cluster node c when monocrit[i] <= r for all cluster indices i below
and including c. r is minimized such that no more than t flat clusters
are formed. monocrit must be monotonic.
-
+
For example, to minimize the threshold t on maximum inconsistency
values so that no more than 3 flat clusters are formed, do:
MI = maxinconsts(Z, R)
cluster(Z, t=3, criterion='maxclust_monocrit', monocrit=MI)
-
+
"""
is_valid_linkage(Z, throw=True, name='Z')
n = Z.shape[0] + 1
T = numpy.zeros((n,), dtype='int32')
-
+
# Since the C code does not support striding using strides.
# The dimensions are used instead.
[Z] = _copy_arrays_if_base_present([Z])
@@ -2033,12 +2033,12 @@ def fclusterdata(X, t, criterion='inconsistent', \
specified.
Named parameters are described below.
-
+
criterion: specifies the criterion for forming flat clusters.
Valid values are 'inconsistent', 'distance', or
'maxclust' cluster formation algorithms. See
cluster for descriptions.
-
+
method: the linkage method to use. See linkage for
descriptions.
@@ -2046,7 +2046,7 @@ def fclusterdata(X, t, criterion='inconsistent', \
distances. See pdist for descriptions and
linkage to verify compatibility with the linkage
method.
-
+
t: the cut-off threshold for the cluster function or
the maximum number of clusters (criterion='maxclust').
@@ -2083,15 +2083,15 @@ def lvlist(Z):
_hierarchy_wrap.prelist_wrap(Z, ML, int(n))
return ML
-# Let's do a conditional import. If matplotlib is not available,
+# Let's do a conditional import. If matplotlib is not available,
try:
-
+
import matplotlib
import matplotlib.pylab
import matplotlib.patches
#import matplotlib.collections
_mpl = True
-
+
# Maps number of leaves to text size.
#
# p <= 20, size="12"
@@ -2182,7 +2182,7 @@ def _plot_dendrogram(icoords, dcoords, ivl, p, n, mh, orientation, no_labels, co
if leaf_font_size:
matplotlib.pylab.setp(lbls, 'size', leaf_font_size)
else:
- matplotlib.pylab.setp(lbls, 'size', float(_get_tick_text_size(p)))
+ matplotlib.pylab.setp(lbls, 'size', float(_get_tick_text_size(p)))
axis.xaxis.set_ticks_position('top')
# Make the tick marks invisible because they cover up the links
for line in axis.get_xticklines():
@@ -2272,7 +2272,7 @@ def _plot_dendrogram(icoords, dcoords, ivl, p, n, mh, orientation, no_labels, co
e.set_clip_box(axis.bbox)
e.set_alpha(0.5)
e.set_facecolor('k')
-
+
#matplotlib.pylab.plot(xs, ys, 'go', markeredgecolor='k', markersize=3)
#matplotlib.pylab.plot(ys, xs, 'go', markeredgecolor='k', markersize=3)
@@ -2377,7 +2377,7 @@ def dendrogram(Z, p=30, truncate_mode=None, colorthreshold=None,
* 'top': plots the root at the top, and plot descendent
links going downwards. (default).
-
+
* 'bottom': plots the root at the bottom, and plot descendent
links going upwards.
@@ -2396,7 +2396,7 @@ def dendrogram(Z, p=30, truncate_mode=None, colorthreshold=None,
When labels=None, the index of the original observation is used
used.
-
+
R = dendrogram(..., count_sort)
When plotting a cluster node and its directly descendent links,
@@ -2405,7 +2405,7 @@ def dendrogram(Z, p=30, truncate_mode=None, colorthreshold=None,
of count_sort are:
* False: nothing is done.
-
+
* 'ascending'/True: the child with the minimum number of
original objects in its cluster is plotted first.
@@ -2464,7 +2464,7 @@ def dendrogram(Z, p=30, truncate_mode=None, colorthreshold=None,
When a callable function is passed, leaf_label_func is passed
cluster index k, and returns a string with the label for the
leaf.
-
+
Indices k < n correspond to original observations while indices
k >= n correspond to non-singleton clusters.
@@ -2618,7 +2618,7 @@ def _append_nonsingleton_leaf_node(Z, p, n, level, lvs, ivl, leaf_label_func, i,
if show_leaf_counts:
ivl.append("(" + str(int(Z[i-n, 3])) + ")")
else:
- ivl.append("")
+ ivl.append("")
def _append_contraction_marks(Z, iv, i, n, contraction_marks):
_append_contraction_marks_sub(Z, iv, Z[i-n, 0], n, contraction_marks)
@@ -2629,7 +2629,7 @@ def _append_contraction_marks_sub(Z, iv, i, n, contraction_marks):
contraction_marks.append((iv, Z[i-n, 2]))
_append_contraction_marks_sub(Z, iv, Z[i-n, 0], n, contraction_marks)
_append_contraction_marks_sub(Z, iv, Z[i-n, 1], n, contraction_marks)
-
+
def _dendrogram_calculate_info(Z, p, truncate_mode, \
colorthreshold=scipy.inf, get_leaves=True, \
@@ -2649,7 +2649,7 @@ def _dendrogram_calculate_info(Z, p, truncate_mode, \
variable value to plot the left-most leaf node below the root node i
(if orientation='top', this would be the left-most x value where the
plotting of this root node i and its descendents should begin).
-
+
ivl is a list to store the labels of the leaf nodes. The leaf_label_func
is called whenever ivl != None, labels == None, and
leaf_label_func != None. When ivl != None and labels != None, the
@@ -2668,7 +2668,7 @@ def _dendrogram_calculate_info(Z, p, truncate_mode, \
* left is the independent variable coordinate of the center of the
the U of the subtree
-
+
* w is the amount of space used for the subtree (in independent
variable units)
@@ -2676,7 +2676,7 @@ def _dendrogram_calculate_info(Z, p, truncate_mode, \
* md is the max(Z[*,2]) for all nodes * below and including
the target node.
-
+
"""
if n == 0:
raise ValueError("Invalid singleton cluster count n.")
@@ -2712,7 +2712,7 @@ def _dendrogram_calculate_info(Z, p, truncate_mode, \
elif truncate_mode in ('mlab',):
pass
-
+
# Otherwise, only truncate if we have a leaf node.
#
# If the truncate_mode is mlab, the linkage has been modified
@@ -2900,7 +2900,7 @@ def is_isomorphic(T1, T2):
else:
d[T1[i]] = T2[i]
return True
-
+
def maxdists(Z):
"""
MD = maxdists(Z)
@@ -2910,12 +2910,12 @@ def maxdists(Z):
and including the node with index i. More specifically,
MD[i] = Z[Q(i)-n, 2].max() where Q(i) is the set of all node indices
below and including node i.
-
+
Note that when Z[:,2] is monotonic, Z[:,2] and MD should not differ.
See linkage for more information on this issue.
"""
is_valid_linkage(Z, throw=True, name='Z')
-
+
n = Z.shape[0] + 1
MD = numpy.zeros((n-1,))
[Z] = _copy_arrays_if_base_present([Z])
@@ -2933,7 +2933,7 @@ def maxinconsts(Z, R):
"""
is_valid_linkage(Z, throw=True, name='Z')
is_valid_im(R, throw=True, name='R')
-
+
n = Z.shape[0] + 1
MI = numpy.zeros((n-1,))
[Z, R] = _copy_arrays_if_base_present([Z, R])
@@ -2989,7 +2989,7 @@ def leaders(Z, T):
is_valid_linkage(Z, throw=True, name='Z')
if len(T) != Z.shape[0] + 1:
raise ValueError('Mismatch: len(T)!=Z.shape[0] + 1.')
-
+
Cl = numpy.unique(T)
kk = len(Cl)
L = numpy.zeros((kk,), dtype='int32')
View
6 scipy/cluster/tests/test_hierarchy.py
@@ -368,7 +368,7 @@ def test_pdist_minkowski_random(self):
Y_test1 = pdist(X, 'minkowski', 3.2)
#print "minkowski", numpy.abs(Y_test1 - Y_right).max()
self.failUnless(within_tol(Y_test1, Y_right, eps))
-
+
def test_pdist_minkowski_random_nonC(self):
"Tests pdist(X, 'test_minkowski') [the non-C implementation] on random data."
eps = 1e-05
@@ -388,7 +388,7 @@ def test_pdist_minkowski_iris(self):
Y_test1 = pdist(X, 'minkowski', 3.2)
#print "minkowski-iris-3.2", numpy.abs(Y_test1 - Y_right).max()
self.failUnless(within_tol(Y_test1, Y_right, eps))
-
+
def test_pdist_minkowski_iris_nonC(self):
"Tests pdist(X, 'test_minkowski') [the non-C implementation] on iris data."
eps = 1e-07
@@ -408,7 +408,7 @@ def test_pdist_minkowski_iris(self):
Y_test1 = pdist(X, 'minkowski', 5.8)
#print "minkowski-iris-5.8", numpy.abs(Y_test1 - Y_right).max()
self.failUnless(within_tol(Y_test1, Y_right, eps))
-
+
def test_pdist_minkowski_iris_nonC(self):
"Tests pdist(X, 'test_minkowski') [the non-C implementation] on iris data."
eps = 1e-07
View
2  scipy/fftpack/setupscons.py
@@ -10,7 +10,7 @@ def configuration(parent_package='',top_path=None):
config.add_sconscript('SConstruct')
config.add_data_dir('tests')
-
+
return config
if __name__ == '__main__':
View
26 scipy/integrate/ode.py
@@ -8,7 +8,7 @@
d y(t)[i]
--------- = f(t,y(t))[i],
d t
-
+
y(t=0)[i] = y0[i],
where::
@@ -20,7 +20,7 @@ class ode
A generic interface class to numeric integrators. It has the following
methods::
-
+
integrator = ode(f,jac=None)
integrator = integrator.set_integrator(name,**params)
integrator = integrator.set_initial_value(y0,t0=0.0)
@@ -108,22 +108,22 @@ class ode
# To wrap cvode to Python, one must write extension module by
# hand. Its interface is too much 'advanced C' that using f2py
# would be too complicated (or impossible).
-#
+#
# How to define a new integrator:
# ===============================
-#
+#
# class myodeint(IntegratorBase):
-#
+#
# runner = <odeint function> or None
-#
+#
# def __init__(self,...): # required
# <initialize>
-#
+#
# def reset(self,n,has_jac): # optional
# # n - the size of the problem (number of equations)
# # has_jac - whether user has supplied its own routine for Jacobian
# <allocate memory,initialize further>
-#
+#
# def run(self,f,jac,y0,t0,t1,f_params,jac_params): # required
# # this method is called to integrate from t=t0 to t=t1
# # with initial condition y0. f and jac are user-supplied functions
@@ -134,11 +134,11 @@ class ode
# if <calculation was unsuccesful>:
# self.success = 0
# return t1,y1
-#
+#
# # In addition, one can define step() and run_relax() methods (they
# # take the same arguments as run()) if the integrator can support
# # these features (see IntegratorBase doc strings).
-#
+#
# if myodeint.runner:
# IntegratorBase.integrator_classes.append(myodeint)
@@ -158,7 +158,7 @@ class ode(object):
A generic interface class to numeric integrators.
See also
---------
+--------
odeint : an integrator with a simpler interface based on lsoda from ODEPACK
quad : for finding the area under a curve
@@ -533,7 +533,7 @@ def reset(self, n, has_jac):
rwork[5] = self.max_step
rwork[6] = self.min_step
self.rwork = rwork
-
+
iwork = zeros((liw,), int32)
if self.ml is not None:
iwork[0] = self.ml
@@ -543,7 +543,7 @@ def reset(self, n, has_jac):
iwork[5] = self.nsteps
iwork[6] = 2 # mxhnil
self.iwork = iwork
-
+
self.call_args = [self.rtol,self.atol,1,1,
self.zwork,self.rwork,self.iwork,mf]
self.success = 1
View
2  scipy/integrate/tests/test_integrate.py
@@ -35,7 +35,7 @@ class TestOde(TestCase):
Check integrate.ode
"""
def _do_problem(self, problem, integrator, method='adams'):
-
+
# ode has callback arguments in different order than odeint
f = lambda t, z: problem.f(z, t)
jac = None
View
10 scipy/io/__init__.py
@@ -16,17 +16,17 @@
convert_objectarray
fread = deprecate_with_doc("""
-scipy.io.fread is can be replaced with raw reading capabilities of NumPy
-including fromfile as well as memory-mapping capabilities.
+scipy.io.fread is can be replaced with raw reading capabilities of NumPy
+including fromfile as well as memory-mapping capabilities.
""")(fread)
fwrite = deprecate_with_doc("""
scipy.io.fwrite can be replaced with raw writing capabilities of
NumPy. Also, remember that files can be directly memory-mapped into NumPy
-arrays which is often a better way of reading especially large files.
+arrays which is often a better way of reading especially large files.
Look at the tofile methods as well as save and savez for writing arrays into
-easily transported files of data.
+easily transported files of data.
""")(fwrite)
bswap = deprecate_with_doc("""
@@ -54,7 +54,7 @@ def scipy_packbits(inp):
unpackbits = deprecate_with_doc("""
The functionality of scipy.io.unpackbits is now available in numpy.unpackbits
The calling convention is different however as the 2-d case is no longer
-specialized.
+specialized.
Thus, the scipy.unpackbits behavior must be simulated using numpy.unpackbits.
View
44 scipy/io/arff/arffread.py
@@ -12,7 +12,7 @@
__all__ = ['MetaData', 'loadarff', 'ArffError', 'ParseArffError']
-# An Arff file is basically two parts:
+# An Arff file is basically two parts:
# - header
# - data
#
@@ -42,7 +42,7 @@
r_comattrval = re.compile(r"'(..+)'\s+(..+$)")
# To get attributes name enclosed with '', possibly spread accross multilines
r_mcomattrval = re.compile(r"'([..\n]+)'\s+(..+$)")
-# To get normal attributes
+# To get normal attributes
r_wcomattrval = re.compile(r"(\S+)\s+(..+$)")
#-------------------------
@@ -61,7 +61,7 @@ class ParseArffError(ArffError):
# An attribute is defined as @attribute name value
def parse_type(attrtype):
"""Given an arff attribute value (meta data), returns its type.
-
+
Expect the value to be a name."""
uattribute = attrtype.lower().strip()
if uattribute[0] == '{':
@@ -83,7 +83,7 @@ def parse_type(attrtype):
def get_nominal(attribute):
"""If attribute is nominal, returns a list of the values"""
return attribute.split(',')
-
+
def read_data_list(ofile):
"""Read each line of the iterable and put it in a list."""
data = [ofile.next()]
@@ -105,9 +105,9 @@ def get_ndata(ofile):
def maxnomlen(atrv):
"""Given a string contening a nominal type definition, returns the string
len of the biggest component.
-
+
A nominal type is defined as seomthing framed between brace ({}).
-
+
Example: maxnomlen("{floup, bouga, fl, ratata}") returns 6 (the size of
ratata, the longest nominal value)."""
nomtp = get_nom_val(atrv)
@@ -115,10 +115,10 @@ def maxnomlen(atrv):
def get_nom_val(atrv):
"""Given a string contening a nominal type, returns a tuple of the possible
- values.
-
+ values.
+
A nominal type is defined as something framed between brace ({}).
-
+
Example: get_nom_val("{floup, bouga, fl, ratata}") returns ("floup",
"bouga", "fl", "ratata")."""
r_nominal = re.compile('{(..+)}')
@@ -130,7 +130,7 @@ def get_nom_val(atrv):
def go_data(ofile):
"""Skip header.
-
+
the first next() call of the returned iterator will be the @data line"""
return itertools.dropwhile(lambda x : not r_datameta.match(x), ofile)
@@ -139,18 +139,18 @@ def go_data(ofile):
#----------------
def tokenize_attribute(iterable, attribute):
"""Parse a raw string in header (eg starts by @attribute).
-
+
Given a raw string attribute, try to get the name and type of the
attribute. Constraints:
- The first line must start with @attribute (case insensitive, and
space like characters begore @attribute are allowed)
- - Works also if the attribute is spread on multilines.
+ - Works also if the attribute is spread on multilines.
- Works if empty lines or comments are in between
-
+
:Parameters:
attribute : str
- the attribute string.
-
+ the attribute string.
+
:Returns:
name : str
name of the attribute
@@ -205,7 +205,7 @@ def tokenize_multilines(iterable, val):
else:
raise ValueError("Cannot parse attribute names spread over multi "\
"lines yet")
-
+
def tokenize_single_comma(val):
# XXX we match twice the same string (here and at the caller level). It is
# stupid, but it is easier for now...
@@ -299,7 +299,7 @@ def get_delim(line):
class MetaData:
"""Small container to keep useful informations on a ARFF dataset.
-
+
Knows about attributes names and types.
:Example:
@@ -318,7 +318,7 @@ class MetaData:
Also maintains the list of attributes in order, i.e. doing for i in
meta, where meta is an instance of MetaData, will return the different
attribute names in the order they were defined.
-
+
"""
def __init__(self, rel, attr):
self.name = rel
@@ -343,7 +343,7 @@ def __repr__(self):
msg += ", range is %s" % str(self._attributes[i][1])
msg += '\n'
return msg
-
+
def __iter__(self):
return iter(self._attrnames)
@@ -386,7 +386,7 @@ def loadarff(filename):
"""
ofile = open(filename)
- # Parse the header file
+ # Parse the header file
try:
rel, attr = read_header(ofile)
except ValueError, e:
@@ -459,9 +459,9 @@ def next_data_line(row_iter):
def generator(row_iter, delim = ','):
# TODO: this is where we are spending times (~80%). I think things
- # could be made more efficiently:
+ # could be made more efficiently:
# - We could for example "compile" the function, because some values
- # do not change here.
+ # do not change here.
# - The function to convert a line to dtyped values could also be
# generated on the fly from a string and be executed instead of
# looping.
View
4 scipy/io/arff/tests/test_data.py
@@ -11,8 +11,8 @@
test4 = os.path.join(data_path, 'test4.arff')
test5 = os.path.join(data_path, 'test5.arff')
-expect4_data = [(0.1, 0.2, 0.3, 0.4, 'class1'),
- (-0.1, -0.2, -0.3, -0.4, 'class2'),
+expect4_data = [(0.1, 0.2, 0.3, 0.4, 'class1'),
+ (-0.1, -0.2, -0.3, -0.4, 'class2'),
(1, 2, 3, 4, 'class3')]
missing = os.path.join(data_path, 'missing.arff')
View
2  scipy/io/data_store.py
@@ -15,7 +15,7 @@
1
"""
-__all__ = ['save_as_module',
+__all__ = ['save_as_module',
# The rest of these are all deprecated
'save', 'create_module',
'create_shelf', 'load']
View
4 scipy/io/matlab/mio4.py
@@ -168,13 +168,13 @@ def get_raw_array(self):
dims = res[-1,0:2]
I = N.ascontiguousarray(tmp[:,0],dtype='intc') #fixes byte order also
J = N.ascontiguousarray(tmp[:,1],dtype='intc')
- I -= 1 # for 1-based indexing
+ I -= 1 # for 1-based indexing
J -= 1
if res.shape[1] == 3:
V = N.ascontiguousarray(tmp[:,2],dtype='float')
else:
V = N.ascontiguousarray(tmp[:,2],dtype='complex')
- V.imag = tmp[:,3]
+ V.imag = tmp[:,3]
if have_sparse:
return scipy.sparse.coo_matrix((V,(I,J)), dims)
return (dims, I, J, V)
View
2  scipy/io/matlab/tests/test_mio.py
@@ -238,5 +238,3 @@ def test_round_trip():
expected = case['expected']
format = case in case_table4 and '4' or '5'
yield _make_rt_check_case, name, expected, format
-
-
View
12 scipy/io/mmio.py
@@ -124,7 +124,7 @@ def _validate_field(self, field):
SYMMETRY_SYMMETRIC = 'symmetric'
SYMMETRY_SKEW_SYMMETRIC = 'skew-symmetric'
SYMMETRY_HERMITIAN = 'hermitian'
- SYMMETRY_VALUES = ( SYMMETRY_GENERAL, SYMMETRY_SYMMETRIC,
+ SYMMETRY_VALUES = ( SYMMETRY_GENERAL, SYMMETRY_SYMMETRIC,
SYMMETRY_SKEW_SYMMETRIC, SYMMETRY_HERMITIAN)
@classmethod
@@ -217,7 +217,7 @@ def _open(filespec, mode='r'):
stream = bz2.BZ2File(filespec, 'r')
else:
stream = open(filespec, mode)
-
+
# open for writing
else:
if filespec[-4:] != '.mtx':
@@ -257,7 +257,7 @@ def _get_symmetry(a):
@staticmethod
def _field_template(field, precision):
return {
- MMFile.FIELD_REAL: '%%.%ie\n' % precision,
+ MMFile.FIELD_REAL: '%%.%ie\n' % precision,
MMFile.FIELD_INTEGER: '%i\n',
MMFile.FIELD_COMPLEX: '%%.%ie %%.%ie\n' % (precision,precision)
}.get(field, None)
@@ -296,7 +296,7 @@ def _init_attrs(self, **kwargs):
attrs = self.__class__.__slots__
public_attrs = [attr[1:] for attr in attrs]
invalid_keys = set(kwargs.keys()) - set(public_attrs)
-
+
if invalid_keys:
raise ValueError, \
'found %s invalid keyword arguments, please only use %s' % \
@@ -395,10 +395,10 @@ def _parse_body(self, stream):
except:
# fallback - fromfile fails for some file-like objects
flat_data = fromstring(stream.read(), sep=' ')
-
+
# TODO use iterator (e.g. xreadlines) to avoid reading
# the whole file into memory
-
+
if is_pattern:
flat_data = flat_data.reshape(-1,2)
I = ascontiguousarray(flat_data[:,0], dtype='intc')
View
4 scipy/io/npfile.py
@@ -225,8 +225,8 @@ def read_array(self, dt, shape=-1, endian=None, order=None):
npfile = N.deprecate_with_doc("""
You can achieve the same effect as using npfile, using ndarray.tofile
-and numpy.fromfile.
+and numpy.fromfile.
-Even better you can use memory-mapped arrays and data-types to map out a
+Even better you can use memory-mapped arrays and data-types to map out a
file format for direct manipulation in NumPy.
""")(npfile)
View
2  scipy/io/pickler.py
@@ -25,7 +25,7 @@ def objsave(file, allglobals, *args):
fid.close()
@deprecate_with_doc("""
-Just use cPickle.load or numpy.load.
+Just use cPickle.load or numpy.load.
""")
def objload(file, allglobals):
"""Load a previously pickled dictionary and insert into given dictionary.
View
46 scipy/io/tests/test_mmio.py
@@ -150,37 +150,37 @@ def test_random_rect_real(self):
_skew_example = '''\
%%MatrixMarket matrix coordinate real skew-symmetric
5 5 7
- 1 1 1.0
- 2 2 10.5
- 4 2 250.5
- 3 3 1.5e-2
- 4 4 -2.8e2
- 5 5 12.
- 5 4 0
+ 1 1 1.0
+ 2 2 10.5
+ 4 2 250.5
+ 3 3 1.5e-2
+ 4 4 -2.8e2
+ 5 5 12.
+ 5 4 0
'''
_symmetric_example = '''\
%%MatrixMarket matrix coordinate real symmetric
5 5 7
- 1 1 1.0
- 2 2 10.5
- 4 2 250.5
- 3 3 1.5e-2
- 4 4 -2.8e2
- 5 5 12.
- 5 4 8
+ 1 1 1.0
+ 2 2 10.5
+ 4 2 250.5
+ 3 3 1.5e-2
+ 4 4 -2.8e2
+ 5 5 12.
+ 5 4 8
'''
_symmetric_pattern_example = '''\
%%MatrixMarket matrix coordinate pattern symmetric
5 5 7
- 1 1
- 2 2
- 4 2
- 3 3
- 4 4
- 5 5
- 5 4
+ 1 1
+ 2 2
+ 4 2
+ 3 3
+ 4 4
+ 5 5
+ 5 4
'''
class TestMMIOCoordinate(TestCase):
@@ -213,7 +213,7 @@ def test_read_hermitian(self):
[0, 0, 0, 33.32j, 12]]
b = mmread(fn).todense()
assert_array_almost_equal(a,b)
-
+
def test_read_skew(self):
"""read a skew-symmetric matrix"""
fn = mktemp()
@@ -228,7 +228,7 @@ def test_read_skew(self):
[0, 0, 0, 0, 12]]
b = mmread(fn).todense()
assert_array_almost_equal(a,b)
-
+
def test_read_symmetric(self):
"""read a symmetric matrix"""
fn = mktemp()
View
3  scipy/io/tests/test_recaster.py
@@ -171,7 +171,6 @@ def run_io_recasts(self, R, inp_outp):
dtt = arr.dtype.type
assert dtt is outp, \
'Expected %s from %s, got %s' % (outp, inp, dtt)
-
+
if __name__ == "__main__":
nose.run(argv=['', __file__])
-
View
3  scipy/lib/blas/scons_support.py
@@ -15,7 +15,7 @@ def do_generate_fake_interface(target, source, env):
# XXX handle skip names
name = splitext(pbasename(target_name))[0]
#generate_interface(name, source_name, target_name)
-
+
f = open(target_name, 'w')
f.write('python module '+name+'\n')
f.write('usercode void empty_module(void) {}\n')
@@ -27,4 +27,3 @@ def do_generate_fake_interface(target, source, env):
f.close()
return 0
-
View
3  scipy/lib/lapack/scons_support.py
@@ -15,7 +15,7 @@ def do_generate_fake_interface(target, source, env):
# XXX handle skip names
name = splitext(pbasename(target_name))[0]
#generate_interface(name, source_name, target_name)
-
+
f = open(target_name, 'w')
f.write('python module '+name+'\n')
f.write('usercode void empty_module(void) {}\n')
@@ -27,4 +27,3 @@ def do_generate_fake_interface(target, source, env):
f.close()
return 0
-
View
3  scipy/lib/lapack/tests/test_lapack.py
@@ -11,7 +11,7 @@
method names. There are no subclasses of TestCase. Thus nose will
pick up nothing but the final test_all_lapack generator function.
This does the work of collecting the test methods and checking if they
-can be run (see the isrunnable method).
+can be run (see the isrunnable method).
'''
import os
@@ -137,4 +137,3 @@ def test_all_lapack():
methods += [getattr(o, n) for n in dir(o) if o.isrunnable(n) is True]
for method in methods:
yield (method, )
-
View
2  scipy/lib/setupscons.py
@@ -3,7 +3,7 @@
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
- config = Configuration('lib',parent_package,top_path,
+ config = Configuration('lib',parent_package,top_path,
setup_name = 'setupscons.py')
config.add_subpackage('blas')
config.add_subpackage('lapack')
View
118 scipy/linalg/basic.py
@@ -26,7 +26,7 @@
def lu_solve((lu, piv), b, trans=0, overwrite_b=0):
"""Solve an equation system, a x = b, given the LU factorization of a
-
+
Parameters
----------
(lu, piv)
@@ -52,7 +52,7 @@ def lu_solve((lu, piv), b, trans=0, overwrite_b=0):
See also
--------
lu_factor : LU factorize a matrix
-
+
"""
b1 = asarray_chkfinite(b)
overwrite_b = overwrite_b or (b1 is not b and not hasattr(b,'__array__'))
@@ -83,7 +83,7 @@ def cho_solve((c, lower), b, overwrite_b=0):
See also
--------
cho_factor : Cholesky factorization of a matrix
-
+
"""
b1 = asarray_chkfinite(b)
overwrite_b = overwrite_b or (b1 is not b and not hasattr(b,'__array__'))
@@ -114,14 +114,14 @@ def solve(a, b, sym_pos=0, lower=0, overwrite_a=0, overwrite_b=0,
Allow overwriting data in a (may enhance performance)
overwrite_b : boolean
Allow overwriting data in b (may enhance performance)
-
+
Returns
-------
x : array, shape (M,) or (M, N) depending on b
Solution to the system a x = b
Raises LinAlgError if a is singular
-
+
"""
a1, b1 = map(asarray_chkfinite,(a,b))
if len(a1.shape) != 2 or a1.shape[0] != a1.shape[1]:
@@ -164,8 +164,8 @@ def solve_banded((l,u), ab, b, overwrite_ab=0, overwrite_b=0,
* a01 a12 a23 a34 a45
a00 a11 a22 a33 a44 a55
- a10 a21 a32 a43 a54 *
- a20 a31 a42 a53 * *
+ a10 a21 a32 a43 a54 *
+ a20 a31 a42 a53 * *
Parameters
----------
@@ -184,7 +184,7 @@ def solve_banded((l,u), ab, b, overwrite_ab=0, overwrite_b=0,
-------
x : array, shape (M,) or (M, K)
The solution to the system a x = b
-
+
"""
a1, b1 = map(asarray_chkfinite,(ab,b))
overwrite_b = overwrite_b or (b1 is not b and not hasattr(b,'__array__'))
@@ -218,7 +218,7 @@ def solveh_banded(ab, b, overwrite_ab=0, overwrite_b=0,
* * a02 a13 a24 a35
* a01 a12 a23 a34 a45
a00 a11 a22 a33 a44 a55
-
+
lower form:
a00 a11 a22 a33 a44 a55
a10 a21 a32 a43 a54 *
@@ -245,7 +245,7 @@ def solveh_banded(ab, b, overwrite_ab=0, overwrite_b=0,
Cholesky factorization of a, in the same banded format as ab
x : array, shape (M,) or (M, K)
The solution to the system a x = b
-
+
"""
ab, b = map(asarray_chkfinite,(ab,b))
@@ -263,25 +263,25 @@ def solveh_banded(ab, b, overwrite_ab=0, overwrite_b=0,
def cholesky_banded(ab, overwrite_ab=0, lower=0):
"""Cholesky decompose a banded Hermitian positive-definite matrix
-
+
The matrix a is stored in ab either in lower diagonal or upper
diagonal ordered form:
-
+
ab[u + i - j, j] == a[i,j] (if upper form; i <= j)
ab[ i - j, j] == a[i,j] (if lower form; i >= j)
-
+
Example of ab (shape of a is (6,6), u=2)::
-
+
upper form:
* * a02 a13 a24 a35
* a01 a12 a23 a34 a45
a00 a11 a22 a33 a44 a55
-
+
lower form:
a00 a11 a22 a33 a44 a55
a10 a21 a32 a43 a54 *
a20 a31 a42 a53 * *
-
+
Parameters
----------
ab : array, shape (M, u + 1)
@@ -290,12 +290,12 @@ def cholesky_banded(ab, overwrite_ab=0, lower=0):
Discard data in ab (may enhance performance)
lower : boolean
Is the matrix in the lower form. (Default is upper form)
-
+
Returns
-------
c : array, shape (M, u+1)
Cholesky factorization of a, in the same banded format as ab
-
+
"""
ab = asarray_chkfinite(ab)
@@ -315,12 +315,12 @@ def cholesky_banded(ab, overwrite_ab=0, lower=0):
# matrix inversion
def inv(a, overwrite_a=0):
"""Compute the inverse of a matrix.
-
+
Parameters
----------
a : array-like, shape (M, M)
Matrix to be inverted
-
+
Returns
-------
ainv : array-like, shape (M, M)
@@ -409,7 +409,7 @@ def norm(x, ord=None):
-2 smallest singular value as below
other - sum(abs(x)**ord)**(1./ord)
===== ============================ ==========================
-
+
Returns
-------
n : float
@@ -420,7 +420,7 @@ def norm(x, ord=None):
For values ord < 0, the result is, strictly speaking, not a
mathematical 'norm', but it may still be useful for numerical
purposes.
-
+
"""
x = asarray_chkfinite(x)
if ord is None: # check the default case first and handle it immediately
@@ -472,7 +472,7 @@ def det(a, overwrite_a=0):
-------
det : float or complex
Determinant of a
-
+
Notes
-----
The determinant is computed via LU factorization, LAPACK routine z/dgetrf.
@@ -491,9 +491,9 @@ def det(a, overwrite_a=0):
def lstsq(a, b, cond=None, overwrite_a=0, overwrite_b=0):
"""Compute least-squares solution to equation :m:`a x = b`
-
+
Compute a vector x such that the 2-norm :m:`|b - a x|` is minimised.
-
+
Parameters
----------
a : array, shape (M, N)
@@ -506,7 +506,7 @@ def lstsq(a, b, cond=None, overwrite_a=0, overwrite_b=0):
Discard data in a (may enhance performance)
overwrite_b : boolean
Discard data in b (may enhance performance)
-
+
Returns
-------
x : array, shape (N,) or (N, K) depending on shape of b
@@ -519,9 +519,9 @@ def lstsq(a, b, cond=None, overwrite_a=0, overwrite_b=0):
Effective rank of matrix a
s : array, shape (min(M,N),)
Singular values of a. The condition number of a is abs(s[0]/s[-1]).
-
+
Raises LinAlgError if computation does not converge
-
+
"""
a1, b1 = map(asarray_chkfinite,(a,b))
if len(a1.shape) != 2:
@@ -562,10 +562,10 @@ def lstsq(a, b, cond=None, overwrite_a=0, overwrite_b=0):
def pinv(a, cond=None, rcond=None):
"""Compute the (Moore-Penrose) pseudo-inverse of a matrix.
-
+
Calculate a generalized inverse of a matrix using a least-squares
solver.
-
+
Parameters
----------
a : array, shape (M, N)
@@ -574,11 +574,11 @@ def pinv(a, cond=None, rcond=None):
Cutoff for 'small' singular values in the least-squares solver.
Singular values smaller than rcond*largest_singular_value are
considered zero.
-
+
Returns
-------
B : array, shape (N, M)
-
+
Raises LinAlgError if computation does not converge
Examples
@@ -590,7 +590,7 @@ def pinv(a, cond=None, rcond=None):
True
>>> allclose(B, dot(B, dot(a, B)))
True
-
+
"""
a = asarray_chkfinite(a)
b = numpy.identity(a.shape[0], dtype=a.dtype)
@@ -605,11 +605,11 @@ def pinv(a, cond=None, rcond=None):
_array_precision = {'f': 0, 'd': 1, 'F': 0, 'D': 1}
def pinv2(a, cond=None, rcond=None):
"""Compute the (Moore-Penrose) pseudo-inverse of a matrix.
-
+
Calculate a generalized inverse of a matrix using its
singular-value decomposition and including all 'large' singular
values.
-
+
Parameters
----------
a : array, shape (M, N)
@@ -620,11 +620,11 @@ def pinv2(a, cond=None, rcond=None):
considered zero.
If None or -1, suitable machine precision is used.
-
+
Returns
-------
B : array, shape (N, M)
-
+
Raises LinAlgError if SVD computation does not converge
Examples
@@ -636,7 +636,7 @@ def pinv2(a, cond=None, rcond=None):
True
>>> allclose(B, dot(B, dot(a, B)))
True
-
+
"""
a = asarray_chkfinite(a)
u, s, vh = decomp.svd(a)
@@ -689,7 +689,7 @@ def tri(N, M=None, k=0, dtype=None):
array([[0, 0, 0, 0, 0],
[1, 0, 0, 0, 0],
[1, 1, 0, 0, 0]])
-
+
"""
if M is None: M = N
if type(M) == type('d'):
@@ -705,7 +705,7 @@ def tri(N, M=None, k=0, dtype=None):
def tril(m, k=0):
"""Construct a copy of a matrix with elements above the k-th diagonal zeroed.
-
+
Parameters
----------
m : array
@@ -717,7 +717,7 @@ def tril(m, k=0):
Returns
-------
A : array, shape m.shape, dtype m.dtype
-
+
Examples
--------
>>> from scipy.linalg import tril
@@ -726,7 +726,7 @@ def tril(m, k=0):
[ 4, 0, 0],
[ 7, 8, 0],
[10, 11, 12]])
-
+
"""
svsp = getattr(m,'spacesaver',lambda:0)()
m = asarray(m)
@@ -736,7 +736,7 @@ def tril(m, k=0):
def triu(m, k=0):
"""Construct a copy of a matrix with elements below the k-th diagonal zeroed.
-
+
Parameters
----------
m : array
@@ -748,7 +748,7 @@ def triu(m, k=0):
Returns
-------
A : array, shape m.shape, dtype m.dtype
-
+
Examples
--------
>>> from scipy.linalg import tril
@@ -757,7 +757,7 @@ def triu(m, k=0):
[ 4, 5, 6],
[ 0, 8, 9],
[ 0, 0, 12]])
-
+
"""
svsp = getattr(m,'spacesaver',lambda:0)()
m = asarray(m)
@@ -767,23 +767,23 @@ def triu(m, k=0):
def toeplitz(c,r=None):
"""Construct a Toeplitz matrix.
-
+
The Toepliz matrix has constant diagonals, c as its first column,
and r as its first row (if not given, r == c is assumed).
-
+
Parameters
----------
c : array
First column of the matrix
r : array
First row of the matrix. If None, r == c is assumed.
-
+
Returns
-------
A : array, shape (len(c), len(r))
Constructed Toeplitz matrix.
dtype is the same as (c[0] + r[0]).dtype
-
+
Examples
--------
>>> from scipy.linalg import toeplitz
@@ -791,11 +791,11 @@ def toeplitz(c,r=None):
array([[1, 4, 5, 6],
[2, 1, 4, 5],
[3, 2, 1, 4]])
-
+
See also
--------
hankel : Hankel matrix
-
+
"""
isscalar = numpy.isscalar
if isscalar(c) or isscalar(r):
@@ -819,23 +819,23 @@ def toeplitz(c,r=None):
def hankel(c,r=None):
"""Construct a Hankel matrix.
-
+
The Hankel matrix has constant anti-diagonals, c as its first column,
and r as its last row (if not given, r == 0 os assumed).
-
+
Parameters
----------
c : array
First column of the matrix
r : array
Last row of the matrix. If None, r == 0 is assumed.
-
+
Returns
-------
A : array, shape (len(c), len(r))
Constructed Hankel matrix.
dtype is the same as (c[0] + r[0]).dtype
-
+
Examples
--------
>>> from scipy.linalg import hankel
@@ -844,11 +844,11 @@ def hankel(c,r=None):
[2, 3, 4, 7, 7],
[3, 4, 7, 7, 8],
[4, 7, 7, 8, 9]])
-
+
See also
--------
toeplitz : Toeplitz matrix
-
+
"""
isscalar = numpy.isscalar
if isscalar(c) or isscalar(r):
@@ -889,14 +889,14 @@ def kron(a,b):
-------
A : array, shape (M*P, N*Q)
Kronecker product of a and b
-
+
Examples
--------
>>> from scipy import kron, array
>>> kron(array([[1,2],[3,4]]), array([[1,1,1]]))
array([[1, 1, 1, 2, 2, 2],
[3, 3, 3, 4, 4, 4]])
-
+
"""
if not a.flags['CONTIGUOUS']:
a = reshape(a, a.shape)
View
9 scipy/linalg/benchmarks/bench_decom.py
@@ -20,16 +20,15 @@ def bench_random():
print ' | contiguous '#'| non-contiguous '
print '----------------------------------------------'
print ' size | scipy '#'| core | scipy | core '
-
+
for size,repeat in [(20,150),(100,7),(200,2)]:
repeat *= 1
print '%5s' % size,
sys.stdout.flush()
-
+
a = random([size,size])
-
+
print '| %6.2f ' % measure('eigvals(a)',repeat),
sys.stdout.flush()
-
- print ' (secs for %s calls)' % (repeat)
+ print ' (secs for %s calls)' % (repeat)
View
2  scipy/linalg/blas.py
@@ -29,7 +29,7 @@ def get_blas_funcs(names,arrays=(),debug=0):
"""Return available BLAS function objects with names.
arrays are used to determine the optimal prefix of
BLAS routines.
-
+
"""
ordering = []
for i in range(len(arrays)):
View
178 scipy/linalg/decomp.py
@@ -101,12 +101,12 @@ def eig(a,b=None, left=False, right=True, overwrite_a=False, overwrite_b=False):
"""Solve an ordinary or generalized eigenvalue problem of a square matrix.
Find eigenvalues w and right or left eigenvectors of a general matrix::
-
+
a vr[:,i] = w[i] b vr[:,i]
a.H vl[:,i] = w[i].conj() b.H vl[:,i]
-
+
where .H is the Hermitean conjugation.
-
+
Parameters
----------
a : array, shape (M, M)
@@ -119,12 +119,12 @@ def eig(a,b=None, left=False, right=True, overwrite_a=False, overwrite_b=False):
Whether to calculate and return left eigenvectors
right : boolean
Whether to calculate and return right eigenvectors
-
+
overwrite_a : boolean
Whether to overwrite data in a (may improve performance)
overwrite_b : boolean
Whether to overwrite data in b (may improve performance)
-
+
Returns
-------
w : double or complex array, shape (M,)
@@ -134,18 +134,18 @@ def eig(a,b=None, left=False, right=True, overwrite_a=False, overwrite_b=False):
vl : double or complex array, shape (M, M)
The normalized left eigenvector corresponding to the eigenvalue w[i]
is the column v[:,i].
-
+
(if right == True)
vr : double or complex array, shape (M, M)
The normalized right eigenvector corresponding to the eigenvalue w[i]
is the column vr[:,i].
-
+
Raises LinAlgError if eigenvalue computation does not converge
See Also
--------
eigh : eigenvalues and right eigenvectors for symmetric/Hermitian arrays
-
+
"""
a1 = asarray_chkfinite(a)
if len(a1.shape) != 2 or a1.shape[0] != a1.shape[1]:
@@ -207,10 +207,10 @@ def eigh(a, lower=True, eigvals_only=False, overwrite_a=False):
"""Solve the eigenvalue problem for a Hermitian or real symmetric matrix.
Find eigenvalues w and optionally right eigenvectors v of a::
-