Skip to content

Commit c50beb6

Browse files
authored
add features section to docs for Graphics
1 parent 5862c6f commit c50beb6

File tree

5 files changed

+68
-23
lines changed

5 files changed

+68
-23
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Features
2+
********
3+
4+
.. autoclass:: fastplotlib.graphics.features.ImageDataFeature
5+
:members:
6+
:inherited-members:
7+
:exclude-members: __init__
8+
:no-undoc-members:
9+
10+
.. autoclass:: fastplotlib.graphics.features.ImageCmapFeature
11+
:members:
12+
:inherited-members:
13+
:exclude-members: __init__
14+
:no-undoc-members:
15+

docs/source/conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1818

1919
extensions = ["sphinx.ext.napoleon", "sphinx.ext.autodoc"]
20-
autodoc_typehints = "description"
2120

2221
templates_path = ['_templates']
2322
exclude_patterns = []
2423

25-
24+
napoleon_custom_sections = ['Features']
2625

2726
# -- Options for HTML output -------------------------------------------------
2827
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
@@ -32,9 +31,12 @@
3231

3332
html_static_path = ['_static']
3433

35-
autodoc_member_order = 'bysource'
34+
autodoc_member_order = 'groupwise'
3635
autoclass_content = "both"
3736

37+
autodoc_typehints = "description"
38+
autodoc_typehints_description_target = "documented_params"
39+
3840
def _setup_navbar_side_toctree(app: Any):
3941

4042
def add_class_toctree_function(app: Any, pagename: Any, templatename: Any, context: Any, doctree: Any):

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Welcome to fastplotlib's documentation!
1414
Subplot <api/subplot>
1515
Gridplot <api/gridplot>
1616
Graphics <api/graphics>
17+
Graphic Features <api/graphic_features>
1718
Selectors <api/selectors>
1819
Widgets <api/widgets>
1920

fastplotlib/graphics/features/_base.py

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from warnings import warn
44
from typing import *
55
import weakref
6+
from dataclasses import dataclass
67

78
import numpy as np
89
from pygfx import Buffer, Texture
@@ -40,13 +41,20 @@ def to_gpu_supported_dtype(array):
4041

4142
class FeatureEvent:
4243
"""
43-
type: <feature_name>, example: "colors"
44+
Dataclass that holds feature event information. Has ``type`` and ``pick_info`` attributes.
45+
46+
Attributes
47+
----------
48+
type: str, example "colors"
49+
4450
pick_info: dict in the form:
45-
{
46-
"index": indices where feature data was changed, ``range`` object or List[int],
47-
"world_object": world object the feature belongs to,
48-
"new_values": the new values
49-
}
51+
============== =======================================================================
52+
index indices where feature data was changed, ``range`` object or List[int]
53+
============== =======================================================================
54+
world_object world object the feature belongs to
55+
new_data the new data for this feature
56+
============== =======================================================================
57+
5058
"""
5159
def __init__(self, type: str, pick_info: dict):
5260
self.type = type
@@ -60,18 +68,15 @@ def __repr__(self):
6068

6169
class GraphicFeature(ABC):
6270
def __init__(self, parent, data: Any, collection_index: int = None):
63-
"""
64-
65-
Parameters
66-
----------
67-
parent
68-
69-
data: Any
70-
71-
collection_index: int
72-
if part of a collection, index of this graphic within the collection
73-
74-
"""
71+
# not shown as a docstring so it doesn't show up in the docs
72+
# Parameters
73+
# ----------
74+
# parent
75+
#
76+
# data: Any
77+
#
78+
# collection_index: int
79+
# if part of a collection, index of this graphic within the collection
7580
self._parent = weakref.proxy(parent)
7681

7782
self._data = to_gpu_supported_dtype(data)
@@ -119,6 +124,15 @@ def add_event_handler(self, handler: callable):
119124
self._event_handlers.append(handler)
120125

121126
def remove_event_handler(self, handler: callable):
127+
"""
128+
Remove a registered event handler
129+
130+
Parameters
131+
----------
132+
handler: callable
133+
event handler to remove
134+
135+
"""
122136
if handler not in self._event_handlers:
123137
raise KeyError(f"event handler {handler} not registered.")
124138

@@ -254,7 +268,7 @@ def cleanup_array_slice(key: np.ndarray, upper_bound) -> np.ndarray:
254268

255269

256270
class GraphicFeatureIndexable(GraphicFeature):
257-
"""And indexable Graphic Feature, colors, data, sizes etc."""
271+
"""An indexable Graphic Feature, colors, data, sizes etc."""
258272

259273
def _set(self, value):
260274
value = self._parse_set_value(value)

fastplotlib/graphics/image.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from ._base import Graphic, Interaction, PreviouslyModifiedData
1010
from .selectors import LinearSelector, LinearRegionSelector
11-
from .features import ImageCmapFeature, ImageDataFeature, HeatmapDataFeature, HeatmapCmapFeature
11+
from .features import ImageCmapFeature, ImageDataFeature, HeatmapDataFeature, HeatmapCmapFeature, PresentFeature
1212
from .features._base import to_gpu_supported_dtype
1313
from ..utils import quick_min_max
1414

@@ -160,6 +160,7 @@ class ImageGraphic(Graphic, Interaction, _ImageHeatmapSelectorsMixin):
160160
feature_events = (
161161
"data",
162162
"cmap",
163+
"present"
163164
)
164165

165166
def __init__(
@@ -199,6 +200,18 @@ def __init__(
199200
kwargs:
200201
additional keyword arguments passed to Graphic
201202
203+
Features
204+
--------
205+
206+
**data**: :class:`.ImageDataFeature`
207+
Manages the data buffer displayed in the ImageGraphic
208+
209+
**cmap**: :class:`.ImageCmapFeature`
210+
Manages the colormap
211+
212+
**present**: :class:`.PresentFeature`
213+
Control the presence of the Graphic in the scene
214+
202215
Examples
203216
--------
204217
.. code-block:: python

0 commit comments

Comments
 (0)