Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 815e8b3

Browse filesBrowse files
kushalkolarclewis7
andauthored
Graphic features refactor (#511)
* just a start * pushing to continue on my desktop * progress on buffer manager cleanup_key * more progress, still lots to do * slicing working with PointsDataFeature, negative slices too, still major WIP * comitting stuff * _update_range() is pretty good now * comment * if statement * simply colors setting * type annotation * simpler slice parsing * remove cleanup_key :D :D :D git status! * all fancy and negative indexing working :D * start tests * exception message * more on tests * refactor sizes, not tested yet * start parameterizing buffer tests * better buffer tests * more variants * add array fancy indexing to same parameterization * parameterize tuple tests * remove repr * test offset and size * test offset and size * test create colors * also test with direct truth indices in colors * points tests, works * remove imports * sizes test working, other cleanup * export sizes feature again * ideas for sharing and unsharing buffers between graphics * ideas for sharing and unsharing buffers between graphics, nto tested * typing * attach and detach buffers to a graphic, not tested * import * more int point tests * Graphic.add_event_handler * adding and removing data feature event works and tested * common features, WIP * regular features and refactor line and scatter into positions graphic * uniform sizes * implement sizes and uniform size for scatter * VertexCmap feature, not yet tested * start image features, not tested, add thickness, not tested * better cmap parsing * cleanup * image features * cleanup * start selection feature refactor * more on selection features * offset and rotation for base graphic * feature event table * position feature event tables * rotation and offset features * work on selectors, WIP, linear region selector inits properly and moves for x-axis * proper centering * much simpliified and better linear region selector * linear region selector works well on x axis with events and data selection * vertex cmap fix, delete synchronizer * linear selector works * cleanup * update graphic methods mixin * update selector example nbs, still WIP * type annotation in setter * add notes to tests comments * refactor image stuff * image selector tool * return selectors as proxies * image stuff works * fix offsets adding graphics, fix positions_graphic cmap bug, quickstart runs :D * fix add_graphic args and mixin * simpler graphic collection stuff * more line collection * remove old events system * fix some examples * remove lingering older interaction stuff * cleanup * fill color arg * black * update examples * fix image tiling, better heatmap example * update hm examples * fix hlut * refactor graphics base * update line examples * bug fixes * update text to use new gfeatures * cleanup * implement iterator for TextureArray, much simpler now :D * basic texture tests * bugfix, cleanup * image graphic tests * type annot * test stuff * tests for common and visible kwarg for Graphic * bugfix * test remove event hanlders common fea * rename * start test positions graphics * test progress * black * add __len__ to buffer managers, add __array_interface__ raises error * TextureArray has len() * docstring * updates and tests * black * uniform colors tests and bug fix * black * bugfix uniform color and sizes * sizes and thickness tests * tests update * lotta team work * docstring, small things * rename UniformSizes -> UniformSize * update graphic methods mixin * update graphic methods mixin * bugfix * test data slice for positiosn graphics * test colors property within buffer tests * cleanup * emit user key not parsed key * rename cmap_values to transform * cmap_values -> cmap_transform in mixin * test graphics in vertex data buffer manager tests * cmap transform tests * make Graphic._features private, add Graphic.events property * color events tests * move data slice test to just buffer tests * data events tests * cleanup * cleanup, remove old histogram graphic * text changes and tests * texture array tests with graphic * image graphic tests * update image features * black * append data and world xy for graphic pointer events * black * move constructor to top * example tests for wide and square hm * update ci * fix message * update examples * bugfix, docstrings * docstrings, exception messages * update api docs * apparently we use __all__ in graphics to generate api docs * remove nbsphinx * bump version * docstring * finish up line collection * fix adding line selector to line collection * finish line collection * update line collection examples * graphic collections are now iterables, add examples for setting properties, add names and metadatas args, separate kwargs for collection and individual lines * 3d line stack example with animation * fix line collection cmap with additional args * black * update kwargs for line collection because of mixin * add numpy.integer check for buffermanager parse slice * rename * docstrings * line linear selector init logic * fix line collection init selectors * fix selector * add plot area hook for collections * docstring * update selector nbs * update example nb * update nb * cleanup * update nb * update nbs * feature is private class attr * fix * remove anim example from screenshot tests * update screenshots * update screenshot * update CONTRIBUTING * smaller hm data test for CI * exclude heatmap change data from tests, too large RAM usage probably * black * change dtype to save ram usage for CI * remove large square heatmap from screenshot tests * black * disable all but one hm test * fix gc * update screenshots * replace one more test image * fix docs * update image screenshots * fix docs * docstrings, Graphic.events -> Graphic.supported_events * update docs --------- Co-authored-by: Caitlin <caitlin9165@gmail.com>
1 parent 9a309ef commit 815e8b3
Copy full SHA for 815e8b3

File tree

192 files changed

+7204
-6537
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner

192 files changed

+7204
-6537
lines changed

‎.github/workflows/black.yml

Copy file name to clipboard
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
name: Lint
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
types:
11+
- opened
12+
- reopened
13+
- synchronize
14+
- ready_for_review
415

516
jobs:
617
lint:
718
runs-on: ubuntu-latest
19+
if: ${{ !github.event.pull_request.draft }}
820
steps:
921
- uses: actions/checkout@v4
1022
- uses: psf/black@stable
1123
with:
12-
src: "./fastplotlib"
24+
src: "./fastplotlib"

‎.github/workflows/ci.yml

Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
docs-build:
1818
name: Docs
1919
runs-on: bigmem
20+
if: ${{ !github.event.pull_request.draft }}
2021
strategy:
2122
fail-fast: false
2223
steps:

‎CONTRIBUTING.md

Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+23-20Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,37 @@ keeps a *private* global dictionary of all `WorldObject` instances and users are
7777
This is due to garbage collection. This may be quite complicated for beginners, for more details see this PR: https://github.com/fastplotlib/fastplotlib/pull/160 .
7878
If you are curious or have more questions on garbage collection in fastplotlib you're welcome to post an issue :D.
7979

80-
#### Graphic Features
80+
#### Graphic properties
8181

82-
There is one important thing that `fastplotlib` uses which we call "graphic features".
82+
Graphic properties are all evented, and internally we called these "graphic features". They are the various
83+
aspects of a graphic that the user can change.
8384
The "graphic features" subpackage can be found at `fastplotlib/graphics/_features`. As we can see this
84-
is a private subpackage and never meant to be accessible to users. In `fastplotlib` "graphic features" are the various
85-
aspects of a graphic that the user can change. Users can also run callbacks whenever a graphic feature changes.
85+
is a private subpackage and never meant to be accessible to users..
8686

8787
##### LineGraphic
8888

8989
For example let's look at `LineGraphic` in `fastplotlib/graphics/line.py`. Every graphic has a class variable called
90-
`feature_events` which is a set of all graphic features. It has the following graphic features: "data", "colors", "cmap", "thickness", "present".
90+
`_features` which is a set of all graphic properties that are evented. It has the following evented properties:
91+
`"data", "colors", "cmap", "thickness"` in addition to properties common to all graphics, such as `"name", "offset", "rotation", and "visible"`
9192

92-
Now look at the constructor for `LineGraphic`, it first creates an instance of `PointsDataFeature`. This is basically a
93-
class that wraps the positions buffer, the vertex positions that define the line, and provides additional useful functionality.
94-
For example, every time that the `data` is changed event handlers will be called (if any event handlers are registered).
93+
Now look at the constructor for the `LineGraphic` base class `PositionsGraphic`, it first creates an instance of `VertexPositions`.
94+
This is a class that manages vertex positions buffer. It defines the line, and provides additional useful functionality.
95+
For example, every time that the `data` is changed, the new data will be marked for upload to the GPU before the next draw.
96+
In addition, event handlers will be called if any event handlers are registered.
9597

96-
`ColorFeature`behaves similarly, but it can perform additional parsing that can create the colors buffer from different forms of user input. For example if a user runs:
97-
`line_graphic.colors = "blue"`, then `ColorFeature.__setitem__()` will create a buffer that corresponds to what `pygfx.Color` thinks is "blue".
98-
Users can also take advantage of fancy indexing, ex: `line_graphics.colors[bool_array] = "red"` :smile:
98+
`VertexColors`behaves similarly, but it can perform additional parsing that can create the colors buffer from different
99+
forms of user input. For example if a user runs: `line_graphic.colors = "blue"`, then `VertexColors.__setitem__()` will
100+
create a buffer that corresponds to what `pygfx.Color` thinks is "blue". Users can also take advantage of fancy indexing,
101+
ex: `line_graphics.colors[bool_array] = "red"` :smile:
99102

100-
`LineGraphic` also has a `CmapFeature`, this is a subclass of `ColorFeature` which can parse colormaps, for example:
103+
`LineGraphic` also has a `VertexCmap`, this manages the line `VertexColors` instance to parse colormaps, for example:
101104
`line_graphic.cmap = "jet"` or even `line_graphic.cmap[50:] = "viridis"`.
102105

103-
`LineGraphic` also has `ThicknessFeature` which is pretty simple, `PresentFeature` which indicates if a graphic is
104-
currently in the scene, and `DeletedFeature` which is useful if you need callbacks to indicate that the graphic has been
105-
deleted (for example, removing references to a graphic from a legend).
106+
`LineGraphic` also has a `thickness` property which is pretty simple, and `DeletedFeature` which is useful if you need
107+
callbacks to indicate that the graphic has been deleted (for example, removing references to a graphic from a legend).
106108

107-
Other graphics have graphic features that are relevant to them, for example `ImageGraphic` has a `cmap` feature which is
108-
unique to images or heatmaps.
109+
Other graphics have properties that are relevant to them, for example `ImageGraphic` has `cmap`, `vmin`, `vmax`,
110+
properties unique to images.
109111

110112
#### Selectors
111113

@@ -192,9 +194,10 @@ the subplots. All subplots within a `Figure` share the same canvas and use diffe
192194

193195
## Tests in detail
194196

195-
The CI pipeline for a plotting library that is supposed to produce things that "look visually correct". Each example
196-
within the `examples` dir is run and an image of the canvas is taken and compared with a ground-truth
197-
screenshot that we have manually inspected. Ground-truth image are stored using `git-lfs`.
197+
Backend tests are in `tests/`, in addition as a plotting library CI pipeline produces things that
198+
"look visually correct". Each example within the `examples` dir is run and an image of the canvas
199+
is taken and compared with a ground-truth screenshot that we have manually inspected.
200+
Ground-truth image are stored using `git-lfs`.
198201

199202
The ground-truth images are in:
200203

‎docs/source/api/gpu.rst

Copy file name to clipboard
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
fastplotlib.utils
2-
*****************
1+
fastplotlib.utils.gpu
2+
*********************
33

4-
.. automodule:: fastplotlib.utils.gpu
4+
.. currentmodule:: fastplotlib.utils.gpu
5+
.. automodule:: fastplotlib
56
:members:

‎docs/source/api/graphic_features/CmapFeature.rst

Copy file name to clipboardExpand all lines: docs/source/api/graphic_features/CmapFeature.rst
-36Lines changed: 0 additions & 36 deletions
This file was deleted.

‎docs/source/api/graphic_features/ColorFeature.rst

Copy file name to clipboardExpand all lines: docs/source/api/graphic_features/ColorFeature.rst
-34Lines changed: 0 additions & 34 deletions
This file was deleted.

‎docs/source/api/graphic_features/Deleted.rst

Copy file name to clipboardExpand all lines: docs/source/api/graphic_features/Deleted.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Properties
2020
.. autosummary::
2121
:toctree: Deleted_api
2222

23+
Deleted.value
2324

2425
Methods
2526
~~~~~~~
@@ -30,4 +31,5 @@ Methods
3031
Deleted.block_events
3132
Deleted.clear_event_handlers
3233
Deleted.remove_event_handler
34+
Deleted.set_value
3335

‎docs/source/api/graphic_features/FeatureEvent.rst

Copy file name to clipboardExpand all lines: docs/source/api/graphic_features/FeatureEvent.rst
-29Lines changed: 0 additions & 29 deletions
This file was deleted.
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.. _api.FontSize:
2+
3+
FontSize
4+
********
5+
6+
========
7+
FontSize
8+
========
9+
.. currentmodule:: fastplotlib.graphics._features
10+
11+
Constructor
12+
~~~~~~~~~~~
13+
.. autosummary::
14+
:toctree: FontSize_api
15+
16+
FontSize
17+
18+
Properties
19+
~~~~~~~~~~
20+
.. autosummary::
21+
:toctree: FontSize_api
22+
23+
FontSize.value
24+
25+
Methods
26+
~~~~~~~
27+
.. autosummary::
28+
:toctree: FontSize_api
29+
30+
FontSize.add_event_handler
31+
FontSize.block_events
32+
FontSize.clear_event_handlers
33+
FontSize.remove_event_handler
34+
FontSize.set_value
35+

‎docs/source/api/graphic_features/GraphicFeature.rst

Copy file name to clipboardExpand all lines: docs/source/api/graphic_features/GraphicFeature.rst
-33Lines changed: 0 additions & 33 deletions
This file was deleted.

‎docs/source/api/graphic_features/GraphicFeatureIndexable.rst

Copy file name to clipboardExpand all lines: docs/source/api/graphic_features/GraphicFeatureIndexable.rst
-34Lines changed: 0 additions & 34 deletions
This file was deleted.

‎docs/source/api/graphic_features/HeatmapCmapFeature.rst

Copy file name to clipboardExpand all lines: docs/source/api/graphic_features/HeatmapCmapFeature.rst
-37Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.