diff --git a/nipy/algorithms/statistics/rft.py b/nipy/algorithms/statistics/rft.py index bb6e5af8ee..f1cd0e5160 100644 --- a/nipy/algorithms/statistics/rft.py +++ b/nipy/algorithms/statistics/rft.py @@ -87,14 +87,14 @@ def Q(dim, dfd=np.inf): j = dim if j <= 0: raise ValueError('Q defined only for dim > 0') - poly = hermitenorm(j-1) - poly = np.poly1d(np.around(poly.c)) + coeffs = np.around(hermitenorm(j - 1).c) if np.isfinite(m): - for l in range((j-1)//2+1): - f = np.exp(gammaln((m+1)/2.) - gammaln((m+2-j+2*l)/2.) - - 0.5*(j-1-2*l)*(np.log(m/2.))) - poly.c[2*l] *= f - return np.poly1d(poly.c) + for L in range((j - 1) // 2 + 1): + f = np.exp(gammaln((m + 1) / 2.) + - gammaln((m + 2 - j + 2 * L) / 2.) + - 0.5 * (j - 1 - 2 * L) * (np.log(m / 2.))) + coeffs[2 * L] *= f + return np.poly1d(coeffs) class ECquasi(np.poly1d): diff --git a/nipy/algorithms/statistics/tests/test_rft.py b/nipy/algorithms/statistics/tests/test_rft.py index f52e69f36e..0cf1cb034b 100644 --- a/nipy/algorithms/statistics/tests/test_rft.py +++ b/nipy/algorithms/statistics/tests/test_rft.py @@ -400,7 +400,7 @@ def test_hotelling2(): chi = rft.ChiSquared(dfn=dfn)(x) assert_almost_equal(h, chi) chi2 = scipy.stats.chi2.sf(x, dfn) - yield assert_almost_equal, h, chi2 + assert_almost_equal(h, chi2) # XXX - p appears to be unused p = rft.spherical_search(dfn) for dfd in [40,50]: @@ -408,8 +408,8 @@ def test_hotelling2(): h = rft.Hotelling(dfd=dfd,k=dfn)(x) f = scipy.stats.f.sf(x*fac, dfn, dfd-dfn+1) f2 = rft.FStat(dfd=dfd-dfn+1,dfn=dfn)(x*fac) - yield assert_almost_equal, f2, f - yield assert_almost_equal, h, f + assert_almost_equal(f2, f) + assert_almost_equal(h, f) @dec.slow