Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Polynomials now copy properly (#22669) #22866

Merged
merged 2 commits into from Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/polynomial/_polybase.py
Expand Up @@ -499,7 +499,7 @@ def __getstate__(self):
ret['coef'] = self.coef.copy()
ret['domain'] = self.domain.copy()
ret['window'] = self.window.copy()
ret['symbol'] = self.symbol.copy()
ret['symbol'] = self.symbol
return ret

def __setstate__(self, dict):
Expand Down
11 changes: 11 additions & 0 deletions numpy/polynomial/tests/test_polynomial.py
Expand Up @@ -5,6 +5,8 @@

import numpy as np
import numpy.polynomial.polynomial as poly
import pickle
from copy import deepcopy
from numpy.testing import (
assert_almost_equal, assert_raises, assert_equal, assert_,
assert_warns, assert_array_equal, assert_raises_regex)
Expand Down Expand Up @@ -41,6 +43,15 @@ def test_polyone(self):
def test_polyx(self):
assert_equal(poly.polyx, [0, 1])

def test_copy(self):
x = poly.Polynomial([1, 2, 3])
y = deepcopy(x)
assert_equal(x, y)

def test_pickle(self):
x = poly.Polynomial([1, 2, 3])
y = pickle.loads(pickle.dumps(x))
assert_equal(x, y)

class TestArithmetic:

Expand Down