diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-04-24 20:31:22 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-04-24 20:31:22 +0000 |
commit | 1a613e1c460d2e7756724b7e5c638c95519ee498 (patch) | |
tree | 31ce56bc09e829271899c784e70f6b2c80eeebbc /numpy/lib/tests/test_polynomial.py | |
parent | 653d2b27fbe3771d7b669da0aec62a0cdb0654ac (diff) | |
download | numpy-1a613e1c460d2e7756724b7e5c638c95519ee498.tar.gz |
Fixed #1095: make polyint work well with object arrays
Diffstat (limited to 'numpy/lib/tests/test_polynomial.py')
-rw-r--r-- | numpy/lib/tests/test_polynomial.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py index 96dd084b2..45e68d248 100644 --- a/numpy/lib/tests/test_polynomial.py +++ b/numpy/lib/tests/test_polynomial.py @@ -110,6 +110,29 @@ class TestDocs(TestCase): cc = np.concatenate((c,c), axis=1) assert_almost_equal(cc, np.polyfit(x,yy,2)) + def test_objects(self): + from decimal import Decimal + p = np.poly1d([Decimal('4.0'), Decimal('3.0'), Decimal('2.0')]) + p2 = p * Decimal('1.333333333333333') + assert p2[1] == Decimal("3.9999999999999990") + p2 = p.deriv() + assert p2[1] == Decimal('8.0') + p2 = p.integ() + assert p2[3] == Decimal("1.333333333333333333333333333") + assert p2[2] == Decimal('1.5') + assert np.issubdtype(p2.coeffs.dtype, np.object_) + + def test_complex(self): + p = np.poly1d([3j, 2j, 1j]) + p2 = p.integ() + assert (p2.coeffs == [1j,1j,1j,0]).all() + p2 = p.deriv() + 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() if __name__ == "__main__": run_module_suite() |