From f60a59811a2578ece3de2c8610ed292e178087e8 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 15 Aug 2024 13:50:44 +0100 Subject: [PATCH 1/4] Work to help restore sessions in Jupyter --- glue/core/application_base.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/glue/core/application_base.py b/glue/core/application_base.py index b200f87c0..03088a025 100644 --- a/glue/core/application_base.py +++ b/glue/core/application_base.py @@ -364,10 +364,4 @@ def __setgluestate__(cls, rec, context): # 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 From 0a797b41b5a54734313da279b98a67da364fbbd1 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 16 Aug 2024 12:11:26 +0100 Subject: [PATCH 2/4] Fixed bug related to colormaps when colormap names match but instances don't - this can happen when reloading sessions --- glue/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glue/config.py b/glue/config.py index 0c970e642..d12b55dce 100644 --- a/glue/config.py +++ b/glue/config.py @@ -390,7 +390,7 @@ def __getitem__(self, cmap_name): 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: return name raise ValueError("Could not find name for colormap") From 7359dba6b8ebd13cf9cd0fe09457a1cea59c6bb5 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 16 Aug 2024 12:17:10 +0100 Subject: [PATCH 3/4] Remove __gluestate__ and __setgluestate__ from base Application class since it is different between Jupyter and Qt glue --- glue/core/application_base.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/glue/core/application_base.py b/glue/core/application_base.py index 03088a025..93e050fe7 100644 --- a/glue/core/application_base.py +++ b/glue/core/application_base.py @@ -350,18 +350,3 @@ def set_data_color(self, color, alpha): for data in self.data_collection: data.style.color = color 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) - - @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) - return self From 41582d5e5fb4329cf4f2e57cf03a8ee836d67c65 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 16 Aug 2024 13:30:04 +0100 Subject: [PATCH 4/4] Added methods back but remove all viewer-specific code --- glue/core/application_base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/glue/core/application_base.py b/glue/core/application_base.py index 93e050fe7..0d286e955 100644 --- a/glue/core/application_base.py +++ b/glue/core/application_base.py @@ -350,3 +350,18 @@ def set_data_color(self, color, alpha): for data in self.data_collection: data.style.color = color data.style.alpha = alpha + + def __gluestate__(self, context): + data = self.session.data_collection + from glue.main import _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) + return self