summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_polynomial.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-08-18 11:51:25 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-08-18 11:51:25 -0600
commitfbd6510d58a47ea0d166c48a82793f05425406e4 (patch)
tree330ce703eb02d20f96099c3fe0fc36ae33d4905b /numpy/lib/tests/test_polynomial.py
parent8ddb0ce0acafe75d78df528b4d2540dfbf4b364d (diff)
downloadnumpy-fbd6510d58a47ea0d166c48a82793f05425406e4.tar.gz
STY: Giant comma spacing fixup.
Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
Diffstat (limited to 'numpy/lib/tests/test_polynomial.py')
-rw-r--r--numpy/lib/tests/test_polynomial.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py
index fa166b7f1..617419eee 100644
--- a/numpy/lib/tests/test_polynomial.py
+++ b/numpy/lib/tests/test_polynomial.py
@@ -86,29 +86,29 @@ class TestDocs(TestCase):
return rundocs()
def test_roots(self):
- assert_array_equal(np.roots([1,0,0]), [0,0])
+ assert_array_equal(np.roots([1, 0, 0]), [0, 0])
def test_str_leading_zeros(self):
- p = np.poly1d([4,3,2,1])
+ p = np.poly1d([4, 3, 2, 1])
p[3] = 0
assert_equal(str(p),
" 2\n"
"3 x + 2 x + 1")
- p = np.poly1d([1,2])
+ p = np.poly1d([1, 2])
p[0] = 0
p[1] = 0
assert_equal(str(p), " \n0")
def test_polyfit(self) :
c = np.array([3., 2., 1.])
- x = np.linspace(0,2,7)
- y = np.polyval(c,x)
- err = [1,-1,1,-1,1,-1,1]
- weights = np.arange(8,1,-1)**2/7.0
+ x = np.linspace(0, 2, 7)
+ y = np.polyval(c, x)
+ err = [1, -1, 1, -1, 1, -1, 1]
+ weights = np.arange(8, 1, -1)**2/7.0
# check 1D case
- m, cov = np.polyfit(x,y+err,2,cov=True)
+ m, cov = np.polyfit(x, y+err, 2, cov=True)
est = [3.8571, 0.2857, 1.619]
assert_almost_equal(est, m, decimal=4)
val0 = [[2.9388, -5.8776, 1.6327],
@@ -116,7 +116,7 @@ class TestDocs(TestCase):
[1.6327, -4.2449, 2.3220]]
assert_almost_equal(val0, cov, decimal=4)
- m2, cov2 = np.polyfit(x,y+err,2,w=weights,cov=True)
+ m2, cov2 = np.polyfit(x, y+err, 2, w=weights, cov=True)
assert_almost_equal([4.8927, -1.0177, 1.7768], m2, decimal=4)
val = [[ 8.7929, -10.0103, 0.9756],
[-10.0103, 13.6134, -1.8178],
@@ -124,19 +124,19 @@ class TestDocs(TestCase):
assert_almost_equal(val, cov2, decimal=4)
# check 2D (n,1) case
- y = y[:,np.newaxis]
- c = c[:,np.newaxis]
- assert_almost_equal(c, np.polyfit(x,y,2))
+ y = y[:, np.newaxis]
+ c = c[:, np.newaxis]
+ assert_almost_equal(c, np.polyfit(x, y, 2))
# check 2D (n,2) case
- yy = np.concatenate((y,y), axis=1)
- cc = np.concatenate((c,c), axis=1)
- assert_almost_equal(cc, np.polyfit(x,yy,2))
+ yy = np.concatenate((y, y), axis=1)
+ cc = np.concatenate((c, c), axis=1)
+ assert_almost_equal(cc, np.polyfit(x, yy, 2))
- m, cov = np.polyfit(x,yy + np.array(err)[:,np.newaxis],2,cov=True)
- assert_almost_equal(est, m[:,0], decimal=4)
- assert_almost_equal(est, m[:,1], decimal=4)
- assert_almost_equal(val0, cov[:,:,0], decimal=4)
- assert_almost_equal(val0, cov[:,:,1], decimal=4)
+ m, cov = np.polyfit(x, yy + np.array(err)[:, np.newaxis], 2, cov=True)
+ assert_almost_equal(est, m[:, 0], decimal=4)
+ assert_almost_equal(est, m[:, 1], decimal=4)
+ assert_almost_equal(val0, cov[:,:, 0], decimal=4)
+ assert_almost_equal(val0, cov[:,:, 1], decimal=4)
def test_objects(self):
from decimal import Decimal
@@ -153,14 +153,14 @@ class TestDocs(TestCase):
def test_complex(self):
p = np.poly1d([3j, 2j, 1j])
p2 = p.integ()
- assert_((p2.coeffs == [1j,1j,1j,0]).all())
+ assert_((p2.coeffs == [1j, 1j, 1j, 0]).all())
p2 = p.deriv()
- assert_((p2.coeffs == [6j,2j]).all())
+ assert_((p2.coeffs == [6j, 2j]).all())
def test_integ_coeffs(self):
- p = np.poly1d([3,2,1])
- p2 = p.integ(3, k=[9,7,6])
- assert_((p2.coeffs == [1/4./5.,1/3./4.,1/2./3.,9/1./2.,7,6]).all())
+ p = np.poly1d([3, 2, 1])
+ p2 = p.integ(3, k=[9, 7, 6])
+ assert_((p2.coeffs == [1/4./5., 1/3./4., 1/2./3., 9/1./2., 7, 6]).all())
def test_zero_dims(self):
try: