Skip to content

make set_feature, reset_feature public #308

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 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions fastplotlib/graphics/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ class Interaction(ABC):
"""Mixin class that makes graphics interactive"""

@abstractmethod
def _set_feature(self, feature: str, new_data: Any, indices: Any):
def set_feature(self, feature: str, new_data: Any, indices: Any):
pass

@abstractmethod
def _reset_feature(self, feature: str):
def reset_feature(self, feature: str):
pass

def link(
Expand Down Expand Up @@ -312,14 +312,14 @@ def _event_handler(self, event):
# the real world object in the pick_info and not the proxy
if wo is event.pick_info["world_object"]:
indices = i
target_info.target._set_feature(
target_info.target.set_feature(
feature=target_info.feature,
new_data=target_info.new_data,
indices=indices,
)
else:
# if target is a single graphic, then indices do not matter
target_info.target._set_feature(
target_info.target.set_feature(
feature=target_info.feature,
new_data=target_info.new_data,
indices=None,
Expand Down
8 changes: 4 additions & 4 deletions fastplotlib/graphics/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ def __init__(
# set it with the actual data
self.data = data

def _set_feature(self, feature: str, new_data: Any, indices: Any):
def set_feature(self, feature: str, new_data: Any, indices: Any):
pass

def _reset_feature(self, feature: str):
def reset_feature(self, feature: str):
pass


Expand Down Expand Up @@ -500,8 +500,8 @@ def vmax(self, value: float):
"""Maximum contrast limit."""
self._material.clim = (self._material.clim[0], value)

def _set_feature(self, feature: str, new_data: Any, indices: Any):
def set_feature(self, feature: str, new_data: Any, indices: Any):
pass

def _reset_feature(self, feature: str):
def reset_feature(self, feature: str):
pass
6 changes: 3 additions & 3 deletions fastplotlib/graphics/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ def _get_linear_selector_init_args(self, padding: float, **kwargs):
def _add_plot_area_hook(self, plot_area):
self._plot_area = plot_area

def _set_feature(self, feature: str, new_data: Any, indices: Any = None):
def set_feature(self, feature: str, new_data: Any, indices: Any = None):
if not hasattr(self, "_previous_data"):
self._previous_data = dict()
elif hasattr(self, "_previous_data"):
self._reset_feature(feature)
self.reset_feature(feature)

feature_instance = getattr(self, feature)
if indices is not None:
Expand All @@ -302,7 +302,7 @@ def _set_feature(self, feature: str, new_data: Any, indices: Any = None):
data=previous, indices=indices
)

def _reset_feature(self, feature: str):
def reset_feature(self, feature: str):
if feature not in self._previous_data.keys():
return

Expand Down
6 changes: 3 additions & 3 deletions fastplotlib/graphics/line_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def _get_linear_selector_init_args(self, padding, **kwargs):
def _add_plot_area_hook(self, plot_area):
self._plot_area = plot_area

def _set_feature(self, feature: str, new_data: Any, indices: Any):
def set_feature(self, feature: str, new_data: Any, indices: Any):
# if single value force to be an array of size 1
if isinstance(indices, (np.integer, int)):
indices = np.array([indices])
Expand All @@ -429,7 +429,7 @@ def _set_feature(self, feature: str, new_data: Any, indices: Any):
if self._previous_data[feature].indices == indices:
return # nothing to change, and this allows bidirectional linking without infinite recursion

self._reset_feature(feature)
self.reset_feature(feature)

# coll_feature = getattr(self[indices], feature)

Expand All @@ -455,7 +455,7 @@ def _set_feature(self, feature: str, new_data: Any, indices: Any):
# since calling `feature._set()` triggers all the feature callbacks
feature_instance._set(new_data)

def _reset_feature(self, feature: str):
def reset_feature(self, feature: str):
if feature not in self._previous_data.keys():
return

Expand Down