Skip to content

Commit

Permalink
Merge pull request #3817 from wf-r/selector_0_fix
Browse files Browse the repository at this point in the history
FIX selector = 0 returns all traces in select_traces
  • Loading branch information
nicolaskruchten authored Jan 4, 2023
2 parents 5cc3c81 + fb7bd75 commit a8a0c9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/python/plotly/plotly/basedatatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ def select_traces(self, selector=None, row=None, col=None, secondary_y=None):
Generator that iterates through all of the traces that satisfy
all of the specified selection criteria
"""
if not selector:
if not selector and not isinstance(selector, int):
selector = {}

if row is not None or col is not None or secondary_y is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ def select_traces_fixture():

def test_select_traces_integer(select_traces_fixture):
fig = select_traces_fixture
# check that selecting first trace does indeed only select the first
tr = list(fig.select_traces(selector=0))
assert len(tr) == 1
assert tr[0].y[1] == 0
# check we can index last trace selected
tr = list(fig.select_traces(selector=-1))[0]
assert tr.y[1] == 20
Expand Down

0 comments on commit a8a0c9b

Please sign in to comment.