← 返回首页
implemenet `@block_reentrance` decorator by kushalkolar · Pull Request #744 · fastplotlib/fastplotlib · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

implemenet @block_reentrance decorator#744

Merged
clewis7 merged 4 commits into
mainfrom
gfeature-block-reentrant
Mar 5, 2025
Merged

implemenet @block_reentrance decorator#744
clewis7 merged 4 commits into
mainfrom
gfeature-block-reentrant

Conversation

kushalkolar commented Mar 3, 2025
edited
Loading

Copy link
Copy Markdown
Member

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 requested a review from clewis7 as a code owner March 3, 2025 19:59

Copy link
Copy Markdown
Member Author

added a simple example with trivially "synced" selectors:

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

Copy link
Copy Markdown
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 🥳

clewis7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

super cool! might need to run the docs to update API?

Comment thread examples/selection_tools/unit_circle.py Show resolved Hide resolved
Comment thread examples/selection_tools/unit_circle.py Show resolved Hide resolved

Copy link
Copy Markdown
Member Author

No API changes here.

clewis7 merged commit 3362669 into main Mar 5, 2025
clewis7 deleted the gfeature-block-reentrant branch March 5, 2025 22:17
kushalkolar mentioned this pull request Mar 14, 2025
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Footer

© 2026 GitHub, Inc.