GeezerVison is showing github.com — clean, docs, docs CI test etc. (#275) · fastplotlib/fastplotlib@1729a0d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/ci.yml +32-1Lines changed: 32 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 |
| 16 | 16 | jobs: | 17 | 17 |
| | 18 | + docs-build: | | 19 | + name: Docs | | 20 | + runs-on: ubuntu-latest | | 21 | + strategy: | | 22 | + fail-fast: false | | 23 | + steps: | | 24 | + - uses: actions/checkout@v3 | | 25 | + - name: Set up Python 3.9 | | 26 | + uses: actions/setup-python@v4 | | 27 | + with: | | 28 | + python-version: 3.9 | | 29 | + - name: Install llvmpipe and lavapipe for offscreen canvas, and git lfs | | 30 | + run: | | | 31 | + sudo apt-get update -y -qq | | 32 | + sudo apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers git-lfs | | 33 | + - name: Install pandoc v3.14, nbsphinx complains about older pandoc versions | | 34 | + run: | | | 35 | + wget https://github.com/jgm/pandoc/releases/download/3.1.4/pandoc-3.1.4-1-amd64.deb | | 36 | + sudo apt-get install ./pandoc-3.1.4-1-amd64.deb | | 37 | + - name: Install dev dependencies | | 38 | + run: | | | 39 | + python -m pip install --upgrade pip | | 40 | + # remove pygfx from requirements, we install a specific commit of pygfx since both fpl and pygfx are fast evolving | | 41 | + sed -i "/pygfx/d" ./setup.py | | 42 | + pip install git+https://github.com/pygfx/pygfx.git@cf1da6c32223ba3cf7256982ce9b89c81b593076 | | 43 | + pip install -e ".[notebook,docs,tests]" | | 44 | + - name: Build docs | | 45 | + run: | | | 46 | + cd docs | | 47 | + make html SPHINXOPTS="-W --keep-going" | | 48 | +
| 18 | 49 | test-build: | 19 | 50 | name: Test examples | 20 | 51 | runs-on: ubuntu-latest | | 47 | 78 | python -m pip install --upgrade pip | 48 | 79 | # remove pygfx from requirements, we install a specific commit of pygfx since both fpl and pygfx are fast evolving | 49 | 80 | sed -i "/pygfx/d" ./setup.py | 50 | | - pip install git+https://github.com/pygfx/pygfx.git@b63f22a1aa61993c32cd96895316cb8248a81e4d | | 81 | + pip install git+https://github.com/pygfx/pygfx.git@cf1da6c32223ba3cf7256982ce9b89c81b593076 | 51 | 82 | pip install -e ".["tests"]" | 52 | 83 | - name: Show wgpu backend | 53 | 84 | run: | |
Collapse file Copy file name to clipboardExpand all lines: .readthedocs.yaml +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 | - libxcb-xfixes0-dev | 11 | 11 | - mesa-vulkan-drivers | 12 | 12 | - libglfw3 | 13 | | - - pandoc | 14 | 13 | jobs: | 15 | 14 | post_checkout: | 16 | 15 | # Download and uncompress the binary | | 27 | 26 | - ./git-lfs fetch | 28 | 27 | # Make local files to have the real content on them | 29 | 28 | - ./git-lfs checkout | | 29 | + # install newer pandoc else nbsphinx complains | | 30 | + - wget https://github.com/jgm/pandoc/releases/download/3.1.4/pandoc-3.1.4-1-amd64.deb | | 31 | + - sudo apt-get install ./pandoc-3.1.4-1-amd64.deb | 30 | 32 | pre_install: | 31 | 33 | - pip install git+https://github.com/pygfx/pygfx.git@main | 32 | 34 |
| |
Collapse file Copy file name to clipboardExpand all lines: docs/source/api/graphics/HistogramGraphic.rst -36Lines changed: 0 additions & 36 deletions Collapse file Copy file name to clipboardExpand all lines: docs/source/api/graphics/index.rst -1Lines changed: 0 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | ImageGraphic | 8 | 8 | ScatterGraphic | 9 | 9 | LineGraphic | 10 | | - HistogramGraphic | 11 | 10 | HeatmapGraphic | 12 | 11 | LineCollection | 13 | 12 | LineStack | |
Collapse file Copy file name to clipboardExpand all lines: docs/source/api/layouts/gridplot.rst +2Lines changed: 2 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -20,6 +20,8 @@ Properties | 20 | 20 | .. autosummary:: | 21 | 21 | :toctree: GridPlot_api | 22 | 22 |
| | 23 | + GridPlot.canvas | | 24 | + GridPlot.renderer | 23 | 25 |
| 24 | 26 | Methods | 25 | 27 | ~~~~~~~ | |
Collapse file Copy file name to clipboardExpand all lines: docs/source/api/layouts/plot.rst +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,7 @@ Properties | 23 | 23 | Plot.camera | 24 | 24 | Plot.canvas | 25 | 25 | Plot.controller | | 26 | + Plot.docks | 26 | 27 | Plot.graphics | 27 | 28 | Plot.name | 28 | 29 | Plot.parent | @@ -40,7 +41,6 @@ Methods | 40 | 41 | Plot.add_animations | 41 | 42 | Plot.add_graphic | 42 | 43 | Plot.add_heatmap | 43 | | - Plot.add_histogram | 44 | 44 | Plot.add_image | 45 | 45 | Plot.add_line | 46 | 46 | Plot.add_line_collection | |
Collapse file Copy file name to clipboardExpand all lines: docs/source/api/layouts/subplot.rst +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,7 @@ Properties | 23 | 23 | Subplot.camera | 24 | 24 | Subplot.canvas | 25 | 25 | Subplot.controller | | 26 | + Subplot.docks | 26 | 27 | Subplot.graphics | 27 | 28 | Subplot.name | 28 | 29 | Subplot.parent | @@ -40,7 +41,6 @@ Methods | 40 | 41 | Subplot.add_animations | 41 | 42 | Subplot.add_graphic | 42 | 43 | Subplot.add_heatmap | 43 | | - Subplot.add_histogram | 44 | 44 | Subplot.add_image | 45 | 45 | Subplot.add_line | 46 | 46 | Subplot.add_line_collection | |
Collapse file Copy file name to clipboardExpand all lines: fastplotlib/graphics/__init__.py -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from .histogram import HistogramGraphic | 2 | 1 | from .line import LineGraphic | 3 | 2 | from .scatter import ScatterGraphic | 4 | 3 | from .image import ImageGraphic, HeatmapGraphic | | 9 | 8 | "ImageGraphic", | 10 | 9 | "ScatterGraphic", | 11 | 10 | "LineGraphic", | 12 | | - "HistogramGraphic", | 13 | 11 | "HeatmapGraphic", | 14 | 12 | "LineCollection", | 15 | 13 | "LineStack", | |
Collapse file Copy file name to clipboardExpand all lines: fastplotlib/graphics/_base.py +33-6Lines changed: 33 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -75,27 +75,30 @@ def __init__( | 75 | 75 | @property | 76 | 76 | def world_object(self) -> WorldObject: | 77 | 77 | """Associated pygfx WorldObject. Always returns a proxy, real object cannot be accessed directly.""" | | 78 | + # We use weakref to simplify garbage collection | 78 | 79 | return weakref.proxy(WORLD_OBJECTS[hex(id(self))]) | 79 | 80 |
| 80 | 81 | def _set_world_object(self, wo: WorldObject): | 81 | 82 | WORLD_OBJECTS[hex(id(self))] = wo | 82 | 83 |
| 83 | 84 | @property | 84 | 85 | def position(self) -> np.ndarray: | 85 | | - """The position of the graphic. You can access or change | 86 | | - using position.x, position.y, etc.""" | | 86 | + """position of the graphic, [x, y, z]""" | 87 | 87 | return self.world_object.world.position | 88 | 88 |
| 89 | 89 | @property | 90 | 90 | def position_x(self) -> float: | | 91 | + """x-axis position of the graphic""" | 91 | 92 | return self.world_object.world.x | 92 | 93 |
| 93 | 94 | @property | 94 | 95 | def position_y(self) -> float: | | 96 | + """y-axis position of the graphic""" | 95 | 97 | return self.world_object.world.y | 96 | 98 |
| 97 | 99 | @property | 98 | 100 | def position_z(self) -> float: | | 101 | + """z-axis position of the graphic""" | 99 | 102 | return self.world_object.world.z | 100 | 103 |
| 101 | 104 | @position.setter | @@ -390,7 +393,19 @@ def graphics(self) -> np.ndarray[Graphic]: | 390 | 393 | return self._graphics_array | 391 | 394 |
| 392 | 395 | def add_graphic(self, graphic: Graphic, reset_index: False): | 393 | | - """Add a graphic to the collection""" | | 396 | + """ | | 397 | + Add a graphic to the collection. | | 398 | +
| | 399 | + Parameters | | 400 | + ---------- | | 401 | + graphic: Graphic | | 402 | + graphic to add, must be a real ``Graphic`` not a proxy | | 403 | +
| | 404 | + reset_index: bool, default ``False`` | | 405 | + reset the collection index | | 406 | +
| | 407 | + """ | | 408 | + | 394 | 409 | if not type(graphic).__name__ == self.child_type: | 395 | 410 | raise TypeError( | 396 | 411 | f"Can only add graphics of the same type to a collection, " | @@ -413,7 +428,19 @@ def add_graphic(self, graphic: Graphic, reset_index: False): | 413 | 428 | self._graphics_changed = True | 414 | 429 |
| 415 | 430 | def remove_graphic(self, graphic: Graphic, reset_index: True): | 416 | | - """Remove a graphic from the collection""" | | 431 | + """ | | 432 | + Remove a graphic from the collection. | | 433 | +
| | 434 | + Parameters | | 435 | + ---------- | | 436 | + graphic: Graphic | | 437 | + graphic to remove | | 438 | +
| | 439 | + reset_index: bool, default ``False`` | | 440 | + reset the collection index | | 441 | +
| | 442 | + """ | | 443 | + | 417 | 444 | self._graphics.remove(graphic.loc) | 418 | 445 |
| 419 | 446 | if reset_index: | @@ -486,8 +513,8 @@ def __init__( | 486 | 513 | setattr(self, attr_name, collection_feature) | 487 | 514 |
| 488 | 515 | @property | 489 | | - def graphics(self) -> Tuple[Graphic]: | 490 | | - """Returns a tuple of the selected graphics.""" | | 516 | + def graphics(self) -> np.ndarray[Graphic]: | | 517 | + """Returns an array of the selected graphics. Always returns a proxy to the Graphic""" | 491 | 518 | return tuple(self._selection) | 492 | 519 |
| 493 | 520 | def __setattr__(self, key, value): | |
Collapse file Copy file name to clipboardExpand all lines: fastplotlib/graphics/_features/_base.py +20-6Lines changed: 20 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,7 +49,7 @@ class FeatureEvent: | 49 | 49 | ---------- | 50 | 50 | type: str, example "colors" | 51 | 51 |
| 52 | | - pick_info: dict in the form: | | 52 | + pick_info: dict: | 53 | 53 |
| 54 | 54 | ============== ============================================================================= | 55 | 55 | key value | @@ -59,6 +59,9 @@ class FeatureEvent: | 59 | 59 | "new_data: the new data for this feature | 60 | 60 | ============== ============================================================================= | 61 | 61 |
| | 62 | + .. note:: | | 63 | + pick info varies between features, this is just the general structure | | 64 | +
| 62 | 65 | """ | 63 | 66 |
| 64 | 67 | def __init__(self, type: str, pick_info: dict): | @@ -97,8 +100,17 @@ def __init__(self, parent, data: Any, collection_index: int = None): | 97 | 100 | def __call__(self, *args, **kwargs): | 98 | 101 | return self._data | 99 | 102 |
| 100 | | - def block_events(self, b: bool): | 101 | | - self._block_events = b | | 103 | + def block_events(self, val: bool): | | 104 | + """ | | 105 | + Block all events from this feature | | 106 | +
| | 107 | + Parameters | | 108 | + ---------- | | 109 | + val: bool | | 110 | + ``True`` or ``False`` | | 111 | +
| | 112 | + """ | | 113 | + self._block_events = val | 102 | 114 |
| 103 | 115 | @abstractmethod | 104 | 116 | def _set(self, value): | @@ -113,9 +125,10 @@ def _parse_set_value(self, value): | 113 | 125 | def add_event_handler(self, handler: callable): | 114 | 126 | """ | 115 | 127 | Add an event handler. All added event handlers are called when this feature changes. | 116 | | - The `handler` can optionally accept ``FeatureEvent`` as the first and only argument. | | 128 | + The ``handler`` can optionally accept a :class:`.FeatureEvent` as the first and only argument. | 117 | 129 | The ``FeatureEvent`` only has two attributes, ``type`` which denotes the type of event | 118 | | - as a ``str`` in the form of "<feature_name>", such as "color". | | 130 | + as a ``str`` in the form of "<feature_name>", such as "color". And ``pick_info`` which contains | | 131 | + information about the event and Graphic that triggered it. | 119 | 132 |
| 120 | 133 | Parameters | 121 | 134 | ---------- | @@ -134,7 +147,7 @@ def add_event_handler(self, handler: callable): | 134 | 147 |
| 135 | 148 | def remove_event_handler(self, handler: callable): | 136 | 149 | """ | 137 | | - Remove a registered event handler | | 150 | + Remove a registered event ``handler``. | 138 | 151 |
| 139 | 152 | Parameters | 140 | 153 | ---------- | @@ -148,6 +161,7 @@ def remove_event_handler(self, handler: callable): | 148 | 161 | self._event_handlers.remove(handler) | 149 | 162 |
| 150 | 163 | def clear_event_handlers(self): | | 164 | + """Clear all event handlers""" | 151 | 165 | self._event_handlers.clear() | 152 | 166 |
| 153 | 167 | # TODO: maybe this can be implemented right here in the base class | |
|