Skip to content

Commit

Permalink
ran reindent
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodmillman committed Dec 8, 2008
1 parent b9a9eed commit 36bb68c
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 48 deletions.
1 change: 0 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,3 @@
"""
plot_output_dir = '_static/plot_directive'
plot_include_source = True

14 changes: 7 additions & 7 deletions scipy/cluster/tests/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def test_is_valid_linkage_4_and_up_neg_index_left(self):
"Tests is_valid_linkage(Z) on linkage on observation sets between sizes 4 and 15 (step size 3) with negative indices (left)."
for i in xrange(4, 15, 3):
y = np.random.rand(i*(i-1)/2)
Z = linkage(y)
Z = linkage(y)
Z[int(i/2),0] = -2
self.failUnless(is_valid_linkage(Z) == False)
self.failUnlessRaises(ValueError, is_valid_linkage, Z, throw=True)
Expand All @@ -600,7 +600,7 @@ def test_is_valid_linkage_4_and_up_neg_index_right(self):
"Tests is_valid_linkage(Z) on linkage on observation sets between sizes 4 and 15 (step size 3) with negative indices (right)."
for i in xrange(4, 15, 3):
y = np.random.rand(i*(i-1)/2)
Z = linkage(y)
Z = linkage(y)
Z[int(i/2),1] = -2
self.failUnless(is_valid_linkage(Z) == False)
self.failUnlessRaises(ValueError, is_valid_linkage, Z, throw=True)
Expand All @@ -609,7 +609,7 @@ def test_is_valid_linkage_4_and_up_neg_dist(self):
"Tests is_valid_linkage(Z) on linkage on observation sets between sizes 4 and 15 (step size 3) with negative distances."
for i in xrange(4, 15, 3):
y = np.random.rand(i*(i-1)/2)
Z = linkage(y)
Z = linkage(y)
Z[int(i/2),2] = -0.5
self.failUnless(is_valid_linkage(Z) == False)
self.failUnlessRaises(ValueError, is_valid_linkage, Z, throw=True)
Expand All @@ -618,7 +618,7 @@ def test_is_valid_linkage_4_and_up_neg_counts(self):
"Tests is_valid_linkage(Z) on linkage on observation sets between sizes 4 and 15 (step size 3) with negative counts."
for i in xrange(4, 15, 3):
y = np.random.rand(i*(i-1)/2)
Z = linkage(y)
Z = linkage(y)
Z[int(i/2),3] = -2
self.failUnless(is_valid_linkage(Z) == False)
self.failUnlessRaises(ValueError, is_valid_linkage, Z, throw=True)
Expand Down Expand Up @@ -676,7 +676,7 @@ def test_is_valid_im_4_and_up_neg_index_left(self):
for i in xrange(4, 15, 3):
y = np.random.rand(i*(i-1)/2)
Z = linkage(y)
R = inconsistent(Z)
R = inconsistent(Z)
R[int(i/2),0] = -2.0
self.failUnless(is_valid_im(R) == False)
self.failUnlessRaises(ValueError, is_valid_im, R, throw=True)
Expand All @@ -686,7 +686,7 @@ def test_is_valid_im_4_and_up_neg_index_right(self):
for i in xrange(4, 15, 3):
y = np.random.rand(i*(i-1)/2)
Z = linkage(y)
R = inconsistent(Z)
R = inconsistent(Z)
R[int(i/2),1] = -2.0
self.failUnless(is_valid_im(R) == False)
self.failUnlessRaises(ValueError, is_valid_im, R, throw=True)
Expand All @@ -696,7 +696,7 @@ def test_is_valid_im_4_and_up_neg_dist(self):
for i in xrange(4, 15, 3):
y = np.random.rand(i*(i-1)/2)
Z = linkage(y)
R = inconsistent(Z)
R = inconsistent(Z)
R[int(i/2),2] = -0.5
self.failUnless(is_valid_im(R) == False)
self.failUnlessRaises(ValueError, is_valid_im, R, throw=True)
Expand Down
4 changes: 2 additions & 2 deletions scipy/interpolate/tests/test_fitpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ def test_evaluate(self):
y = array([1,2,3,4,5])
z = array([[1,2,1,2,1],[1,2,1,2,1],[1,2,3,2,1],[1,2,2,2,1],[1,2,1,2,1]])
lut = RectBivariateSpline(x,y,z)

xi = [1, 2.3, 5.3, 0.5, 3.3, 1.2, 3]
yi = [1, 3.3, 1.2, 4.0, 5.0, 1.0, 3]
zi = lut.ev(xi, yi)
zi2 = array([lut(xp, yp)[0,0] for xp, yp in zip(xi, yi)])

assert_almost_equal(zi, zi2)

if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions scipy/io/matlab/tests/test_mio.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,5 @@ def test_structname_len():
savemat(StringIO(), {'longstruct': st1}, format='5')
fldname = 'a' * (lim+1)
st1 = np.zeros((1,1), dtype=[(fldname, object)])
assert_raises(ValueError, savemat, StringIO(),
assert_raises(ValueError, savemat, StringIO(),
{'longstruct': st1}, format='5')

2 changes: 1 addition & 1 deletion scipy/linalg/decomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ def qr(a, overwrite_a=0, lwork=None, econ=None, mode='qr'):
warn("qr econ argument will be removed after scipy 0.7. "
"The economy transform will then be available through "
"the mode='economic' argument.", DeprecationWarning)

a1 = asarray_chkfinite(a)
if len(a1.shape) != 2:
raise ValueError("expected 2D array")
Expand Down
8 changes: 4 additions & 4 deletions scipy/signal/signaltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,11 +1515,11 @@ def lfilter_zi(b,a):
#Based on:
# [Gust96] Fredrik Gustafsson, Determining the initial states in
# forward-backward filtering, IEEE Transactions on
# Signal Processing, pp. 988--992, April 1996,
# Signal Processing, pp. 988--992, April 1996,
# Volume 44, Issue 4

n=max(len(a),len(b))

zin = (np.eye(n-1) - np.hstack((-a[1:n,newaxis],
np.vstack((np.eye(n-2),zeros(n-2))))))

Expand All @@ -1530,10 +1530,10 @@ def lfilter_zi(b,a):

#convert the result into a regular array (not a matrix)
for i in range(len(zi_matrix)):
zi_return.append(float(zi_matrix[i][0]))
zi_return.append(float(zi_matrix[i][0]))

return array(zi_return)



def filtfilt(b,a,x):
Expand Down
4 changes: 2 additions & 2 deletions scipy/sparse/linalg/eigen/arpack/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def configuration(parent_package='',top_path=None):

config.add_library('arpack', sources=arpack_sources,
include_dirs=[join('ARPACK', 'SRC')],
depends = [join('ARPACK', 'FWRAPPERS',
depends = [join('ARPACK', 'FWRAPPERS',
'veclib_cabi_f.f'),
join('ARPACK', 'FWRAPPERS',
'veclib_cabi_c.c'),
join('ARPACK', 'FWRAPPERS',
join('ARPACK', 'FWRAPPERS',
'dummy.f')])


Expand Down
6 changes: 3 additions & 3 deletions scipy/stats/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ def moment(self, n, *args):
Parameters:
-----------
n: int, n>=1
*args:
The shape parameter(s) for the distribution (see docstring of the
instance object for more information)
Expand Down Expand Up @@ -3112,7 +3112,7 @@ def _cdf(self, x, b):
def _ppf(self, q, b):
return -log(1-q+q*exp(-b))
def _munp(self, n, b):
#wrong answer with formula, same as in continuous.pdf
#wrong answer with formula, same as in continuous.pdf
#return gam(n+1)-special.gammainc(1+n,b)
if n == 1:
return (1-(b+1)*np.exp(-b))/(1-np.exp(-b))
Expand Down Expand Up @@ -3955,7 +3955,7 @@ def moment(self, n, *args, **kwds): # Non-central moments in standard form.
Parameters:
-----------
n: int, n>=1
*args:
The shape parameter(s) for the distribution (see docstring of the
instance object for more information)
Expand Down
46 changes: 23 additions & 23 deletions scipy/stats/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,11 +1898,11 @@ def ttest_ind(a, b, axis=0):
Returns: t-value, two-tailed p-value
This is a two-sided test for the null hypothesis that 2 independent samples
have identical average (expected) values.
have identical average (expected) values.
Description
-----------
We can use this test, if we observe two independent samples from
the same or different population, e.g. exam scores of boys and
girls or of two ethnic groups. The test measures whether the
Expand Down Expand Up @@ -1966,12 +1966,12 @@ def ttest_rel(a,b,axis=None):
first), or an integer (the axis over which to operate on a and b).
Returns: t-value, two-tailed p-value
Description
-----------
This is a two-sided test for the null hypothesis that 2 repeated samples
have identical average values.
have identical average values.
Examples for the use are scores of a student in different exams,
or repeated sampling from the same units. The test measures
Expand All @@ -1984,7 +1984,7 @@ def ttest_rel(a,b,axis=None):
equal averages.
see: http://en.wikipedia.org/wiki/T-test#Dependent_t-test
Examples
--------
Expand Down Expand Up @@ -2071,7 +2071,7 @@ def kstest(rvs, cdf, args=(), N=20, alternative = 'unequal', mode='approx'):
defines distribution used for calculating p-value
'approx' : use approximation to exact distribution of test statistic
'asymp' : use asymptotic distribution of test statistic
Returns
-------
Expand Down Expand Up @@ -2103,33 +2103,33 @@ def kstest(rvs, cdf, args=(), N=20, alternative = 'unequal', mode='approx'):
---------------------------------------------
>>> np.random.seed(987654321)
>>> # shift distribution to larger values, so that cdf_dgp(x)< norm.cdf(x)
>>> x = stats.norm.rvs(loc=0.2, size=100)
>>> kstest(x,'norm', alternative = 'smaller')
>>> x = stats.norm.rvs(loc=0.2, size=100)
>>> kstest(x,'norm', alternative = 'smaller')
(0.12464329735846891, 0.040989164077641749)
>>> # reject equal distribution against alternative hypothesis: smaller
>>> kstest(x,'norm', alternative = 'larger')
(0.0072115233216311081, 0.98531158590396395)
>>> # don't reject equal distribution against alternative hypothesis: larger
>>> kstest(x,'norm', mode='asymp')
(0.12464329735846891, 0.08944488871182088)
testing t distributed random variables against normal distribution
------------------------------------------------------------------
With 100 degrees of freedom the t distribution looks close to the normal
distribution, and the kstest does not reject the hypothesis that the sample
came from the normal distribution
>>> np.random.seed(987654321)
>>> stats.kstest(stats.t.rvs(100,size=100),'norm')
(0.072018929165471257, 0.67630062862479168)
With 3 degrees of freedom the t distribution looks sufficiently different
from the normal distribution, that we can reject the hypothesis that the
sample came from the normal distribution at a alpha=10% level
>>> np.random.seed(987654321)
>>> stats.kstest(stats.t.rvs(3,size=100),'norm')
(0.131016895759829, 0.058826222555312224)
Expand All @@ -2139,11 +2139,11 @@ def kstest(rvs, cdf, args=(), N=20, alternative = 'unequal', mode='approx'):
#cdf = getattr(stats, rvs).cdf
if (not cdf) or (cdf == rvs):
cdf = getattr(distributions, rvs).cdf
rvs = getattr(distributions, rvs).rvs
rvs = getattr(distributions, rvs).rvs
else:
raise AttributeError, 'if rvs is string, cdf has to be the same distribution'


if isinstance(cdf, basestring):
cdf = getattr(distributions, cdf).cdf
if callable(rvs):
Expand All @@ -2153,21 +2153,21 @@ def kstest(rvs, cdf, args=(), N=20, alternative = 'unequal', mode='approx'):
vals = np.sort(rvs)
N = len(vals)
cdfvals = cdf(vals, *args)

if alternative in ['unequal', 'larger']:
Dplus = (np.arange(1.0, N+1)/N - cdfvals).max()
if alternative == 'larger':
return Dplus, distributions.ksone.sf(Dplus,N)

if alternative in ['unequal', 'smaller']:
Dmin = (cdfvals - np.arange(0.0, N)/N).max()
if alternative == 'smaller':
return Dmin, distributions.ksone.sf(Dmin,N)

if alternative == 'unequal':
D = np.max([Dplus,Dmin])
if mode == 'asymp':
return D, distributions.kstwobign.sf(D*np.sqrt(N))
return D, distributions.kstwobign.sf(D*np.sqrt(N))
if mode == 'approx':
pval_two = distributions.kstwobign.sf(D*np.sqrt(N))
if N > 2666 or pval_two > 0.80 - N*0.3/1000.0 :
Expand Down Expand Up @@ -2198,7 +2198,7 @@ def ks_2samp(data1, data2):
data1, data2: array_like, 1-dim
samples assumed to be drawn from a continuous distribution,
sample sizes can be different
Returns: KS D-value, p-value
Description:
Expand All @@ -2207,7 +2207,7 @@ def ks_2samp(data1, data2):
Tests whether 2 samples are drawn from the same distribution. Note
that, like the one-sample K-S test the distribution is assumed to be
continuous.
This is the two-sided test, one-sided tests are not implemented.
The test uses the two-sided asymptotic Kolmogorov-Smirnov distribution.
Expand All @@ -2221,7 +2221,7 @@ def ks_2samp(data1, data2):
>>> from scipy import stats
>>> import numpy as np
>>> from scipy.stats import ks_2samp
# fix random seed to get the same result
>>> np.random.seed(12345678);
Expand All @@ -2247,7 +2247,7 @@ def ks_2samp(data1, data2):
>>> rvs4 = stats.norm.rvs(size=n2,loc=0.0,scale=1.0)
>>> ks_2samp(rvs1,rvs4)
(0.07999999999999996, 0.41126949729859719)
"""
data1, data2 = map(asarray, (data1, data2))
n1 = data1.shape[0]
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/tests/test_discrete_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_discrete_basic():
alpha = 0.01
yield check_discrete_chisquare, distfn, arg, rvs, alpha, \
distname + ' chisquare'

@npt.dec.slow
def test_discrete_extra():
for distname, arg in distdiscrete:
Expand Down
4 changes: 2 additions & 2 deletions scipy/stats/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ def test_friedmanchisquare():

def test_kstest():
#from numpy.testing import assert_almost_equal

# comparing with values from R
x = np.linspace(-1,1,9)
D,p = stats.kstest(x,'norm')
Expand Down Expand Up @@ -1052,7 +1052,7 @@ def test_ks_2samp():
assert_almost_equal(
np.array(stats.ks_2samp(np.linspace(1,100,100),
np.linspace(1,100,110)+20-0.1)),
np.array((0.20818181818181825, 0.017981441789762638)))
np.array((0.20818181818181825, 0.017981441789762638)))

if __name__ == "__main__":
run_module_suite()

0 comments on commit 36bb68c

Please sign in to comment.