GeezerVison is showing github.com — implemenet `@block_reentrance` decorator by kushalkolar · Pull Request #744 · fastplotlib/fastplotlib
Conversation
kushalkolar
commented
Mar 3, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
This simple decorator applied on all the GraphicFeature.set_value() methods should allow us to create complex event graphs with cycles. Users don't have to think about managing bidirectional events 😄
related #741
Example:
import fastplotlib as fpl
import numpy as np
fig = fpl.Figure((3, 1))
sels = list()
for subplot in fig:
lg = subplot.add_line(np.sin(np.linspace(0, np.pi * 10, 100)))
sel = lg.add_linear_selector()
sels.append(sel)
# create event handler and just add it to all graphics
# don't need to worry worry when event graphs have cycles
def set_selection(ev):
for sel in sels:
sel.selection = ev.info["value"]
for sel in sels:
sel.add_event_handler(set_selection, "selection")
fig.show(maintain_aspect=False)
Need to test with more graphics and also test when exceptions are raised in GraphicFeature.set_value()
@apasarkar @FlynnOConnell you guys will love this!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
added a simple example with trivially "synced" selectors:
unit_circle-2025-03-03_22.50.14.mp4
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The decorator is working as expected and exceptions are also raised correctly, @clewis7 if you can test on your end too it should be gtg! This is probably my favorite PR, small few lines decorator that makes life so much easier 🥳
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Mar 4, 2025
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.
super cool! might need to run the docs to update API?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced May 19, 2025
Reviewers
clewis7
clewis7 approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.