Skip to content

Navigation Menu

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

implemenet @block_reentrance decorator #744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 5, 2025
Merged

Conversation

kushalkolar
Copy link
Member

@kushalkolar kushalkolar commented Mar 3, 2025

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!

@kushalkolar kushalkolar requested a review from clewis7 as a code owner March 3, 2025 19:59
@kushalkolar
Copy link
Member Author

added a simple example with trivially "synced" selectors:

unit_circle-2025-03-03_22.50.14.mp4

@kushalkolar
Copy link
Member Author

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 🥳

Copy link
Member

@clewis7 clewis7 left a 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?

examples/selection_tools/unit_circle.py Show resolved Hide resolved
examples/selection_tools/unit_circle.py Show resolved Hide resolved
@kushalkolar
Copy link
Member Author

No API changes here.

@clewis7 clewis7 merged commit 3362669 into main Mar 5, 2025
50 of 52 checks passed
@clewis7 clewis7 deleted the gfeature-block-reentrant branch March 5, 2025 22:17
@kushalkolar kushalkolar mentioned this pull request Mar 14, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.