Skip to content

Commit 4b3bd27

Browse files
select_traces uses _selector_matches accepting function
1 parent b492497 commit 4b3bd27

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

packages/python/plotly/plotly/basedatatypes.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -804,19 +804,10 @@ def _perform_select_traces(self, filter_by_subplot, grid_subplot_refs, selector)
804804
continue
805805

806806
# Filter by selector
807-
# If selector is a dict, call self._selector_matches
808-
if type(selector) == type(dict()):
809-
trace_matches = self._selector_matches(trace, selector)
810-
# If selector is a function, call it with the trace as the argument
811-
elif type(selector) == type(lambda x: True):
812-
trace_matches = selector(trace)
813-
else:
814-
raise TypeError(
815-
"selector must be dict or a function "
816-
"accepting a trace returning a boolean."
817-
)
818-
if trace_matches:
819-
yield trace
807+
if not self._selector_matches(trace, selector):
808+
continue
809+
810+
yield trace
820811

821812
@staticmethod
822813
def _selector_matches(obj, selector):

0 commit comments

Comments
 (0)