cosmicds / hubbleds

Hubble's law data story
MIT License
0 stars 8 forks source link

Intermittent Dot plot zoom in error #617

Open patudom opened 1 month ago

patudom commented 1 month ago

On PR #604: this is not consistently reproducible, but 3 times now, I've gotten my dot plot into a state where the zoom in gets stuck. This tends to happen after I've been using the vertical marker line in the spectrum viewer that draws the corresponding line in the dot plot viewer. Here is a screenshot of what it looks like.

(The dotted gray line shows the zoom in range specified).

image

Terminal errors:


ERROR:solara.server.patch:Uncaught exception: Traceback (most recent call last):
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/ipywidgets/widgets/widget.py", line 222, in m
    return(method(self, *args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/ipywidgets/widgets/widget.py", line 773, in _handle_msg
    self.set_state(state)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/ipywidgets/widgets/widget.py", line 650, in set_state
    with self._lock_property(**sync_data), self.hold_trait_notifications():
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/traitlets/traitlets.py", line 1510, in hold_trait_notifications
    self.notify_change(change)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/ipywidgets/widgets/widget.py", line 701, in notify_change
    super().notify_change(change)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/traitlets/traitlets.py", line 1525, in notify_change
    return self._notify_observers(change)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/traitlets/traitlets.py", line 1568, in _notify_observers
    c(event)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/plotly/basewidget.py", line 719, in _handler_js2py_pointsCallback
    trace._dispatch_on_selection(points, selector)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/plotly/basedatatypes.py", line 6249, in _dispatch_on_selection
    callback(self, points, selector)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/glue_plotly/viewers/common/tools.py", line 53, in on_selection
    self._on_selection(trace, points, selector)
  File "/Users/Pat/Documents/GitHub/hubbleds/src/hubbleds/viewers/tools/wavelength_zoom.py", line 22, in _on_selection
    super()._on_selection(_trace, _points, selector)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/glue_plotly/viewers/common/tools.py", line 102, in _on_selection
    with self.viewer.figure.batch_update(), delay_callback(viewer_state, 'x_min', 'x_max'):
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/plotly/basedatatypes.py", line 3062, in batch_update
    self.plotly_update(
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/plotly/basedatatypes.py", line 2915, in plotly_update
    ) = self._perform_plotly_update(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/plotly/basedatatypes.py", line 2967, in _perform_plotly_update
    restyle_changes = self._perform_plotly_restyle(restyle_data, trace_indexes)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Pat/anaconda3/envs/common-solara/lib/python3.11/site-packages/plotly/basedatatypes.py", line 1735, in _perform_plotly_restyle
    raise ValueError(
ValueError: 
Invalid property path 'marker.size' for trace class Heatmap
patudom commented 1 month ago

@Carifio24, let us know if you have ideas on how to track this down.

patudom commented 1 month ago

Possible culprit - we noticed that the state of the zoom in tool button got out of sync with the state of the tool itself. The zoom button was in the "on" state, but the vertical line was in measurement mode rather than zoom mode.

johnarban commented 1 week ago

so @Carifio24 @patudom A little more info on what is happening here. Something is preventing on_selection from running in the tool.

A normal call sequence looks like

PlotlyHZoomMode.activate
PlotlySelectionMode.activate
PlotlyDragMode.activate
PlotlySelectionMode.on_selection
WavelengthZoom._on_selection
PlotlyHZoomMode._on_selection
PlotlySelectionMode.deactivate
PlotlyDragMode.deactivate

but instead what happens when it doesn't work is

PlotlyHZoomMode.activate
PlotlySelectionMode.activate
PlotlyDragMode.activate

I am not sure why, but this is the furthest I have gotten on this problem so far. I generated these by adding a print statement to all of the those Plotly tools.

There is no error emitted for me when it breaks.