Skip to content

Commit

Permalink
Merge pull request #62 from Carifio24/init-all-ids
Browse files Browse the repository at this point in the history
Initialize all trace metadata IDs
  • Loading branch information
Carifio24 authored May 10, 2024
2 parents 6dde829 + 05d26d8 commit 0f8f7e5
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

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

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

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

0 comments on commit 0f8f7e5

Please sign in to comment.