summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2009-11-28 19:43:32 +0000
committerCharles Harris <charlesr.harris@gmail.com>2009-11-28 19:43:32 +0000
commitdb2d4b5fe5e2325ac9d21fba27825c74eff8384f (patch)
tree37408ba2690be745149b7a80270cf0cc0d9329b4
parentf9d1cd5265b013042b5909adf92ca5ea168aaee3 (diff)
downloadnumpy-db2d4b5fe5e2325ac9d21fba27825c74eff8384f.tar.gz
Small cleanups in polynomial modules.
-rw-r--r--numpy/polynomial/polyutils.py14
-rw-r--r--numpy/polynomial/tests/test_chebyshev.py2
-rw-r--r--numpy/polynomial/tests/test_polynomial.py2
3 files changed, 10 insertions, 8 deletions
diff --git a/numpy/polynomial/polyutils.py b/numpy/polynomial/polyutils.py
index e81275e91..25fd012d6 100644
--- a/numpy/polynomial/polyutils.py
+++ b/numpy/polynomial/polyutils.py
@@ -35,6 +35,7 @@ __all__ = ['RankWarning', 'PolyError', 'PolyDomainError', 'PolyBase',
import warnings, exceptions
import numpy as np
+import sys
#
# Warnings and Exceptions
@@ -67,11 +68,12 @@ class PolyBase(object) :
#
# We need the any function for python < 2.5
#
-def any(iterable) :
- for element in iterable:
- if element :
- return True
- return False
+if sys.version_info[:2] < (2,5) :
+ def any(iterable) :
+ for element in iterable:
+ if element :
+ return True
+ return False
#
# Helper functions to convert inputs to 1d arrays
@@ -135,7 +137,7 @@ def as_series(alist, trim=True) :
arrays = [np.array(a, ndmin=1, copy=0) for a in alist]
if min([a.size for a in arrays]) == 0 :
raise ValueError("Coefficient array is empty")
- if max([a.ndim for a in arrays]) > 1 :
+ if any([a.ndim != 1 for a in arrays]) :
raise ValueError("Coefficient array is not 1-d")
if trim :
arrays = [trimseq(a) for a in arrays]
diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py
index 969125ff3..793458096 100644
--- a/numpy/polynomial/tests/test_chebyshev.py
+++ b/numpy/polynomial/tests/test_chebyshev.py
@@ -105,7 +105,7 @@ class TestArithmetic(TestCase) :
return x*(x**2 - 1)
#check empty input
- assert_equal(ch.chebval([], 1).size, 0)
+ assert_equal(ch.chebval([], [1]).size, 0)
#check normal input)
for i in range(5) :
diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py
index 1e63cc86d..d4baaea8a 100644
--- a/numpy/polynomial/tests/test_polynomial.py
+++ b/numpy/polynomial/tests/test_polynomial.py
@@ -97,7 +97,7 @@ class TestArithmetic(TestCase) :
return x*(x**2 - 1)
#check empty input
- assert_equal(poly.polyval([], 1).size, 0)
+ assert_equal(poly.polyval([], [1]).size, 0)
#check normal input)
x = np.linspace(-1,1)