Skip to content
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

Remove viewer-specific code from __gluestate__ and __setgluestate__ on base Application class #2510

Merged
merged 4 commits into from
Aug 16, 2024
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
2 changes: 1 addition & 1 deletion glue/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@

def name_from_cmap(self, cmap_desired):
for name, cmap in self.members:
if cmap is cmap_desired:
if cmap is cmap_desired or cmap.name == cmap_desired.name:

Check warning on line 393 in glue/config.py

View check run for this annotation

Codecov / codecov/patch

glue/config.py#L393

Added line #L393 was not covered by tests
return name
raise ValueError("Could not find name for colormap")

Expand Down
12 changes: 3 additions & 9 deletions glue/core/application_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,22 +352,16 @@ def set_data_color(self, color, alpha):
data.style.alpha = alpha

def __gluestate__(self, context):
viewers = [list(map(context.id, tab)) for tab in self.viewers]
data = self.session.data_collection
from glue.main import _loaded_plugins
return dict(session=context.id(self.session), viewers=viewers,
data=context.id(data), plugins=_loaded_plugins)
return dict(session=context.id(self.session),
data=context.id(data),
plugins=_loaded_plugins)

@classmethod
def __setgluestate__(cls, rec, context):
self = cls(data_collection=context.object(rec['data']))
# manually register the newly-created session, which
# the viewers need
context.register_object(rec['session'], self.session)
for i, tab in enumerate(rec['viewers']):
if self.tab(i) is None:
self.new_tab()
for v in tab:
viewer = context.object(v)
self.add_widget(viewer, tab=i, hold_position=True)
return self
Loading