diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2012-01-31 20:43:46 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2012-02-05 17:03:27 -0700 |
commit | 794e9c3b37bb08e95e31b40889947d1d772b8f18 (patch) | |
tree | 6e55e578cffb5dd213a1c39595a8487170c5bd7f /numpy | |
parent | ef767a54fae8977cb15d7e0849a8cb626c4b0f2c (diff) | |
download | numpy-794e9c3b37bb08e95e31b40889947d1d772b8f18.tar.gz |
STY: Code cleanup in polynomial [*]fromroots functions.
Use divmod instead of // and % separately.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/polynomial/chebyshev.py | 6 | ||||
-rw-r--r-- | numpy/polynomial/hermite.py | 6 | ||||
-rw-r--r-- | numpy/polynomial/hermite_e.py | 6 | ||||
-rw-r--r-- | numpy/polynomial/laguerre.py | 6 | ||||
-rw-r--r-- | numpy/polynomial/legendre.py | 6 | ||||
-rw-r--r-- | numpy/polynomial/polynomial.py | 6 |
6 files changed, 18 insertions, 18 deletions
diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py index ab4c96a54..6fbd5d346 100644 --- a/numpy/polynomial/chebyshev.py +++ b/numpy/polynomial/chebyshev.py @@ -541,12 +541,12 @@ def chebfromroots(roots) : else : [roots] = pu.as_series([roots], trim=False) roots.sort() - n = len(roots) p = [chebline(-r, 1) for r in roots] + n = len(p) while n > 1: - m = n//2 + m, r = divmod(n, 2) tmp = [chebmul(p[i], p[i+m]) for i in range(m)] - if n%2: + if r: tmp[0] = chebmul(tmp[0], p[-1]) p = tmp n = m diff --git a/numpy/polynomial/hermite.py b/numpy/polynomial/hermite.py index 32b50a866..229ac26db 100644 --- a/numpy/polynomial/hermite.py +++ b/numpy/polynomial/hermite.py @@ -288,12 +288,12 @@ def hermfromroots(roots) : else : [roots] = pu.as_series([roots], trim=False) roots.sort() - n = len(roots) p = [hermline(-r, 1) for r in roots] + n = len(p) while n > 1: - m = n//2 + m, r = divmod(n, 2) tmp = [hermmul(p[i], p[i+m]) for i in range(m)] - if n%2: + if r: tmp[0] = hermmul(tmp[0], p[-1]) p = tmp n = m diff --git a/numpy/polynomial/hermite_e.py b/numpy/polynomial/hermite_e.py index 0511307a4..ba41a4fc0 100644 --- a/numpy/polynomial/hermite_e.py +++ b/numpy/polynomial/hermite_e.py @@ -288,12 +288,12 @@ def hermefromroots(roots) : else : [roots] = pu.as_series([roots], trim=False) roots.sort() - n = len(roots) p = [hermeline(-r, 1) for r in roots] + n = len(p) while n > 1: - m = n//2 + m, r = divmod(n, 2) tmp = [hermemul(p[i], p[i+m]) for i in range(m)] - if n%2: + if r: tmp[0] = hermemul(tmp[0], p[-1]) p = tmp n = m diff --git a/numpy/polynomial/laguerre.py b/numpy/polynomial/laguerre.py index 866aab5c4..4401b5414 100644 --- a/numpy/polynomial/laguerre.py +++ b/numpy/polynomial/laguerre.py @@ -284,12 +284,12 @@ def lagfromroots(roots) : else : [roots] = pu.as_series([roots], trim=False) roots.sort() - n = len(roots) p = [lagline(-r, 1) for r in roots] + n = len(p) while n > 1: - m = n//2 + m, r = divmod(n, 2) tmp = [lagmul(p[i], p[i+m]) for i in range(m)] - if n%2: + if r: tmp[0] = lagmul(tmp[0], p[-1]) p = tmp n = m diff --git a/numpy/polynomial/legendre.py b/numpy/polynomial/legendre.py index b76e678c2..9470865a8 100644 --- a/numpy/polynomial/legendre.py +++ b/numpy/polynomial/legendre.py @@ -315,12 +315,12 @@ def legfromroots(roots) : else : [roots] = pu.as_series([roots], trim=False) roots.sort() - n = len(roots) p = [legline(-r, 1) for r in roots] + n = len(p) while n > 1: - m = n//2 + m, r = divmod(n, 2) tmp = [legmul(p[i], p[i+m]) for i in range(m)] - if n%2: + if r: tmp[0] = legmul(tmp[0], p[-1]) p = tmp n = m diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index c8894c68e..7a5d3dbd5 100644 --- a/numpy/polynomial/polynomial.py +++ b/numpy/polynomial/polynomial.py @@ -187,12 +187,12 @@ def polyfromroots(roots) : else : [roots] = pu.as_series([roots], trim=False) roots.sort() - n = len(roots) p = [polyline(-r, 1) for r in roots] + n = len(p) while n > 1: - m = n//2 + m, r = divmod(n, 2) tmp = [polymul(p[i], p[i+m]) for i in range(m)] - if n%2: + if r: tmp[0] = polymul(tmp[0], p[-1]) p = tmp n = m |