Skip to content

Commit

Permalink
Initialize trace metadata IDs to avoid trace-getting methods picking …
Browse files Browse the repository at this point in the history
…up other traces (like those added by tools).
  • Loading branch information
Carifio24 committed May 10, 2024
1 parent 98f5e10 commit 05d26d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion glue_plotly/viewers/histogram/dotplot_layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# normalized mode, as a dotplot only makes sense when the heights are integral.

import numpy as np
from uuid import uuid4

from glue.core.exceptions import IncompatibleAttribute
from glue.viewers.common.layer_artist import LayerArtist
Expand Down Expand Up @@ -35,7 +36,7 @@ def __init__(self, view, viewer_state, layer_state=None, layer=None):

self.view = view
self.bins = None
self._dots_id = None
self._dots_id = uuid4().hex

Check warning on line 39 in glue_plotly/viewers/histogram/dotplot_layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/histogram/dotplot_layer_artist.py#L39

Added line #L39 was not covered by tests

self._viewer_state.add_global_callback(self._update_dotplot)
self.state.add_global_callback(self._update_dotplot)
Expand Down
3 changes: 2 additions & 1 deletion glue_plotly/viewers/histogram/layer_artist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
from uuid import uuid4

from glue.core.exceptions import IncompatibleAttribute
from glue.viewers.common.layer_artist import LayerArtist
Expand Down Expand Up @@ -30,7 +31,7 @@ def __init__(self, view, viewer_state, layer_state=None, layer=None):

self.view = view
self.bins = None
self._bars_id = None
self._bars_id = uuid4().hex

Check warning on line 34 in glue_plotly/viewers/histogram/layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/histogram/layer_artist.py#L34

Added line #L34 was not covered by tests

self._viewer_state.add_global_callback(self._update_histogram)
self.state.add_global_callback(self._update_histogram)
Expand Down
10 changes: 7 additions & 3 deletions glue_plotly/viewers/scatter/layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ def __init__(self, view, viewer_state, layer_state=None, layer=None):
scatter = self._create_scatter()
self.view.figure.add_trace(scatter)

self._lines_id = None
self._error_id = None
self._vector_id = None
# We want to initialize these to some dummy UUIDs so that
# _get_lines, _get_error_bars, _get_vectors, etc. don't pick up
# any other traces that tools have added to the viewer, which
# will happen if these IDs are None
self._lines_id = uuid4().hex
self._error_id = uuid4().hex
self._vector_id = uuid4().hex

Check warning on line 93 in glue_plotly/viewers/scatter/layer_artist.py

View check run for this annotation

Codecov / codecov/patch

glue_plotly/viewers/scatter/layer_artist.py#L91-L93

Added lines #L91 - L93 were not covered by tests

def remove(self):
self.view._remove_traces([self._get_scatter()])
Expand Down

0 comments on commit 05d26d8

Please sign in to comment.