From f64ff43b2adca4d9e78a8ca18bf21feaac76881d Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 15:27:47 -0500 Subject: [PATCH 01/19] add size_space to pygfx.PointsMaterial kwargs --- fastplotlib/graphics/scatter.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fastplotlib/graphics/scatter.py b/fastplotlib/graphics/scatter.py index 39d815c95..8f0d73df4 100644 --- a/fastplotlib/graphics/scatter.py +++ b/fastplotlib/graphics/scatter.py @@ -21,6 +21,7 @@ def __init__( isolated_buffer: bool = True, sizes: float | np.ndarray | Iterable[float] = 1, uniform_size: bool = False, + size_space: str = "screen", **kwargs, ): """ @@ -60,6 +61,9 @@ def __init__( if True, uses a uniform buffer for the scatter point sizes, basically saves GPU VRAM when all scatter points are the same size + size_space: str, default "screen" + coordinate space in which the size is expressed (‘screen’, ‘world’, ‘model’) + kwargs passed to Graphic @@ -97,6 +101,8 @@ def __init__( self._sizes = PointsSizesFeature(sizes, n_datapoints=n_datapoints) geo_kwargs["sizes"] = self.sizes.buffer + material_kwargs['size_space'] = size_space + world_object = pygfx.Points( pygfx.Geometry(**geo_kwargs), material=pygfx.PointsMaterial(**material_kwargs), From 7edc00743d0e9f820d0121cf8a917fc10233bd35 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 16:26:51 -0500 Subject: [PATCH 02/19] add CoordSpace graphic feature --- .../graphics/_features/_positions_graphics.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fastplotlib/graphics/_features/_positions_graphics.py b/fastplotlib/graphics/_features/_positions_graphics.py index ee7927a36..80946ab47 100644 --- a/fastplotlib/graphics/_features/_positions_graphics.py +++ b/fastplotlib/graphics/_features/_positions_graphics.py @@ -182,6 +182,24 @@ def set_value(self, graphic, value: float | int): self._call_event_handlers(event) +# manages the coordinate space for scatter +class CoordSpace(GraphicFeature): + def __init__(self, value): + self._value = str(value) + super().__init__() + + @property + def value(self) -> str: + return self._value + + def set_value(self, graphic, value: str): + graphic.world_object.material.size_space = str(value) + self._value = value + + event = FeatureEvent(type="sizes", info={"value": value}) + self._call_event_handlers(event) + + class VertexPositions(BufferManager): """ +----------+----------------------------------------------------------+------------------------------------------------------------------------------------------+ From 83f3c179f438f89e0fc97daf39cf4a1fe7a32fe0 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 16:27:07 -0500 Subject: [PATCH 03/19] store _coord_space graphic feature --- fastplotlib/graphics/scatter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastplotlib/graphics/scatter.py b/fastplotlib/graphics/scatter.py index 8f0d73df4..afa4c20cc 100644 --- a/fastplotlib/graphics/scatter.py +++ b/fastplotlib/graphics/scatter.py @@ -4,7 +4,7 @@ import pygfx from ._positions_base import PositionsGraphic -from ._features import PointsSizesFeature, UniformSize +from ._features import PointsSizesFeature, UniformSize, CoordSpace class ScatterGraphic(PositionsGraphic): @@ -101,6 +101,7 @@ def __init__( self._sizes = PointsSizesFeature(sizes, n_datapoints=n_datapoints) geo_kwargs["sizes"] = self.sizes.buffer + self._coord_space = CoordSpace(size_space) material_kwargs['size_space'] = size_space world_object = pygfx.Points( From 113ff684df2ab1ddc0e4ad204d13f4badb3a63f3 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 16:30:21 -0500 Subject: [PATCH 04/19] add coordspace to features init --- fastplotlib/graphics/_features/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fastplotlib/graphics/_features/__init__.py b/fastplotlib/graphics/_features/__init__.py index 4f9013425..dfeed96bd 100644 --- a/fastplotlib/graphics/_features/__init__.py +++ b/fastplotlib/graphics/_features/__init__.py @@ -2,6 +2,7 @@ VertexColors, UniformColor, UniformSize, + CoordSpace, Thickness, VertexPositions, PointsSizesFeature, @@ -42,6 +43,7 @@ "VertexColors", "UniformColor", "UniformSize", + "CoordSpace", "Thickness", "VertexPositions", "PointsSizesFeature", From e54b9289a9aa7b480fcd5c0c898a6772b151660c Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 16:55:08 -0500 Subject: [PATCH 05/19] make size_space a property of PositionsGraphic --- fastplotlib/graphics/_positions_base.py | 13 +++++++++++++ fastplotlib/graphics/scatter.py | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/_positions_base.py b/fastplotlib/graphics/_positions_base.py index 3727087cc..be677fba4 100644 --- a/fastplotlib/graphics/_positions_base.py +++ b/fastplotlib/graphics/_positions_base.py @@ -54,6 +54,17 @@ def cmap(self, name: str): self._cmap[:] = name + @property + def size_space(self): + """ + The coordinate space in which the size is expressed (‘screen’, ‘world’, ‘model’) + """ + return self._size_space + + @size_space.setter + def size_space(self, value: str): + self._size_space = value + def __init__( self, data: Any, @@ -63,6 +74,7 @@ def __init__( cmap: str | VertexCmap = None, cmap_transform: np.ndarray = None, isolated_buffer: bool = True, + size_space: str = "screen", *args, **kwargs, ): @@ -132,6 +144,7 @@ def __init__( self._colors, cmap_name=None, transform=None, alpha=alpha ) + self._size_space = size_space super().__init__(*args, **kwargs) def unshare_property(self, property: str): diff --git a/fastplotlib/graphics/scatter.py b/fastplotlib/graphics/scatter.py index afa4c20cc..4b38f3f2a 100644 --- a/fastplotlib/graphics/scatter.py +++ b/fastplotlib/graphics/scatter.py @@ -77,6 +77,7 @@ def __init__( cmap=cmap, cmap_transform=cmap_transform, isolated_buffer=isolated_buffer, + size_space=size_space, **kwargs, ) @@ -101,9 +102,7 @@ def __init__( self._sizes = PointsSizesFeature(sizes, n_datapoints=n_datapoints) geo_kwargs["sizes"] = self.sizes.buffer - self._coord_space = CoordSpace(size_space) material_kwargs['size_space'] = size_space - world_object = pygfx.Points( pygfx.Geometry(**geo_kwargs), material=pygfx.PointsMaterial(**material_kwargs), From 77f4c4043a815f7a7d55a1016ef78e4f6ba42665 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 17:17:19 -0500 Subject: [PATCH 06/19] rename CoordSpace->SizeSpace for consistency / avoid confusion with pygfx.CoordSpace --- fastplotlib/graphics/_features/__init__.py | 4 ++-- fastplotlib/graphics/_features/_positions_graphics.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fastplotlib/graphics/_features/__init__.py b/fastplotlib/graphics/_features/__init__.py index dfeed96bd..a1915bbe9 100644 --- a/fastplotlib/graphics/_features/__init__.py +++ b/fastplotlib/graphics/_features/__init__.py @@ -2,7 +2,7 @@ VertexColors, UniformColor, UniformSize, - CoordSpace, + SizeSpace, Thickness, VertexPositions, PointsSizesFeature, @@ -43,7 +43,7 @@ "VertexColors", "UniformColor", "UniformSize", - "CoordSpace", + "SizeSpace", "Thickness", "VertexPositions", "PointsSizesFeature", diff --git a/fastplotlib/graphics/_features/_positions_graphics.py b/fastplotlib/graphics/_features/_positions_graphics.py index 80946ab47..5ff4d8a0d 100644 --- a/fastplotlib/graphics/_features/_positions_graphics.py +++ b/fastplotlib/graphics/_features/_positions_graphics.py @@ -183,7 +183,7 @@ def set_value(self, graphic, value: float | int): # manages the coordinate space for scatter -class CoordSpace(GraphicFeature): +class SizeSpace(GraphicFeature): def __init__(self, value): self._value = str(value) super().__init__() From 9ff2abc99032ee4707e3aceb14e93ee433a6d60d Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 17:28:40 -0500 Subject: [PATCH 07/19] fix size_space feature, FeatureEvent type=size_space?? --- fastplotlib/graphics/_features/_positions_graphics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/_features/_positions_graphics.py b/fastplotlib/graphics/_features/_positions_graphics.py index 5ff4d8a0d..f1c773c6d 100644 --- a/fastplotlib/graphics/_features/_positions_graphics.py +++ b/fastplotlib/graphics/_features/_positions_graphics.py @@ -184,7 +184,7 @@ def set_value(self, graphic, value: float | int): # manages the coordinate space for scatter class SizeSpace(GraphicFeature): - def __init__(self, value): + def __init__(self, value: str): self._value = str(value) super().__init__() @@ -196,7 +196,7 @@ def set_value(self, graphic, value: str): graphic.world_object.material.size_space = str(value) self._value = value - event = FeatureEvent(type="sizes", info={"value": value}) + event = FeatureEvent(type="size_space", info={"value": value}) self._call_event_handlers(event) From b398b7268d984c7420546dd0ef377b8fe672c1fa Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 17:29:06 -0500 Subject: [PATCH 08/19] add getters/setters to scatter/line graphics --- fastplotlib/graphics/line.py | 22 ++++++++++++++++++++-- fastplotlib/graphics/scatter.py | 13 +++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/fastplotlib/graphics/line.py b/fastplotlib/graphics/line.py index 1574587fe..a56389f4f 100644 --- a/fastplotlib/graphics/line.py +++ b/fastplotlib/graphics/line.py @@ -6,7 +6,7 @@ from ._positions_base import PositionsGraphic from .selectors import LinearRegionSelector, LinearSelector, RectangleSelector -from ._features import Thickness +from ._features import Thickness, SizeSpace class LineGraphic(PositionsGraphic): @@ -22,6 +22,7 @@ def __init__( cmap: str = None, cmap_transform: np.ndarray | Iterable = None, isolated_buffer: bool = True, + size_space: str = "screen", **kwargs, ): """ @@ -53,6 +54,9 @@ def __init__( cmap_transform: 1D array-like of numerical values, optional if provided, these values are used to map the colors from the cmap + size_space: str, default "screen" + coordinate space in which the size is expressed (‘screen’, ‘world’, ‘model’) + **kwargs passed to Graphic @@ -66,10 +70,12 @@ def __init__( cmap=cmap, cmap_transform=cmap_transform, isolated_buffer=isolated_buffer, + size_space=size_space, **kwargs, ) self._thickness = Thickness(thickness) + self._size_space = SizeSpace(size_space) if thickness < 1.1: MaterialCls = pygfx.LineThinMaterial @@ -83,10 +89,14 @@ def __init__( color_mode="uniform", color=self.colors, pick_write=True, + thickness_space=self.size_space, ) else: material = MaterialCls( - thickness=self.thickness, color_mode="vertex", pick_write=True + thickness=self.thickness, + color_mode="vertex", + pick_write=True, + thickness_space=self.size_space ) geometry = pygfx.Geometry( positions=self._data.buffer, colors=self._colors.buffer @@ -96,6 +106,14 @@ def __init__( self._set_world_object(world_object) + @property + def size_space(self) -> str: + return self._size_space.value + + @size_space.setter + def size_space(self, value: str): + self._size_space.set_value(self, value) + @property def thickness(self) -> float: """line thickness""" diff --git a/fastplotlib/graphics/scatter.py b/fastplotlib/graphics/scatter.py index 4b38f3f2a..5313ba4fb 100644 --- a/fastplotlib/graphics/scatter.py +++ b/fastplotlib/graphics/scatter.py @@ -4,7 +4,7 @@ import pygfx from ._positions_base import PositionsGraphic -from ._features import PointsSizesFeature, UniformSize, CoordSpace +from ._features import PointsSizesFeature, UniformSize, SizeSpace class ScatterGraphic(PositionsGraphic): @@ -85,6 +85,7 @@ def __init__( geo_kwargs = {"positions": self._data.buffer} material_kwargs = {"pick_write": True} + self._size_space = SizeSpace(size_space) if uniform_color: material_kwargs["color_mode"] = "uniform" @@ -102,7 +103,7 @@ def __init__( self._sizes = PointsSizesFeature(sizes, n_datapoints=n_datapoints) geo_kwargs["sizes"] = self.sizes.buffer - material_kwargs['size_space'] = size_space + material_kwargs['size_space'] = self.size_space world_object = pygfx.Points( pygfx.Geometry(**geo_kwargs), material=pygfx.PointsMaterial(**material_kwargs), @@ -110,6 +111,14 @@ def __init__( self._set_world_object(world_object) + @property + def size_space(self) -> str: + return self._size_space.value + + @size_space.setter + def size_space(self, value: str): + self._size_space.set_value(self, value) + @property def sizes(self) -> PointsSizesFeature | float: """Get or set the scatter point size(s)""" From 3e527cc0949f7e3e52d08ed26e8a6393d749d10a Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 17:34:47 -0500 Subject: [PATCH 09/19] add size_space to _features cls dict --- fastplotlib/graphics/line.py | 2 +- fastplotlib/graphics/scatter.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/line.py b/fastplotlib/graphics/line.py index a56389f4f..0b51b4c67 100644 --- a/fastplotlib/graphics/line.py +++ b/fastplotlib/graphics/line.py @@ -10,7 +10,7 @@ class LineGraphic(PositionsGraphic): - _features = {"data", "colors", "cmap", "thickness"} + _features = {"data", "colors", "cmap", "thickness", "size_space"} def __init__( self, diff --git a/fastplotlib/graphics/scatter.py b/fastplotlib/graphics/scatter.py index 5313ba4fb..73c8d01be 100644 --- a/fastplotlib/graphics/scatter.py +++ b/fastplotlib/graphics/scatter.py @@ -8,7 +8,7 @@ class ScatterGraphic(PositionsGraphic): - _features = {"data", "sizes", "colors", "cmap"} + _features = {"data", "sizes", "colors", "cmap", "size_space"} def __init__( self, From 7e88a082f35531a8e83af85cec04760f2154004e Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 18:27:13 -0500 Subject: [PATCH 10/19] move size_space properties to base PositionGraphics class, add link to CoordSpace in docstring --- fastplotlib/graphics/_positions_base.py | 5 ++++- fastplotlib/graphics/line.py | 9 --------- fastplotlib/graphics/scatter.py | 8 -------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/fastplotlib/graphics/_positions_base.py b/fastplotlib/graphics/_positions_base.py index be677fba4..3dc5db8af 100644 --- a/fastplotlib/graphics/_positions_base.py +++ b/fastplotlib/graphics/_positions_base.py @@ -10,6 +10,7 @@ UniformColor, VertexCmap, PointsSizesFeature, + SizeSpace, ) @@ -58,6 +59,8 @@ def cmap(self, name: str): def size_space(self): """ The coordinate space in which the size is expressed (‘screen’, ‘world’, ‘model’) + + See https://docs.pygfx.org/stable/_autosummary/utils/utils/enums/pygfx.utils.enums.CoordSpace.html#pygfx.utils.enums.CoordSpace for available options. """ return self._size_space @@ -144,7 +147,7 @@ def __init__( self._colors, cmap_name=None, transform=None, alpha=alpha ) - self._size_space = size_space + self._size_space = SizeSpace(size_space) super().__init__(*args, **kwargs) def unshare_property(self, property: str): diff --git a/fastplotlib/graphics/line.py b/fastplotlib/graphics/line.py index 0b51b4c67..25f77c658 100644 --- a/fastplotlib/graphics/line.py +++ b/fastplotlib/graphics/line.py @@ -75,7 +75,6 @@ def __init__( ) self._thickness = Thickness(thickness) - self._size_space = SizeSpace(size_space) if thickness < 1.1: MaterialCls = pygfx.LineThinMaterial @@ -106,14 +105,6 @@ def __init__( self._set_world_object(world_object) - @property - def size_space(self) -> str: - return self._size_space.value - - @size_space.setter - def size_space(self, value: str): - self._size_space.set_value(self, value) - @property def thickness(self) -> float: """line thickness""" diff --git a/fastplotlib/graphics/scatter.py b/fastplotlib/graphics/scatter.py index 73c8d01be..2fda91773 100644 --- a/fastplotlib/graphics/scatter.py +++ b/fastplotlib/graphics/scatter.py @@ -111,14 +111,6 @@ def __init__( self._set_world_object(world_object) - @property - def size_space(self) -> str: - return self._size_space.value - - @size_space.setter - def size_space(self, value: str): - self._size_space.set_value(self, value) - @property def sizes(self) -> PointsSizesFeature | float: """Get or set the scatter point size(s)""" From b8a9be31278af72167ff0220a62a254889b855a8 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Tue, 7 Jan 2025 18:27:39 -0500 Subject: [PATCH 11/19] fix comment for SizeSpace scatter/line --- fastplotlib/graphics/_features/_positions_graphics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastplotlib/graphics/_features/_positions_graphics.py b/fastplotlib/graphics/_features/_positions_graphics.py index f1c773c6d..ca3c274b8 100644 --- a/fastplotlib/graphics/_features/_positions_graphics.py +++ b/fastplotlib/graphics/_features/_positions_graphics.py @@ -182,7 +182,7 @@ def set_value(self, graphic, value: float | int): self._call_event_handlers(event) -# manages the coordinate space for scatter +# manages the coordinate space for scatter/line class SizeSpace(GraphicFeature): def __init__(self, value: str): self._value = str(value) From 8a0b9be3b9ba9ee778c7827186438faaa3876f0e Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Thu, 9 Jan 2025 10:21:48 -0500 Subject: [PATCH 12/19] return .value, set_value() --- fastplotlib/graphics/_positions_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/_positions_base.py b/fastplotlib/graphics/_positions_base.py index 3dc5db8af..d0ae5e444 100644 --- a/fastplotlib/graphics/_positions_base.py +++ b/fastplotlib/graphics/_positions_base.py @@ -62,11 +62,11 @@ def size_space(self): See https://docs.pygfx.org/stable/_autosummary/utils/utils/enums/pygfx.utils.enums.CoordSpace.html#pygfx.utils.enums.CoordSpace for available options. """ - return self._size_space + return self._size_space.value @size_space.setter def size_space(self, value: str): - self._size_space = value + self._size_space.set_value(self, value) def __init__( self, From 5db629b2fbe1af966d09eec558c021d3cdc2b254 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Thu, 9 Jan 2025 10:22:50 -0500 Subject: [PATCH 13/19] don't coerce str, check if "Line" in class name --- fastplotlib/graphics/_features/_positions_graphics.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/_features/_positions_graphics.py b/fastplotlib/graphics/_features/_positions_graphics.py index ca3c274b8..c4e153a31 100644 --- a/fastplotlib/graphics/_features/_positions_graphics.py +++ b/fastplotlib/graphics/_features/_positions_graphics.py @@ -185,7 +185,7 @@ def set_value(self, graphic, value: float | int): # manages the coordinate space for scatter/line class SizeSpace(GraphicFeature): def __init__(self, value: str): - self._value = str(value) + self._value = value super().__init__() @property @@ -193,7 +193,10 @@ def value(self) -> str: return self._value def set_value(self, graphic, value: str): - graphic.world_object.material.size_space = str(value) + if "Line" in graphic.world_object.material.__class__.__name__: + graphic.world_object.material.thickness_space = value + else: + graphic.world_object.material.size_space = value self._value = value event = FeatureEvent(type="size_space", info={"value": value}) From 07de27bd9c2f2304c98c1b299c38792a0ac5d335 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Thu, 9 Jan 2025 11:00:36 -0500 Subject: [PATCH 14/19] add test for size_space --- tests/test_positions_graphics.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_positions_graphics.py b/tests/test_positions_graphics.py index 81403c06b..034660efd 100644 --- a/tests/test_positions_graphics.py +++ b/tests/test_positions_graphics.py @@ -443,3 +443,26 @@ def test_thickness(thickness): else: assert isinstance(graphic.world_object.material, pygfx.LineMaterial) + +@pytest.mark.parametrize("graphic_type", ["line", "scatter"]) +@pytest.mark.parametrize("size_space", ["screen", "world", "model"]) +def test_size_space(graphic_type, size_space): + fig = fpl.Figure() + + kwargs = dict() + for kwarg in ["size_space"]: + if locals()[kwarg] is not None: + # add to dict of arguments that will be passed + kwargs[kwarg] = locals()[kwarg] + + data = generate_positions_spiral_data("xy") + + if size_space is None: + size_space = "screen" # default space + + if graphic_type == "line": + graphic = fig[0, 0].add_line(data=data, **kwargs) + assert graphic.world_object.material.thickness_space == size_space + elif graphic_type == "scatter": + graphic = fig[0, 0].add_scatter(data=data, **kwargs) + assert graphic.world_object.material.size_space == size_space From 68c83ebb9a6c9cf388b7ffb0b8738dc120d62300 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Thu, 9 Jan 2025 16:44:35 -0500 Subject: [PATCH 15/19] add tests for setting properties --- tests/test_positions_graphics.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_positions_graphics.py b/tests/test_positions_graphics.py index 034660efd..197c9dcfc 100644 --- a/tests/test_positions_graphics.py +++ b/tests/test_positions_graphics.py @@ -460,9 +460,27 @@ def test_size_space(graphic_type, size_space): if size_space is None: size_space = "screen" # default space + # size_space is really an alias for pygfx.utils.enums.CoordSpace if graphic_type == "line": graphic = fig[0, 0].add_line(data=data, **kwargs) + + # test getter assert graphic.world_object.material.thickness_space == size_space + assert graphic.size_space == size_space + + # test setter + graphic.size_space = 'world' + assert graphic.size_space == 'world' + assert graphic.world_object.material.thickness_space == 'world' + elif graphic_type == "scatter": + + # test getter graphic = fig[0, 0].add_scatter(data=data, **kwargs) assert graphic.world_object.material.size_space == size_space + assert graphic.size_space == size_space + + # test setter + graphic.size_space = 'world' + assert graphic.size_space == 'world' + assert graphic.world_object.material.size_space == 'world' From 000d6a3f0bacda7d8249fd2b7182e1179edce474 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Thu, 9 Jan 2025 17:17:47 -0500 Subject: [PATCH 16/19] double quotes for the linting overlords --- tests/test_positions_graphics.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_positions_graphics.py b/tests/test_positions_graphics.py index 197c9dcfc..2b16463b5 100644 --- a/tests/test_positions_graphics.py +++ b/tests/test_positions_graphics.py @@ -469,9 +469,9 @@ def test_size_space(graphic_type, size_space): assert graphic.size_space == size_space # test setter - graphic.size_space = 'world' - assert graphic.size_space == 'world' - assert graphic.world_object.material.thickness_space == 'world' + graphic.size_space = "world" + assert graphic.size_space == "world" + assert graphic.world_object.material.thickness_space == "world" elif graphic_type == "scatter": @@ -481,6 +481,6 @@ def test_size_space(graphic_type, size_space): assert graphic.size_space == size_space # test setter - graphic.size_space = 'world' - assert graphic.size_space == 'world' - assert graphic.world_object.material.size_space == 'world' + graphic.size_space = "world" + assert graphic.size_space == "world" + assert graphic.world_object.material.size_space == "world" From 613ece77c0f7f7798f559e2e5934b3a9cc3b13a4 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Thu, 9 Jan 2025 17:19:20 -0500 Subject: [PATCH 17/19] regen api docs --- .../source/api/graphic_features/SizeSpace.rst | 35 +++++++++++++++++++ docs/source/api/graphic_features/index.rst | 1 + docs/source/api/graphics/LineGraphic.rst | 1 + docs/source/api/graphics/ScatterGraphic.rst | 1 + 4 files changed, 38 insertions(+) create mode 100644 docs/source/api/graphic_features/SizeSpace.rst diff --git a/docs/source/api/graphic_features/SizeSpace.rst b/docs/source/api/graphic_features/SizeSpace.rst new file mode 100644 index 000000000..0bca1ecc8 --- /dev/null +++ b/docs/source/api/graphic_features/SizeSpace.rst @@ -0,0 +1,35 @@ +.. _api.SizeSpace: + +SizeSpace +********* + +========= +SizeSpace +========= +.. currentmodule:: fastplotlib.graphics._features + +Constructor +~~~~~~~~~~~ +.. autosummary:: + :toctree: SizeSpace_api + + SizeSpace + +Properties +~~~~~~~~~~ +.. autosummary:: + :toctree: SizeSpace_api + + SizeSpace.value + +Methods +~~~~~~~ +.. autosummary:: + :toctree: SizeSpace_api + + SizeSpace.add_event_handler + SizeSpace.block_events + SizeSpace.clear_event_handlers + SizeSpace.remove_event_handler + SizeSpace.set_value + diff --git a/docs/source/api/graphic_features/index.rst b/docs/source/api/graphic_features/index.rst index ea3ce8903..dc88e97d6 100644 --- a/docs/source/api/graphic_features/index.rst +++ b/docs/source/api/graphic_features/index.rst @@ -7,6 +7,7 @@ Graphic Features VertexColors UniformColor UniformSize + SizeSpace Thickness VertexPositions PointsSizesFeature diff --git a/docs/source/api/graphics/LineGraphic.rst b/docs/source/api/graphics/LineGraphic.rst index cb924b4dc..4302ab56c 100644 --- a/docs/source/api/graphics/LineGraphic.rst +++ b/docs/source/api/graphics/LineGraphic.rst @@ -31,6 +31,7 @@ Properties LineGraphic.offset LineGraphic.right_click_menu LineGraphic.rotation + LineGraphic.size_space LineGraphic.supported_events LineGraphic.thickness LineGraphic.visible diff --git a/docs/source/api/graphics/ScatterGraphic.rst b/docs/source/api/graphics/ScatterGraphic.rst index 8f15e827a..83e734c61 100644 --- a/docs/source/api/graphics/ScatterGraphic.rst +++ b/docs/source/api/graphics/ScatterGraphic.rst @@ -31,6 +31,7 @@ Properties ScatterGraphic.offset ScatterGraphic.right_click_menu ScatterGraphic.rotation + ScatterGraphic.size_space ScatterGraphic.sizes ScatterGraphic.supported_events ScatterGraphic.visible From 38c1897f12ae2ba6371879de98091925c87b2f03 Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Thu, 9 Jan 2025 17:27:05 -0500 Subject: [PATCH 18/19] double quotes on "size_space" --- fastplotlib/graphics/scatter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastplotlib/graphics/scatter.py b/fastplotlib/graphics/scatter.py index 2fda91773..8dad7cd43 100644 --- a/fastplotlib/graphics/scatter.py +++ b/fastplotlib/graphics/scatter.py @@ -103,7 +103,7 @@ def __init__( self._sizes = PointsSizesFeature(sizes, n_datapoints=n_datapoints) geo_kwargs["sizes"] = self.sizes.buffer - material_kwargs['size_space'] = self.size_space + material_kwargs["size_space"] = self.size_space world_object = pygfx.Points( pygfx.Geometry(**geo_kwargs), material=pygfx.PointsMaterial(**material_kwargs), From 18b34553e0d7ee7f1840e9d73cefc7f67c9b428e Mon Sep 17 00:00:00 2001 From: Flynn OConnell Date: Thu, 9 Jan 2025 17:29:40 -0500 Subject: [PATCH 19/19] black formatting spaces / trailing commas --- fastplotlib/graphics/_positions_base.py | 2 +- fastplotlib/graphics/line.py | 2 +- tests/test_positions_graphics.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/_positions_base.py b/fastplotlib/graphics/_positions_base.py index d0ae5e444..565a4cd98 100644 --- a/fastplotlib/graphics/_positions_base.py +++ b/fastplotlib/graphics/_positions_base.py @@ -59,7 +59,7 @@ def cmap(self, name: str): def size_space(self): """ The coordinate space in which the size is expressed (‘screen’, ‘world’, ‘model’) - + See https://docs.pygfx.org/stable/_autosummary/utils/utils/enums/pygfx.utils.enums.CoordSpace.html#pygfx.utils.enums.CoordSpace for available options. """ return self._size_space.value diff --git a/fastplotlib/graphics/line.py b/fastplotlib/graphics/line.py index 25f77c658..8fe505ba9 100644 --- a/fastplotlib/graphics/line.py +++ b/fastplotlib/graphics/line.py @@ -95,7 +95,7 @@ def __init__( thickness=self.thickness, color_mode="vertex", pick_write=True, - thickness_space=self.size_space + thickness_space=self.size_space, ) geometry = pygfx.Geometry( positions=self._data.buffer, colors=self._colors.buffer diff --git a/tests/test_positions_graphics.py b/tests/test_positions_graphics.py index 2b16463b5..b76ece2ca 100644 --- a/tests/test_positions_graphics.py +++ b/tests/test_positions_graphics.py @@ -444,6 +444,7 @@ def test_thickness(thickness): else: assert isinstance(graphic.world_object.material, pygfx.LineMaterial) + @pytest.mark.parametrize("graphic_type", ["line", "scatter"]) @pytest.mark.parametrize("size_space", ["screen", "world", "model"]) def test_size_space(graphic_type, size_space): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy