8000 Pep8 numpy polynomial by charris · Pull Request #4924 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Pep8 numpy polynomial #4924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 4, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
MAINT: Fix blemishes in numpy/polynomial/tests revealed by pyflakes.
  • Loading branch information
charris committed Jul 30, 2014
commit f9c6398d4f021e9509e19157a0d5ee72b27a8c2a
28 changes: 21 additions & 7 deletions numpy/polynomial/tests/test_classes.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

import numpy as np
from numpy.polynomial import (
Polynomial, Legendre, Chebyshev, Laguerre,
Hermite, HermiteE)
Polynomial, Legendre, Chebyshev, Laguerre, Hermite, HermiteE)
from numpy.testing import (
TestCase, assert_almost_equal, assert_raises,
assert_equal, assert_, run_module_suite, dec)
from numpy.testing.noseclasses import KnownFailure
assert_almost_equal, assert_raises, assert_equal, assert_,
run_module_suite)
from numpy.compat import long


Expand Down Expand Up @@ -410,6 +408,9 @@ def check_roots(Poly):
d = Poly.domain + random((2,))*.25
w = Poly.window + random((2,))*.25
tgt = np.sort(random((5,)))
res = np.sort(Poly.fromroots(tgt, domain=d, window=w).roots())
assert_almost_equal(res, tgt)
# default domain and window
res = np.sort(Poly.fromroots(tgt).roots())
assert_almost_equal(res, tgt)

Expand Down Expand Up @@ -468,6 +469,12 @@ def check_deriv(Poly):
p3 = p1.integ(1, k=[1])
assert_almost_equal(p2.deriv(1).coef, p3.coef)
assert_almost_equal(p2.deriv(2).coef, p1.coef)
# default domain and window
p1 = Poly([1, 2, 3])
p2 = p1.integ(2, k=[1, 2])
p3 = p1.integ(1, k=[1])
assert_almost_equal(p2.deriv(1).coef, p3.coef)
assert_almost_equal(p2.deriv(2).coef, p1.coef)


def check_linspace(Poly):
Expand All @@ -491,11 +498,18 @@ def check_linspace(Poly):
def check_pow(Poly):
d = Poly.domain + random((2,))*.25
w = Poly.window + random((2,))*.25
tgt = Poly([1], domain=d, window=d)
tst = Poly([1, 2, 3], domain=d, window=d)
tgt = Poly([1], domain=d, window=w)
tst = Poly([1, 2, 3], domain=d, window=w)
for i in range(5):
assert_poly_almost_equal(tst**i, tgt)
tgt = tgt * tst
# default domain and window
tgt = Poly([1])
tst = Poly([1, 2, 3])
for i in range(5):
assert_poly_almost_equal(tst**i, tgt)
tgt = tgt * tst
# check error for invalid powers
assert_raises(ValueError, op.pow, tgt, 1.5)
assert_raises(ValueError, op.pow, tgt, -1)

Expand Down
1 change: 0 additions & 1 deletion numpy/polynomial/tests/test_hermite.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def test_hermval(self):
y = [polyval(x, c) for c in Hlist]
for i in range(10):
msg = "At i=%d" % i
ser = np.zeros
tgt = y[i]
res = herm.hermval(x, [0]*i + [1])
assert_almost_equal(res, tgt, err_msg=msg)
Expand Down
5 changes: 3 additions & 2 deletions numpy/polynomial/tests/test_hermite_e.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import numpy as np
import numpy.polynomial.hermite_e as herme
from numpy.polynomial.polynomial import polyval
from numpy.testing import *
from numpy.testing import (
TestCase, assert_almost_equal, assert_raises,
assert_equal, assert_, run_module_suite)

He0 = np.array([1])
He1 = np.array([0, 1])
Expand Down Expand Up @@ -117,7 +119,6 @@ def test_hermeval(self):
y = [polyval(x, c) for c in Helist]
for i in range(10):
msg = "At i=%d" % i
ser = np.zeros
tgt = y[i]
res = herme.hermeval(x, [0]*i + [1])
assert_almost_equal(res, tgt, err_msg=msg)
Expand Down
1 change: 0 additions & 1 deletion numpy/polynomial/tests/test_laguerre.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def test_lagval(self):
y = [polyval(x, c) for c in Llist]
for i in range(7):
msg = "At i=%d" % i
ser = np.zeros
tgt = y[i]
res = lag.lagval(x, [0]*i + [1])
assert_almost_equal(res, tgt, err_msg=msg)
Expand Down
1 change: 0 additions & 1 deletion numpy/polynomial/tests/test_legendre.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def test_legval(self):
y = [polyval(x, c) for c in Llist]
for i in range(10):
msg = "At i=%d" % i
ser = np.zeros
tgt = y[i]
res = leg.legval(x, [0]*i + [1])
assert_almost_equal(res, tgt, err_msg=msg)
Expand Down
8 changes: 7 additions & 1 deletion numpy/polynomial/tests/test_polyutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import numpy as np
import numpy.polynomial.polyutils as pu
from numpy.testing import *
from numpy.testing import (
TestCase, assert_almost_equal, assert_raises,
assert_equal, assert_, run_module_suite)


class TestMisc(TestCase):
Expand Down Expand Up @@ -101,3 +103,7 @@ def test_mapparms(self):
tgt = [-1 + 1j, 1 - 1j]
res = pu.mapparms(dom1, dom2)
assert_almost_equal(res, tgt)


if __name__ == "__main__":
run_module_suite()
0