GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — graphic features refactor by kushalkolar · Pull Request #473 · fastplotlib/fastplotlib

Conversation

@kushalkolar

@kushalkolar kushalkolar commented Apr 3, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

See #511 , I accidentally merged this into main 🤦‍♂️

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kushalkolar

kushalkolar commented May 17, 2024

Copy link
Copy Markdown
Member Author

Working on this, Graphic features should have no access to collection_index. When we emit events, we can have the graphic accessible and then the collection index of the graphic can be accessed if required.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 6 commits May 17, 2024 23:33
@kushalkolar
just a start
60e7f60
@kushalkolar
pushing to continue on my desktop
6eec7d5
@kushalkolar
progress on buffer manager cleanup_key
0249125
@kushalkolar
more progress, still lots to do
9d891ee
@kushalkolar
slicing working with PointsDataFeature, negative slices too, still ma…
9635bc0
…jor WIP
@kushalkolar
comitting stuff
9be017c
@kushalkolar
kushalkolar force-pushed the graphic-features-refactor branch from 92c562d to 9be017c Compare May 18, 2024 03:37
@kushalkolar

kushalkolar commented May 18, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

ok so PointsDataFeature working, and we have negative and multi-dim slicing now 🥳

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented May 18, 2024

Copy link
Copy Markdown
Member Author

I should double check to make sure we don't get any off by 1 errors in the slicing and with size in update_range

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 3 commits May 18, 2024 00:50
@kushalkolar
_update_range() is pretty good now
0491f8c
@kushalkolar
comment
97b7303
@kushalkolar
if statement
4585be2
@kushalkolar

kushalkolar commented May 18, 2024

Copy link
Copy Markdown
Member Author

Ideas for event adding:

# graphic base class
Graphic:
  def add_event_handler(func, "event-name")

Where "event-name" is either a feature name or pygfx event name (ex: "click" etc.). And emitted feature events use a pick_info dict that holds event information just like pygfx events. Might make sense to subclass pygfx.Event here for feature events, will see.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 7 commits May 20, 2024 00:27
@kushalkolar
simply colors setting
261a5a9
@kushalkolar
type annotation
5d40af8
@kushalkolar
simpler slice parsing
697d50e
@kushalkolar
remove cleanup_key :D :D :D git status!
08fd17d
@kushalkolar
all fancy and negative indexing working :D
a45651d
@kushalkolar
start tests
9612d60
@kushalkolar
exception message
dda8396
@kushalkolar

kushalkolar commented May 20, 2024

Copy link
Copy Markdown
Member Author

@almarklein I've arrived at this parser that takes the key used to index the buffer and auto determines the offset & size to mark for upload, do you think this would be useful to have directly in pygfx?

snippet:

    def _update_range(self, key: int | slice | np.ndarray[int | bool] | list[bool | int] | tuple[slice, ...]):
        """
        Uses key from slicing to determine the offset and
        size of the buffer to mark for upload to the GPU
        """
        # number of elements in the buffer
        upper_bound = self.value.shape[0]

        if isinstance(key, tuple):
            # if multiple dims are sliced, we only need the key for
            # the first dimension corresponding to n_datapoints
            key: int | np.ndarray[int | bool] | slice = key[0]

        if isinstance(key, int):
            # simplest case
            offset = key
            size = 1

        elif isinstance(key, slice):
            # parse slice
            start, stop, step = key.indices(upper_bound)

            # account for backwards indexing
            if (start > stop) and step < 0:
                offset = stop
            else:
                offset = start

            # slice.indices will give -1 if None is passed
            # which just means 0 here since buffers do not
            # use negative indexing
            offset = max(0, offset)

            # number of elements to upload
            # this is indexing so do not add 1
            size = abs(stop - start)

        elif isinstance(key, (np.ndarray, list)):
            if isinstance(key, list):
                # convert to array
                key = np.array(key)

            if not key.ndim == 1:
                raise TypeError(key)

            if key.dtype == bool:
                # convert bool mask to integer indices
                key = np.nonzero(key)[0]

            if not np.issubdtype(key.dtype, np.integer):
                # fancy indexing doesn't make sense with non-integer types
                raise TypeError(key)

            if key.size < 1:
                # nothing to update
                return

            # convert any negative integer indices to positive indices
            key %= upper_bound

            # index of first element to upload
            offset = key.min()

            # number of elements to upload
            # add 1 because this is direct
            # passing of indices, not a start:stop
            size = np.ptp(key) + 1

        else:
            raise TypeError(key)

        self.buffer.update_range(offset=offset, size=size)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented May 20, 2024

Copy link
Copy Markdown
Member Author

I need to do a thing in the tests where we just draw frames on demand to test that the right things are in buffer._gfx_pending_uploads, and that after a frame is draw this list is cleared and take a screenshot and see that it looks right.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 4 commits May 20, 2024 03:30
@kushalkolar
more on tests
e22fe7c
@kushalkolar
refactor sizes, not tested yet
9b4082f
@kushalkolar
start parameterizing buffer tests
2a1869c
@kushalkolar
better buffer tests
29a0a76
kushalkolar
kushalkolar commented May 21, 2024
View reviewed changes
Comment thread tests/test_buffer_manager.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 2 commits May 20, 2024 20:41
@kushalkolar
more variants
054c836
@kushalkolar
add array fancy indexing to same parameterization
f50614f
kushalkolar added 10 commits May 25, 2024 05:17
@kushalkolar
work on selectors, WIP, linear region selector inits properly and mov…
ec6b2f4
…es for x-axis
@kushalkolar
proper centering
db910d3
@kushalkolar
much simpliified and better linear region selector
a09386b
@kushalkolar
linear region selector works well on x axis with events and data sele…
49c2108
…ction
@kushalkolar
vertex cmap fix, delete synchronizer
1ec0f40
@kushalkolar
linear selector works
5022753
@kushalkolar
cleanup
f295356
@kushalkolar
update graphic methods mixin
4d4d636
@kushalkolar
update selector example nbs, still WIP
1d6adc6
@kushalkolar
type annotation in setter
284a1db
clewis7
clewis7 reviewed May 29, 2024
View reviewed changes

@clewis7 clewis7 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started reviewing things...

Things with lines appear to be working well - shared buffers, event handling

Images are a bit wonking - updating data, changing cmap, etc.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/_base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_features/_base.py
+============+=============+===============================================+
| type | str | "colors" - name of the event |
+------------+-------------+-----------------------------------------------+
| graphic | Graphic | graphic instance that the event is from |

@clewis7 clewis7 May 29, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| graphic | Graphic | graphic instance that the event is from |
| graphic | Graphic | graphic instance that emitted the event |

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread fastplotlib/graphics/_features/_data.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_features/_image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented May 30, 2024

Copy link
Copy Markdown
Member Author

Thought from Billy: make the simplest use cases default kwargs, ex: uniform_colors for line and scatter.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar
add notes to tests comments
b4fe957
@kushalkolar kushalkolar mentioned this pull request Jun 4, 2024
Modes for selector Sychronizer and use of arrow key #262
Closed
4 tasks
kushalkolar and others added 9 commits June 3, 2024 21:50
@kushalkolar
refactor image stuff
e6b9133
@kushalkolar
image selector tool
820772d
@kushalkolar
return selectors as proxies
254f0ba
@kushalkolar
image stuff works
2bf33fa
@kushalkolar
fix offsets adding graphics, fix positions_graphic cmap bug, quicksta…
67404ca
…rt runs :D
@kushalkolar
fix add_graphic args and mixin
b1b297d
@kushalkolar
simpler graphic collection stuff
74f8428
@kushalkolar
more line collection
6eb5a1a
@clewis7
remove old events system
f543e4a
@clewis7

clewis7 commented Jun 4, 2024

Copy link
Copy Markdown
Member

Adding a LinearRegionSelector to an ImageGraphic has a default fill that is solid:
image
Especially now that heatmap is part of ImageGraphic, we should pass the fill so that it is transparent, just so then you can see the data that you are selecting

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7

clewis7 commented Jun 4, 2024

Copy link
Copy Markdown
Member

TODO: need to fix HLUT in ImageWidget to mirror changes in LinearRegionSelector

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7
clewis7 reviewed Jun 4, 2024
View reviewed changes
Comment thread fastplotlib/graphics/_features/_positions_graphics.py
Comment on lines +308 to +310
if self._cmap_values is not None:
if not isinstance(self._cmap_values, np.ndarray):
raise TypeError

@clewis7 clewis7 Jun 4, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a previous example with lines we had setting the cmap_values from a list, with this change we would no longer be supporting

for now, I changed the example to just cast the list to an array

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@clewis7
fix some examples
aa1e974
@clewis7 clewis7 mentioned this pull request Jun 4, 2024
add "Guide" to docs #510
Closed
@kushalkolar
kushalkolar merged commit aa1e974 into main Jun 4, 2024
@kushalkolar

kushalkolar commented Jun 4, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

see if this can reopen

Edit: apparently not

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@clewis7 clewis7 clewis7 left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@kushalkolar @almarklein @clewis7
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.