From 57702ac398e61f58a86f4cfd2965ed48a7f9ab95 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 17 Jun 2024 20:48:38 -0400 Subject: [PATCH 1/2] ndarray.ptp -> np.ptp for numpy v2 --- fastplotlib/widgets/histogram_lut.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastplotlib/widgets/histogram_lut.py b/fastplotlib/widgets/histogram_lut.py index a3edffcbd..02c21aa38 100644 --- a/fastplotlib/widgets/histogram_lut.py +++ b/fastplotlib/widgets/histogram_lut.py @@ -163,7 +163,7 @@ def _calculate_histogram(self, data): # used if data ptp <= 10 because event things get weird # with tiny world objects due to floating point error # so if ptp <= 10, scale up by a factor - self._scale_factor: int = max(1, 100 * int(10 / data_ss.ptp())) + self._scale_factor: int = max(1, 100 * int(10 / np.ptp(data_ss))) edges = edges * self._scale_factor From 46c685c347c2f7767f41ebf5719c623ba377af9e Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Wed, 26 Jun 2024 18:47:21 +0200 Subject: [PATCH 2/2] fix legend --- fastplotlib/legends/legend.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fastplotlib/legends/legend.py b/fastplotlib/legends/legend.py index 8ab3ddedb..df78d5662 100644 --- a/fastplotlib/legends/legend.py +++ b/fastplotlib/legends/legend.py @@ -56,10 +56,10 @@ def __init__( ) # for now only support lines with a single color - if np.unique(graphic.colors(), axis=0).shape[0] > 1: + if np.unique(graphic.colors.value, axis=0).shape[0] > 1: raise ValueError("Use colorbars for multi-colored lines, not legends") - color = pygfx.Color(np.unique(graphic.colors(), axis=0).ravel()) + color = pygfx.Color(np.unique(graphic.colors.value, axis=0).ravel()) self._parent = parent @@ -117,7 +117,7 @@ def label(self, text: str): self._label_world_object.geometry.set_text(text) def _update_color(self, ev: FeatureEvent): - new_color = ev.pick_info["new_data"] + new_color = ev.info["value"] if np.unique(new_color, axis=0).shape[0] > 1: raise ValueError( "LegendError: LineGraphic colors no longer appropriate for legend" @@ -126,8 +126,8 @@ def _update_color(self, ev: FeatureEvent): self._color = new_color[0] self._line_world_object.material.color = pygfx.Color(self._color) - def _highlight_graphic(self, graphic, ev): - graphic_color = pygfx.Color(np.unique(graphic.colors(), axis=0).ravel()) + def _highlight_graphic(self, graphic: Graphic, ev): + graphic_color = pygfx.Color(np.unique(graphic.colors.value, axis=0).ravel()) if graphic_color == self._parent.highlight_color: graphic.colors = self._color @@ -270,7 +270,7 @@ def add_graphic(self, graphic: Graphic, label: str = None): self._graphics.append(graphic) self._items[graphic._fpl_address] = legend_item - graphic.deleted.add_event_handler(partial(self.remove_graphic, graphic)) + graphic.add_event_handler(partial(self.remove_graphic, graphic), "deleted") self._col_counter = new_col_ix self._row_counter = new_row_ix