Skip to content

Commit

Permalink
ran reindent before tagging later tonight
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodmillman committed Nov 24, 2008
1 parent 399b092 commit 2cf4a79
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 54 deletions.
2 changes: 1 addition & 1 deletion doc/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def process_html(fn, lines):
def process_tex(lines):
"""
Remove unnecessary section titles from the LaTeX file.
"""
new_lines = []
for line in lines:
Expand Down
4 changes: 2 additions & 2 deletions scipy/cluster/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,9 @@ def inconsistent(Z, d=2):
deviation of the link heights, respectively; ``R[i,2]`` is
the number of links included in the calculation; and
``R[i,3]`` is the inconsistency coefficient,
.. math::
\frac{\mathtt{Z[i,2]}-\mathtt{R[i,0]}}
{R[i,1]}.
"""
Expand Down
22 changes: 11 additions & 11 deletions scipy/linalg/decomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def eig(a,b=None, left=False, right=True, overwrite_a=False, overwrite_b=False):
def eigh(a, b=None, lower=True, eigvals_only=False, overwrite_a=False,
overwrite_b=False, turbo=True, eigvals=None, type=1):
"""Solve an ordinary or generalized eigenvalue problem for a complex
Hermitian or real symmetric matrix.
Hermitian or real symmetric matrix.
Find eigenvalues w and optionally eigenvectors v of matrix a, where
b is positive definite::
Expand Down Expand Up @@ -262,8 +262,8 @@ def eigh(a, b=None, lower=True, eigvals_only=False, overwrite_a=False,
type 2: inv(v).conj() a inv(v) = w
type = 1 or 2: v.conj() b v = I
type = 3 : v.conj() inv(b) v = I
Raises LinAlgError if eigenvalue computation does not converge,
Raises LinAlgError if eigenvalue computation does not converge,
an error occurred, or b matrix is not definite positive. Note that
if input matrices are not symmetric or hermitian, no error is reported
but results will be wrong.
Expand Down Expand Up @@ -296,7 +296,7 @@ def eigh(a, b=None, lower=True, eigvals_only=False, overwrite_a=False,
cplx = cplx or False
else:
b1 = None

# Set job for fortran routines
_job = (eigvals_only and 'N') or 'V'

Expand All @@ -321,17 +321,17 @@ def eigh(a, b=None, lower=True, eigvals_only=False, overwrite_a=False,
pfx = 'he'
else:
pfx = 'sy'

# Standard Eigenvalue Problem
# Use '*evr' routines
# FIXME: implement calculation of optimal lwork
# for all lapack routines
if b1 is None:
(evr,) = get_lapack_funcs((pfx+'evr',), (a1,))
if eigvals is None:
if eigvals is None:
w, v, info = evr(a1, uplo=uplo, jobz=_job, range="A", il=1,
iu=a1.shape[0], overwrite_a=overwrite_a)
else:
else:
(lo, hi)= eigvals
w_tot, v, info = evr(a1, uplo=uplo, jobz=_job, range="I",
il=lo, iu=hi, overwrite_a=overwrite_a)
Expand Down Expand Up @@ -367,7 +367,7 @@ def eigh(a, b=None, lower=True, eigvals_only=False, overwrite_a=False,
return w
else:
return w, v

elif info < 0:
raise LinAlgError("illegal value in %i-th argument of internal"
" fortran routine." % (-info))
Expand Down Expand Up @@ -579,7 +579,7 @@ def eigvals(a,b=None,overwrite_a=0):
def eigvalsh(a, b=None, lower=True, overwrite_a=False,
overwrite_b=False, turbo=True, eigvals=None, type=1):
"""Solve an ordinary or generalized eigenvalue problem for a complex
Hermitian or real symmetric matrix.
Hermitian or real symmetric matrix.
Find eigenvalues w of matrix a, where b is positive definite::
Expand Down Expand Up @@ -622,7 +622,7 @@ def eigvalsh(a, b=None, lower=True, overwrite_a=False,
The N (1<=N<=M) selected eigenvalues, in ascending order, each
repeated according to its multiplicity.
Raises LinAlgError if eigenvalue computation does not converge,
Raises LinAlgError if eigenvalue computation does not converge,
an error occurred, or b matrix is not definite positive. Note that
if input matrices are not symmetric or hermitian, no error is reported
but results will be wrong.
Expand All @@ -636,7 +636,7 @@ def eigvalsh(a, b=None, lower=True, overwrite_a=False,
"""
return eigh(a, b=b, lower=lower, eigvals_only=True,
overwrite_a=overwrite_a, overwrite_b=overwrite_b,
turbo=turbo, eigvals=eigvals, type=type)
turbo=turbo, eigvals=eigvals, type=type)

def eigvals_banded(a_band,lower=0,overwrite_a_band=0,
select='a', select_range=None):
Expand Down
6 changes: 3 additions & 3 deletions scipy/linalg/tests/test_decomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def _complex_symrand(dim, dtype):
# add antisymmetric matrix as imag part
a = a1 +1j*(triu(a2)-tril(a2))
return a.astype(dtype)

def eigenhproblem_standard(desc, dim, dtype,
overwrite, lower, turbo,
eigvals):
Expand All @@ -524,7 +524,7 @@ def eigenhproblem_standard(desc, dim, dtype,
a = _complex_symrand(dim, dtype)
else:
a = symrand(dim).astype(dtype)

if overwrite:
a_c = a.copy()
else:
Expand Down Expand Up @@ -559,7 +559,7 @@ def eigenhproblem_general(desc, dim, dtype,
assert_array_almost_equal(diag1_, w, DIGITS[dtype])
diag2_ = diag(dot(z.T.conj(), dot(b_c, z))).real
assert_array_almost_equal(diag2_, ones(diag2_.shape[0]), DIGITS[dtype])

def test_eigh_integer():
a = array([[1,2],[2,7]])
b = array([[3,1],[1,5]])
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def __mul__(self, other):
other = np.asanyarray(other)

other = np.asanyarray(other)

if other.ndim == 1 or other.ndim == 2 and other.shape[1] == 1:
# dense row or column vector
if other.shape != (N,) and other.shape != (N,1):
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/linalg/eigen/arpack/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from os.path import join

def needs_veclib_wrapper(info):
"""Returns true if needs special veclib wrapper."""
"""Returns true if needs special veclib wrapper."""
import re
r_accel = re.compile("Accelerate")
r_vec = re.compile("vecLib")
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_complex_nonsymmetric_modes(self):
for typ in 'FD':
for which in ['LI','LR','LM','SI','SR','SM']:
for m in self.nonsymmetric:
self.eval_evec(m,typ,k,which)
self.eval_evec(m,typ,k,which)

if __name__ == "__main__":
run_module_suite()
20 changes: 10 additions & 10 deletions scipy/sparse/linalg/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ def _matmat(self, X):
"""Default matrix-matrix multiplication handler. Falls back on
the user-defined matvec() routine, which is always provided.
"""

return np.hstack( [ self.matvec(col.reshape(-1,1)) for col in X.T ] )


def matvec(self, x):
"""Matrix-vector multiplication
Performs the operation y=A*x where A is an MxN linear
Performs the operation y=A*x where A is an MxN linear
operator and x is a column vector or rank-1 array.
Parameters
Expand All @@ -103,7 +103,7 @@ def matvec(self, x):
Returns
-------
y : {matrix, ndarray}
A matrix or ndarray with shape (M,) or (M,1) depending
A matrix or ndarray with shape (M,) or (M,1) depending
on the type and shape of the x argument.
Notes
Expand All @@ -114,14 +114,14 @@ def matvec(self, x):
"""

x = np.asanyarray(x)

M,N = self.shape

if x.shape != (N,) and x.shape != (N,1):
raise ValueError('dimension mismatch')

y = self._matvec(x)

if isinstance(x, np.matrix):
y = np.asmatrix(y)
else:
Expand All @@ -141,7 +141,7 @@ def matvec(self, x):
def matmat(self, X):
"""Matrix-matrix multiplication
Performs the operation y=A*X where A is an MxN linear
Performs the operation y=A*X where A is an MxN linear
operator and X dense N*K matrix or ndarray.
Parameters
Expand All @@ -163,10 +163,10 @@ def matmat(self, X):
"""

X = np.asanyarray(X)

if X.ndim != 2:
raise ValueError('expected rank-2 ndarray or matrix')

M,N = self.shape

if X.shape[0] != N:
Expand All @@ -178,7 +178,7 @@ def matmat(self, X):
Y = np.asmatrix(Y)

return Y


def __mul__(self,x):
x = np.asarray(x)
Expand Down
15 changes: 7 additions & 8 deletions scipy/sparse/linalg/tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from numpy.testing import *

import numpy as np
import scipy.sparse as sparse
import scipy.sparse as sparse

from scipy.sparse.linalg.interface import *

Expand All @@ -27,28 +27,28 @@ def test_matvec(self):

for matvec in self.matvecs:
A = LinearOperator((2,3), matvec)

assert_equal(A.matvec(np.array([1,2,3])), [14,32])
assert_equal(A.matvec(np.array([[1],[2],[3]])), [[14],[32]])
assert_equal(A * np.array([1,2,3]), [14,32])
assert_equal(A * np.array([[1],[2],[3]]), [[14],[32]])

assert_equal(A.matvec(np.matrix([[1],[2],[3]])), [[14],[32]])
assert_equal(A * np.matrix([[1],[2],[3]]), [[14],[32]])

assert( isinstance(A.matvec(np.array([1,2,3])), np.ndarray) )
assert( isinstance(A.matvec(np.array([[1],[2],[3]])), np.ndarray) )
assert( isinstance(A * np.array([1,2,3]), np.ndarray) )
assert( isinstance(A * np.array([[1],[2],[3]]), np.ndarray) )

assert( isinstance(A.matvec(np.matrix([[1],[2],[3]])), np.ndarray) )
assert( isinstance(A * np.matrix([[1],[2],[3]]), np.ndarray) )

assert_raises(ValueError, A.matvec, np.array([1,2]))
assert_raises(ValueError, A.matvec, np.array([1,2,3,4]))
assert_raises(ValueError, A.matvec, np.array([[1],[2]]))
assert_raises(ValueError, A.matvec, np.array([[1],[2],[3],[4]]))



class TestAsLinearOperator(TestCase):
Expand Down Expand Up @@ -102,4 +102,3 @@ def test_basic(self):

if hasattr(M,'dtype'):
assert_equal(A.dtype, M.dtype)

2 changes: 1 addition & 1 deletion scipy/sparse/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_rmatvec(self):
assert_array_almost_equal([1,2,3,4]*M, dot([1,2,3,4], M.toarray()))
row = matrix([[1,2,3,4]])
assert_array_almost_equal(row*M, row*M.todense())

def test_small_multiplication(self):
"""test that A*x works for x with shape () (1,) and (1,1)
"""
Expand Down
28 changes: 14 additions & 14 deletions scipy/stats/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ def percentileofscore(a, score, kind = 'rank' ):
"mean": is the average score between "weak" and "strict" and is used in
testing
see: http://en.wikipedia.org/wiki/Percentile_rank
Parameters
----------
Expand Down Expand Up @@ -1063,13 +1063,13 @@ def percentileofscore(a, score, kind = 'rank' ):
>>> percentileofscore([1,2,3,4,5,6,7,8,9,10],4) #default kind = 'rank
40.0
>>> percentileofscore([1,2,3,4,5,6,7,8,9,10],4,kind = 'mean')
>>> percentileofscore([1,2,3,4,5,6,7,8,9,10],4,kind = 'mean')
35.0
>>> percentileofscore([1,2,3,4,5,6,7,8,9,10],4,kind = 'strict')
30.0
>>> percentileofscore([1,2,3,4,5,6,7,8,9,10],4,kind = 'weak')
40.0
# multiple - 2
>>> percentileofscore([1,2,3,4,4,5,6,7,8,9],4)
45.0
Expand All @@ -1079,8 +1079,8 @@ def percentileofscore(a, score, kind = 'rank' ):
30.0
>>> percentileofscore([1,2,3,4,4,5,6,7,8,9],4,kind = 'weak')
50.0
# multiple - 3
>>> percentileofscore([1,2,3,4,4,4,5,6,7,8],4)
50.0
Expand All @@ -1090,7 +1090,7 @@ def percentileofscore(a, score, kind = 'rank' ):
30.0
>>> percentileofscore([1,2,3,4,4,4,5,6,7,8],4,kind = 'weak')
60.0
# missing
>>> percentileofscore([1,2,3,5,6,7,8,9,10,11],4)
30.0
Expand Down Expand Up @@ -1143,7 +1143,7 @@ def percentileofscore(a, score, kind = 'rank' ):
90.0
>>> percentileofscore([ 10,20,30,50,60,70,80,90,100,110],110,kind = 'weak')
100.0
#out of bounds
Expand All @@ -1154,7 +1154,7 @@ def percentileofscore(a, score, kind = 'rank' ):
'''


a=np.array(a)
n = len(a)

Expand All @@ -1164,12 +1164,12 @@ def percentileofscore(a, score, kind = 'rank' ):
a_len = np.array(range(len(a)))
else:
a_len = np.array(range(len(a))) + 1.0

a = np.sort(a)
idx = [a == score]
pct = (np.mean(a_len[idx])/(n))*100.0
pct = (np.mean(a_len[idx])/(n))*100.0
return pct

elif kind == 'strict':
return sum(a<score)/float(n)*100
elif kind == 'weak':
Expand Down Expand Up @@ -2145,7 +2145,7 @@ def friedmanchisquare(*args):
probability value.
This function uses Chisquared aproximation of Friedman Chisquared
distribution. This is exact only if n > 10 and factor levels > 6.
distribution. This is exact only if n > 10 and factor levels > 6.
Returns: friedman chi-square statistic, associated p-valueIt assumes 3 or more repeated measures. Only 3
"""
Expand All @@ -2155,7 +2155,7 @@ def friedmanchisquare(*args):
n = len(args[0])
for i in range(1,k):
if len(args[i]) <> n:
raise ValueError, 'Unequal N in friedmanchisquare. Aborting.'
raise ValueError, 'Unequal N in friedmanchisquare. Aborting.'
if n < 10 and k < 6:
print 'Warning: friedmanchisquare test using Chisquared aproximation'

Expand All @@ -2172,7 +2172,7 @@ def friedmanchisquare(*args):
for t in repnum:
ties += t*(t*t-1)
c = 1 - ties / float(k*(k*k-1)*n)

ssbn = pysum(pysum(data)**2)
chisq = ( 12.0 / (k*n*(k+1)) * ssbn - 3*n*(k+1) ) / c
return chisq, chisqprob(chisq,k-1)
Expand Down
Loading

0 comments on commit 2cf4a79

Please sign in to comment.