From df3e16ca293ed7a384ba174bfddd0e6ec6147491 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Sun, 16 Mar 2025 22:14:55 -0400 Subject: [PATCH 1/2] fix comment, fix doc example readme file --- examples/window_layouts/README.rst | 4 ++-- fastplotlib/layouts/_plot_area.py | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/window_layouts/README.rst b/examples/window_layouts/README.rst index 3c7df2366..23684627b 100644 --- a/examples/window_layouts/README.rst +++ b/examples/window_layouts/README.rst @@ -1,2 +1,2 @@ -WindowLayout Examples -===================== +Window Layout Examples +====================== diff --git a/fastplotlib/layouts/_plot_area.py b/fastplotlib/layouts/_plot_area.py index 2e69af100..e780607ce 100644 --- a/fastplotlib/layouts/_plot_area.py +++ b/fastplotlib/layouts/_plot_area.py @@ -87,12 +87,10 @@ def __init__( self._animate_funcs_pre: list[callable] = list() self._animate_funcs_post: list[callable] = list() - # list of hex id strings for all graphics managed by this PlotArea - # the real Graphic instances are managed by REFERENCES + # list of all graphics managed by this PlotArea self._graphics: list[Graphic] = list() # selectors are in their own list so they can be excluded from scene bbox calculations - # managed similar to GRAPHICS for garbage collection etc. self._selectors: list[BaseSelector] = list() # legends, managed just like other graphics as explained above From cf51ffb3ab6865d496b5b4c506e3790dc0956e32 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 17 Mar 2025 01:50:57 -0400 Subject: [PATCH 2/2] update get_cmap_texture to return pygfx.Texture since cmap lib changed --- fastplotlib/utils/functions.py | 2 +- tests/test_image_graphic.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fastplotlib/utils/functions.py b/fastplotlib/utils/functions.py index 910eba8e8..6ad365e40 100644 --- a/fastplotlib/utils/functions.py +++ b/fastplotlib/utils/functions.py @@ -205,7 +205,7 @@ def make_colors(n_colors: int, cmap: str, alpha: float = 1.0) -> np.ndarray: def get_cmap_texture(name: str, alpha: float = 1.0) -> Texture: - return cmap_lib.Colormap(name).to_pygfx() + return Texture(get_cmap(name, alpha), dim=1) def make_colors_dict(labels: Sequence, cmap: str, **kwargs) -> OrderedDict: diff --git a/tests/test_image_graphic.py b/tests/test_image_graphic.py index 0ea9979a6..02b982d80 100644 --- a/tests/test_image_graphic.py +++ b/tests/test_image_graphic.py @@ -2,6 +2,8 @@ from numpy import testing as npt import imageio.v3 as iio +import pygfx + import fastplotlib as fpl from fastplotlib.graphics._features import FeatureEvent from fastplotlib.utils import make_colors @@ -86,6 +88,10 @@ def test_gray(): # the entire image should be in the single Texture buffer npt.assert_almost_equal(ig.data.buffer[0, 0].data, GRAY_IMAGE) + assert isinstance(ig._material, pygfx.ImageBasicMaterial) + assert isinstance(ig._material.map, pygfx.TextureMap) + assert isinstance(ig._material.map.texture, pygfx.Texture) + ig.cmap = "viridis" assert ig.cmap == "viridis" check_event(graphic=ig, feature="cmap", value="viridis")