Skip to content

Commit

Permalink
address comments, seperate in files and use newer react
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Jul 13, 2022
1 parent 802c039 commit 04148fb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 182 deletions.
9 changes: 4 additions & 5 deletions glue_jupyter/bqplot/common/reactviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def create_scale(viewer_state, name):
v_min, set_v_min = use_echo_state(viewer_state, f"{name}_min")
v_max, set_v_max = use_echo_state(viewer_state, f"{name}_max")
if is_log:
scale = bq.LogScale(min=v_min, max=v_max, allow_padding=False)
scale = bq.LogScale(min=v_min, max=v_max, allow_padding=False).shared()
else:
scale = bq.LinearScale(min=v_min, max=v_max, allow_padding=False)
scale = bq.LinearScale(min=v_min, max=v_max, allow_padding=False).shared()
return scale


Expand Down Expand Up @@ -76,7 +76,6 @@ def Figure(
]

show_axes, _ = use_echo_state(viewer_state, "show_axes")
# print(viewer_state)
axis_x = bq.Axis(scale=scale_x, grid_lines="none", label=label_x, visible=show_axes)
axis_y = bq.Axis(
scale=scale_y,
Expand Down Expand Up @@ -118,7 +117,7 @@ def initialize_figure(self):
self.figure_el = Figure(
self, self.state, is2d=self.is2d, components=self.components
)
self._figure: bqplot.Figure = react.render_fixed(self.figure_el)[0]
self._figure: bqplot.Figure = react.render_fixed(self.figure_el, handle_error=False)[0]
self.scale_x = self._figure.scale_x
self.scale_y = self._figure.scale_y
self.scales = {"x": self.scale_x, "y": self.scale_y}
Expand Down Expand Up @@ -226,4 +225,4 @@ def _callback_key(self, callback):
return (callback.__func__, (callback.__self__,))
elif isinstance(callback, partial):
return (callback.func, callback.args)
return callback
return callback
3 changes: 2 additions & 1 deletion glue_jupyter/bqplot/histogram/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .reacthistogram import * # noqa
from .layer_artist import * # noqa
from .viewer import * # noqa
173 changes: 0 additions & 173 deletions glue_jupyter/bqplot/histogram/reacthistogram.py

This file was deleted.

4 changes: 2 additions & 2 deletions glue_jupyter/common/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def cleanup():
state.add_callback(name, handler)
return cleanup

react.use_side_effect(add_event_handler)
react.use_effect(add_event_handler)

def set_value_sync(new_value):
setattr(
Expand All @@ -40,4 +40,4 @@ def cleanup():
viewer._layer_artist_container.on_changed(handler)
return cleanup

react.use_side_effect(hookup)
react.use_effect(hookup)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ install_requires =
bqplot-image-gl>=1.4.3
bqplot>=0.12.17
scikit-image
react-ipywidgets
react-ipywidgets>=0.11.0

[options.extras_require]
test =
Expand Down

0 comments on commit 04148fb

Please sign in to comment.