Skip to content

Commit

Permalink
Merge pull request #22670 from MatteoRaso/master
Browse files Browse the repository at this point in the history
BUG: Polynomials now copy properly (#22669)
  • Loading branch information
mattip committed Nov 27, 2022
2 parents f07bb7a + ab24072 commit 343fae6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit 343fae6

Please sign in to comment.