Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
A deepcopy of aFigure
object results inValueError: 'Spines' object does not contain a '__deepcopy__' spine
.
This issue surfaced in a bug report ofschemdraw
:https://bitbucket.org/cdelker/schemdraw/issues/56/copydeepcopy-drawing-fails Nevertheless, the current issue is unrelated toschemdraw
. I'm just mentioning this to illustrate a relevant use case leading to this problem.
Code for reproduction
importmatplotlib.pyplotaspltimportcopyfig,ax=plt.subplots()copy.deepcopy(fig)
Disclaimer: this is taken from a message ofcdelker
onhttps://bitbucket.org/cdelker/schemdraw/issues/56/copydeepcopy-drawing-fails
Actual outcome
Traceback (most recent call last): File "/usr/lib64/python3.9/site-packages/matplotlib/spines.py", line 551, in __getattr__ return self._dict[name]KeyError: '__deepcopy__'During handling of the above exception, another exception occurred:Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.9/copy.py", line 172, in deepcopy y = _reconstruct(x, memo, *rv) File "/usr/lib64/python3.9/copy.py", line 270, in _reconstruct state = deepcopy(state, memo) File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "/usr/lib64/python3.9/copy.py", line 230, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib64/python3.9/copy.py", line 172, in deepcopy y = _reconstruct(x, memo, *rv) File "/usr/lib64/python3.9/copy.py", line 270, in _reconstruct state = deepcopy(state, memo) File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "/usr/lib64/python3.9/copy.py", line 230, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "/usr/lib64/python3.9/copy.py", line 205, in _deepcopy_list append(deepcopy(a, memo)) File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "/usr/lib64/python3.9/copy.py", line 210, in _deepcopy_tuple y = [deepcopy(a, memo) for a in x] File "/usr/lib64/python3.9/copy.py", line 210, in <listcomp> y = [deepcopy(a, memo) for a in x] File "/usr/lib64/python3.9/copy.py", line 172, in deepcopy y = _reconstruct(x, memo, *rv) File "/usr/lib64/python3.9/copy.py", line 270, in _reconstruct state = deepcopy(state, memo) File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy y = copier(x, memo) File "/usr/lib64/python3.9/copy.py", line 230, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(value, memo) File "/usr/lib64/python3.9/copy.py", line 151, in deepcopy copier = getattr(x, "__deepcopy__", None) File "/usr/lib64/python3.9/site-packages/matplotlib/spines.py", line 553, in __getattr__ raise ValueError(ValueError: 'Spines' object does not contain a '__deepcopy__' spine
Expected outcome
Either a deepcopy of the figure or a meaningful error message explaining that this operation is not supported.
Operating system
Fedora Linux
Matplotlib Version
3.4.3
Matplotlib Backend
Qt5Agg
Python version
3.9.7
Jupyter version
6.1.6, (not installed)
Other libraries
None
Installation
Linux package manager (Debian/Fedora/etc.)
Conda channel
No response