summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_polynomial.py
diff options
context:
space:
mode:
authorjaimefrio <jaime.frio@gmail.com>2014-09-25 10:45:08 -0700
committerjaimefrio <jaime.frio@gmail.com>2014-09-25 10:49:16 -0700
commit3a0587e545e959747d9b501dbf029a4cd6576547 (patch)
treee6cb41c3c6f67240a28690241b5a6d0e8e84aa2d /numpy/lib/tests/test_polynomial.py
parentf4fa7bd2a67a577eaa72af83028adcfbc71b7fd4 (diff)
downloadnumpy-3a0587e545e959747d9b501dbf029a4cd6576547.tar.gz
ENH: Cast non-object arrays to float in np.poly
Closes #5096. Casts integer arrays to np.double, to prevent integer overflow. Object arrays are left unchanged, to allow use of arbitrary precision objects.
Diffstat (limited to 'numpy/lib/tests/test_polynomial.py')
-rw-r--r--numpy/lib/tests/test_polynomial.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py
index 02faa0283..5c15941e6 100644
--- a/numpy/lib/tests/test_polynomial.py
+++ b/numpy/lib/tests/test_polynomial.py
@@ -153,6 +153,9 @@ class TestDocs(TestCase):
assert_(p2[3] == Decimal("1.333333333333333333333333333"))
assert_(p2[2] == Decimal('1.5'))
assert_(np.issubdtype(p2.coeffs.dtype, np.object_))
+ p = np.poly([Decimal(1), Decimal(2)])
+ assert_equal(np.poly([Decimal(1), Decimal(2)]),
+ [1, Decimal(-3), Decimal(2)])
def test_complex(self):
p = np.poly1d([3j, 2j, 1j])
@@ -173,5 +176,13 @@ class TestDocs(TestCase):
except ValueError:
pass
+ def test_poly_int_overflow(self):
+ """
+ Regression test for gh-5096.
+ """
+ v = np.arange(1, 21)
+ assert_almost_equal(np.poly(v), np.poly(np.diag(v)))
+
+
if __name__ == "__main__":
run_module_suite()