diff --git a/fastplotlib/graphics/_features/_base.py b/fastplotlib/graphics/_features/_base.py index 5616eec19..99ebbf436 100644 --- a/fastplotlib/graphics/_features/_base.py +++ b/fastplotlib/graphics/_features/_base.py @@ -191,6 +191,10 @@ def _call_event_handlers(self, event_data: FeatureEvent): ) func() + @abstractmethod + def __repr__(self) -> str: + pass + def cleanup_slice(key: Union[int, slice], upper_bound) -> Union[slice, int]: """ diff --git a/fastplotlib/graphics/_features/_colors.py b/fastplotlib/graphics/_features/_colors.py index 256a5d65f..85014155d 100644 --- a/fastplotlib/graphics/_features/_colors.py +++ b/fastplotlib/graphics/_features/_colors.py @@ -234,6 +234,10 @@ def _feature_changed(self, key, new_data): self._call_event_handlers(event_data) + def __repr__(self) -> str: + s = f"ColorsFeature for {self._parent}. Call `.colors()` to get values." + return s + class CmapFeature(ColorFeature): """ @@ -270,6 +274,10 @@ def __setitem__(self, key, cmap_name): self._cmap_name = cmap_name super(CmapFeature, self).__setitem__(key, colors) + @property + def name(self) -> str: + return self._cmap_name + @property def values(self) -> np.ndarray: return self._cmap_values @@ -287,10 +295,18 @@ def values(self, values: np.ndarray): super(CmapFeature, self).__setitem__(slice(None), colors) + def __repr__(self) -> str: + s = f"CmapFeature for {self._parent}, to get name or values: `.cmap.name`, `.cmap.values`" + return s + class ImageCmapFeature(GraphicFeature): """ - Colormap for :class:`ImageGraphic` + Colormap for :class:`ImageGraphic`. + + .cmap() returns the Texture buffer for the cmap. + + .cmap.name returns the cmap name as a str. **event pick info:** @@ -309,7 +325,7 @@ class ImageCmapFeature(GraphicFeature): def __init__(self, parent, cmap: str): cmap_texture_view = get_cmap_texture(cmap) super(ImageCmapFeature, self).__init__(parent, cmap_texture_view) - self.name = cmap + self._name = cmap def _set(self, cmap_name: str): if self._parent.data().ndim > 2: @@ -317,9 +333,13 @@ def _set(self, cmap_name: str): self._parent.world_object.material.map.data[:] = make_colors(256, cmap_name) self._parent.world_object.material.map.update_range((0, 0, 0), size=(256, 1, 1)) - self.name = cmap_name + self._name = cmap_name - self._feature_changed(key=None, new_data=self.name) + self._feature_changed(key=None, new_data=self._name) + + @property + def name(self) -> str: + return self._name @property def vmin(self) -> float: @@ -359,7 +379,7 @@ def _feature_changed(self, key, new_data): pick_info = { "index": None, "world_object": self._parent.world_object, - "name": self.name, + "name": self._name, "vmin": self.vmin, "vmax": self.vmax, } @@ -368,6 +388,10 @@ def _feature_changed(self, key, new_data): self._call_event_handlers(event_data) + def __repr__(self) -> str: + s = f"ImageCmapFeature for {self._parent}. Use `.cmap.name` to get str name of cmap." + return s + class HeatmapCmapFeature(ImageCmapFeature): """ diff --git a/fastplotlib/graphics/_features/_data.py b/fastplotlib/graphics/_features/_data.py index 0d22299ed..23e80b470 100644 --- a/fastplotlib/graphics/_features/_data.py +++ b/fastplotlib/graphics/_features/_data.py @@ -100,6 +100,10 @@ def _feature_changed(self, key, new_data): self._call_event_handlers(event_data) + def __repr__(self) -> str: + s = f"PointsDataFeature for {self._parent}, call `.data()` to get values" + return s + class ImageDataFeature(GraphicFeatureIndexable): """ @@ -164,6 +168,10 @@ def _feature_changed(self, key, new_data): self._call_event_handlers(event_data) + def __repr__(self) -> str: + s = f"ImageDataFeature for {self._parent}, call `.data()` to get values" + return s + class HeatmapDataFeature(ImageDataFeature): @property diff --git a/fastplotlib/graphics/_features/_present.py b/fastplotlib/graphics/_features/_present.py index b0bb627c5..6fbf93b48 100644 --- a/fastplotlib/graphics/_features/_present.py +++ b/fastplotlib/graphics/_features/_present.py @@ -66,3 +66,7 @@ def _feature_changed(self, key, new_data): event_data = FeatureEvent(type="present", pick_info=pick_info) self._call_event_handlers(event_data) + + def __repr__(self) -> str: + s = f"PresentFeature for {self._parent}, call `.present()` to get values" + return s diff --git a/fastplotlib/graphics/_features/_selection_features.py b/fastplotlib/graphics/_features/_selection_features.py index 5f161562f..9a2696f7c 100644 --- a/fastplotlib/graphics/_features/_selection_features.py +++ b/fastplotlib/graphics/_features/_selection_features.py @@ -191,6 +191,10 @@ def _feature_changed(self, key: Union[int, slice, Tuple[slice]], new_data: Any): self._call_event_handlers(event_data) + def __repr__(self) -> str: + s = f"LinearSelectionFeature for {self._parent}" + return s + class LinearRegionSelectionFeature(GraphicFeature): """ @@ -313,3 +317,7 @@ def _feature_changed(self, key: Union[int, slice, Tuple[slice]], new_data: Any): event_data = FeatureEvent(type="selection", pick_info=pick_info) self._call_event_handlers(event_data) + + def __repr__(self) -> str: + s = f"LinearRegionSelectionFeature for {self._parent}" + return s diff --git a/fastplotlib/graphics/_features/_sizes.py b/fastplotlib/graphics/_features/_sizes.py index 377052918..e951064e4 100644 --- a/fastplotlib/graphics/_features/_sizes.py +++ b/fastplotlib/graphics/_features/_sizes.py @@ -105,4 +105,8 @@ def _feature_changed(self, key, new_data): event_data = FeatureEvent(type="sizes", pick_info=pick_info) - self._call_event_handlers(event_data) \ No newline at end of file + self._call_event_handlers(event_data) + + def __repr__(self) -> str: + s = f"PointsSizesFeature for {self._parent}, call `.sizes()` to get values" + return s diff --git a/fastplotlib/graphics/_features/_thickness.py b/fastplotlib/graphics/_features/_thickness.py index cae3828b7..f9190f0b1 100644 --- a/fastplotlib/graphics/_features/_thickness.py +++ b/fastplotlib/graphics/_features/_thickness.py @@ -40,3 +40,7 @@ def _feature_changed(self, key, new_data): event_data = FeatureEvent(type="thickness", pick_info=pick_info) self._call_event_handlers(event_data) + + def __repr__(self) -> str: + s = f"ThicknessFeature for {self._parent}, call `.thickness()` to get value" + return s 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