Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit eff3a3e

Browse files
committed
♻️ avoid deepcopy of dict in validate_coerce
1 parent 4363c51 commit eff3a3e

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

‎packages/python/plotly/_plotly_utils/basevalidators.py‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from importlib import import_module
88
import copy
99
import io
10-
from copy import deepcopy
1110
import re
1211
import sys
1312

@@ -2626,10 +2625,6 @@ def get_trace_class(self, trace_name):
26262625
def validate_coerce(self, v, skip_invalid=False, _validate=True):
26272626
from plotly.basedatatypes import BaseTraceType
26282627

2629-
# Import Histogram2dcontour, this is the deprecated name of the
2630-
# Histogram2dContour trace.
2631-
from plotly.graph_objs import Histogram2dcontour
2632-
26332628
if v is None:
26342629
v = []
26352630
else:
@@ -2645,30 +2640,28 @@ def validate_coerce(self, v, skip_invalid=False, _validate=True):
26452640
v_el = v_el.to_plotly_json()
26462641

26472642
if isinstance(v_el, dict):
2648-
v_copy = deepcopy(v_el)
2649-
2650-
if "type" in v_copy:
2651-
trace_type = v_copy.pop("type")
2652-
elif isinstance(v_el, Histogram2dcontour):
2653-
trace_type = "histogram2dcontour"
2654-
else:
2655-
trace_type = "scatter"
2643+
type_in_v_el = "type" in v_el
2644+
trace_type = v_el.pop("type", "scatter")
26562645

26572646
if trace_type not in self.class_strs_map:
26582647
if skip_invalid:
26592648
# Treat as scatter trace
26602649
trace = self.get_trace_class("scatter")(
2661-
skip_invalid=skip_invalid, _validate=_validate, **v_copy
2650+
skip_invalid=skip_invalid, _validate=_validate, **v_el
26622651
)
26632652
res.append(trace)
26642653
else:
26652654
res.append(None)
26662655
invalid_els.append(v_el)
26672656
else:
26682657
trace = self.get_trace_class(trace_type)(
2669-
skip_invalid=skip_invalid, _validate=_validate, **v_copy
2658+
skip_invalid=skip_invalid, _validate=_validate, **v_el
26702659
)
26712660
res.append(trace)
2661+
2662+
if type_in_v_el:
2663+
# Restore type in v_el
2664+
v_el["type"] = trace_type
26722665
else:
26732666
if skip_invalid:
26742667
# Add empty scatter trace

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /