[Scipy-svn] r5236 - in trunk: doc/source scipy/cluster/tests scipy/interpolate/tests scipy/io/matlab/tests scipy/linalg scipy/signal scipy/sparse/linalg/eigen/arpack scipy/stats scipy/stats/tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Dec 7 19:08:31 EST 2008
Author: jarrod.millman
Date: 2008-12-07 18:08:23 -0600 (Sun, 07 Dec 2008)
New Revision: 5236
Modified:
trunk/doc/source/conf.py
trunk/scipy/cluster/tests/test_hierarchy.py
trunk/scipy/interpolate/tests/test_fitpack.py
trunk/scipy/io/matlab/tests/test_mio.py
trunk/scipy/linalg/decomp.py
trunk/scipy/signal/signaltools.py
trunk/scipy/sparse/linalg/eigen/arpack/setup.py
trunk/scipy/stats/distributions.py
trunk/scipy/stats/stats.py
trunk/scipy/stats/tests/test_discrete_basic.py
trunk/scipy/stats/tests/test_stats.py
Log:
ran reindent
Modified: trunk/doc/source/conf.py
===================================================================
--- trunk/doc/source/conf.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/doc/source/conf.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -239,4 +239,3 @@
"""
plot_output_dir = '_static/plot_directive'
plot_include_source = True
-
Modified: trunk/scipy/cluster/tests/test_hierarchy.py
===================================================================
--- trunk/scipy/cluster/tests/test_hierarchy.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -591,7 +591,7 @@
"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)
@@ -600,7 +600,7 @@
"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)
@@ -609,7 +609,7 @@
"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)
@@ -618,7 +618,7 @@
"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)
@@ -676,7 +676,7 @@
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)
@@ -686,7 +686,7 @@
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)
@@ -696,7 +696,7 @@
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)
Modified: trunk/scipy/interpolate/tests/test_fitpack.py
===================================================================
--- trunk/scipy/interpolate/tests/test_fitpack.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/interpolate/tests/test_fitpack.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -155,12 +155,12 @@
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__":
Modified: trunk/scipy/io/matlab/tests/test_mio.py
===================================================================
--- trunk/scipy/io/matlab/tests/test_mio.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/io/matlab/tests/test_mio.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -347,6 +347,5 @@
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')
-
Modified: trunk/scipy/linalg/decomp.py
===================================================================
--- trunk/scipy/linalg/decomp.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/linalg/decomp.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -1175,7 +1175,7 @@
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")
Modified: trunk/scipy/signal/signaltools.py
===================================================================
--- trunk/scipy/signal/signaltools.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/signal/signaltools.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -1515,11 +1515,11 @@
#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))))))
@@ -1530,12 +1530,12 @@
#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):
# FIXME: For now only accepting 1d arrays
ntaps=max(len(a),len(b))
Modified: trunk/scipy/sparse/linalg/eigen/arpack/setup.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/arpack/setup.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/sparse/linalg/eigen/arpack/setup.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -43,11 +43,11 @@
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')])
Modified: trunk/scipy/stats/distributions.py
===================================================================
--- trunk/scipy/stats/distributions.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/stats/distributions.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -772,7 +772,7 @@
Parameters:
-----------
n: int, n>=1
-
+
*args:
The shape parameter(s) for the distribution (see docstring of the
instance object for more information)
@@ -3112,7 +3112,7 @@
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))
@@ -3955,7 +3955,7 @@
Parameters:
-----------
n: int, n>=1
-
+
*args:
The shape parameter(s) for the distribution (see docstring of the
instance object for more information)
Modified: trunk/scipy/stats/stats.py
===================================================================
--- trunk/scipy/stats/stats.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/stats/stats.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -1898,11 +1898,11 @@
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
@@ -1966,12 +1966,12 @@
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
@@ -1984,7 +1984,7 @@
equal averages.
see: http://en.wikipedia.org/wiki/T-test#Dependent_t-test
-
+
Examples
--------
@@ -2071,8 +2071,8 @@
defines distribution used for calculating p-value
'approx' : use approximation to exact distribution of test statistic
'asymp' : use asymptotic distribution of test statistic
-
+
Returns
-------
D: test statistic either D, D+ or D-
@@ -2103,8 +2103,8 @@
---------------------------------------------
>>> 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')
@@ -2112,24 +2112,24 @@
>>> # 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)
@@ -2139,11 +2139,11 @@
#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):
@@ -2153,21 +2153,21 @@
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 :
@@ -2198,7 +2198,7 @@
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:
@@ -2207,7 +2207,7 @@
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.
@@ -2221,7 +2221,7 @@
>>> 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);
@@ -2247,7 +2247,7 @@
>>> 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]
Modified: trunk/scipy/stats/tests/test_discrete_basic.py
===================================================================
--- trunk/scipy/stats/tests/test_discrete_basic.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/stats/tests/test_discrete_basic.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -47,7 +47,7 @@
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:
Modified: trunk/scipy/stats/tests/test_stats.py
===================================================================
--- trunk/scipy/stats/tests/test_stats.py 2008-12-07 22:06:29 UTC (rev 5235)
+++ trunk/scipy/stats/tests/test_stats.py 2008-12-08 00:08:23 UTC (rev 5236)
@@ -999,7 +999,7 @@
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')
@@ -1052,7 +1052,7 @@
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()
More information about the Scipy-svn
mailing list