Skip to content

Can't copy.deepcopy a Plotly figure #1165

Closed
@rmarren1

Description

@rmarren1

This does not work:

>>> from copy import deepcopy
>>> import plotly.graph_objs as go
>>> figure = go.Figure(data=[go.Scatter(x=[1,2,3], y=[1,2,3])], layout=go.Layout())
>>> deepcopy(figure)

and gives the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/copy.py", line 281, in _reconstruct
    if hasattr(y, '__setstate__'):
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3537, in __getattr__
    if prop in self._subplotid_props:
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3537, in __getattr__
    if prop in self._subplotid_props:
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3537, in __getattr__
    if prop in self._subplotid_props:
  [Previous line repeated 490 more times]
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3536, in __getattr__
    prop = self._strip_subplot_suffix_of_1(prop)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 3504, in _strip_subplot_suffix_of_1
    prop_tuple = BaseFigure._str_to_dict_path(prop)
  File "/home/ryan/.virtualenvs/dash-3.7/lib/python3.7/site-packages/plotly/basedatatypes.py", line 745, in _str_to_dict_path
    if isinstance(key_path_str, string_types) and \
RecursionError: maximum recursion depth exceeded while calling a Python object

I am using plotly==3.1.0 and Python==3.7.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions