diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-03-21 21:59:18 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-03-21 21:59:18 +0000 |
commit | 3c4f17b7d6d44b3076be9d50e305ed71836fa5d9 (patch) | |
tree | 3388e99f2cb08d22c29f714641a9a9a17c0cb83f /numpy/lib/tests/test_polynomial.py | |
parent | 0ea21d1092c9154d72d50b04ba2c8025704c679f (diff) | |
download | numpy-3c4f17b7d6d44b3076be9d50e305ed71836fa5d9.tar.gz |
TST: Prove that poly1d coeffs are immutable
Remove the comment suggesting that they are not
Diffstat (limited to 'numpy/lib/tests/test_polynomial.py')
-rw-r--r-- | numpy/lib/tests/test_polynomial.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py index f1e4543bb..0725c186d 100644 --- a/numpy/lib/tests/test_polynomial.py +++ b/numpy/lib/tests/test_polynomial.py @@ -222,6 +222,20 @@ class TestDocs(TestCase): assert_equal(p == p2, False) assert_equal(p != p2, True) + def test_poly_coeffs_immutable(self): + """ Coefficients should not be modifiable """ + p = np.poly1d([1, 2, 3]) + + try: + # despite throwing an exception, this used to change state + p.coeffs += 1 + except Exception: + pass + assert_equal(p.coeffs, [1, 2, 3]) + + p.coeffs[2] += 10 + assert_equal(p.coeffs, [1, 2, 3]) + if __name__ == "__main__": run_module_suite() |