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

Interactivity #84

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implementing reset_feature
  • Loading branch information
clewis7 committed Dec 23, 2022
commit 7454ae09470943572c1613390b0be4ae6e67c0a3
14 changes: 10 additions & 4 deletions 14 fastplotlib/graphics/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from abc import ABC, abstractmethod
from dataclasses import dataclass
# from .linecollection import LineCollection

class Graphic:
def __init__(
Expand Down Expand Up @@ -139,7 +140,7 @@ def _set_feature(self, feature: str, new_data: Any, indices: Any):
pass

@abstractmethod
def _reset_feature(self):
def _reset_feature(self, feature: str, old_data: Any, indices: Any):
pass

<<<<<<< HEAD
Expand All @@ -165,17 +166,18 @@ def link(self, event_type: str, target: Graphic, feature: str, new_data: Any, in

if event_type in self.registered_callbacks.keys():
self.registered_callbacks[event_type].append(
CallbackData(target=target, feature=feature, new_data=new_data))
CallbackData(target=target, feature=feature, new_data=new_data, old_data=getattr(target, feature).copy()))
else:
self.registered_callbacks[event_type] = list()
self.registered_callbacks[event_type].append(
CallbackData(target=target, feature=feature, new_data=new_data))
CallbackData(target=target, feature=feature, new_data=new_data, old_data=getattr(target, feature).copy()))

>>>>>>> 0f22531 (small changes)
def event_handler(self, event):
if event.type in self.registered_callbacks.keys():
for target_info in self.registered_callbacks[event.type]:
target_info.target._set_feature(feature=target_info.feature, new_data=target_info.new_data)
target_info.target._reset_feature(feature=target_info.feature, old_data=target_info.old_data, indices=None)
target_info.target._set_feature(feature=target_info.feature, new_data=target_info.new_data, indices=None)

>>>>>>> e203cff (updates to line, works w previous example)
@dataclass
Expand All @@ -198,4 +200,8 @@ def __init__(self, target: Graphic, feature: str, new_data: Any):
target: Graphic
feature: str
new_data: Any
<<<<<<< HEAD
>>>>>>> 0f22531 (small changes)
=======
old_data: Any
>>>>>>> bc688fc (implementing reset_feature)
10 changes: 10 additions & 0 deletions 10 fastplotlib/graphics/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def _set_feature(self, feature: str, new_data: Any, indices: Any = None):
else:
raise ValueError("name arg is not a valid feature")

<<<<<<< HEAD
<<<<<<< HEAD
def link(self, event_type: str, target: Graphic, feature: str, new_data: Any, indices_mapper: callable = None):
valid_events = ["click"]
Expand Down Expand Up @@ -170,3 +171,12 @@ def event_handler(self, event):
def _reset_feature():
pass
>>>>>>> 0f22531 (small changes)
=======
def _reset_feature(self, feature: str, old_data: Any, indices: Any = None):
if feature in ["colors", "data"]:
update_func = getattr(self, f"update_{feature}")
update_func(old_data)
else:
raise ValueError("name arg is not a valid feature")

>>>>>>> bc688fc (implementing reset_feature)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.