-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
BUG: deep copying polybase broken #22669
Copy link
Copy link
Closed
Labels
Milestone
Description
Describe the issue:
The issue is at line 502 in _polybase.py:
ret['symbol'] = self.symbol.copy()
Pronblem is that self.symbol is a string and has no copy method. Instead should be assigned directly as it is immutable:
ret['symbol'] = self.symbol
Reproduce the code example:
>>> from numpy.polynomial import Polynomial
>>> x = Polynomial([1, 2, 3])
>>> from copy import deepcopy
>>> deepcopy(x)Error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/copy.py", line 161, in deepcopy
rv = reductor(4)
File "/hdd/tmp/tempvenv/lib/python3.8/site-packages/numpy/polynomial/_polybase.py", line 502, in __getstate__
ret['symbol'] = self.symbol.copy()
AttributeError: 'str' object has no attribute 'copy'NumPy/Python version information:
1.24.0rc1 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0]
Context for the issue:
Easy fix in the bug description.
Reactions are currently unavailable