From 92ddef76ea030f1f7f0fcc112360cd0b8d467d67 Mon Sep 17 00:00:00 2001 From: Celia Parts Date: Fri, 26 Sep 2025 13:56:18 -0400 Subject: [PATCH 1/4] adding get_overlays call to each add overlays method --- src/ipyaladin/widget.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ipyaladin/widget.py b/src/ipyaladin/widget.py index df2cc08e..07e87dad 100644 --- a/src/ipyaladin/widget.py +++ b/src/ipyaladin/widget.py @@ -550,6 +550,7 @@ def add_markers( "options": catalog_options, } ) + self.get_overlays() def _save_file(self, path: str, buffer: bytes) -> None: """Save a file from a buffer. @@ -673,6 +674,7 @@ def add_catalog_from_URL( "options": votable_options, } ) + self.get_overlays() @widget_should_be_loaded def add_fits(self, fits: Union[str, Path, HDUList], **image_options: any) -> None: @@ -878,6 +880,7 @@ def add_table( {"event_name": "add_table", "options": table_options}, buffers=[table_bytes.getvalue()], ) + self.get_overlays() @widget_should_be_loaded def add_graphic_overlay_from_region( @@ -958,6 +961,7 @@ def add_graphic_overlay_from_region( "graphic_options": graphic_options, } ) + self.get_overlays() @widget_should_be_loaded def add_overlay_from_stcs( @@ -1023,6 +1027,7 @@ def add_graphic_overlay_from_stcs( "graphic_options": overlay_options, } ) + self.get_overlays() @widget_should_be_loaded def remove_overlay(self, overlay_name: Union[Iterable[str], str]) -> None: From 699da68423dd4258ad1392d6c986a55327db5a04 Mon Sep 17 00:00:00 2001 From: Celia Parts Date: Fri, 26 Sep 2025 14:15:36 -0400 Subject: [PATCH 2/4] updating add_table to handle widget not being ready when get_overlays called --- src/ipyaladin/widget.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ipyaladin/widget.py b/src/ipyaladin/widget.py index 07e87dad..721cccfa 100644 --- a/src/ipyaladin/widget.py +++ b/src/ipyaladin/widget.py @@ -880,7 +880,16 @@ def add_table( {"event_name": "add_table", "options": table_options}, buffers=[table_bytes.getvalue()], ) - self.get_overlays() + if not self._ready: + warnings.warn( + "The table has not yet finished loading into the widget, so the " + "overlays list has not been updated. Please call `get_overlays()` " + "to update the list.", + UserWarning, + stacklevel=2, + ) + else: + self.get_overlays() @widget_should_be_loaded def add_graphic_overlay_from_region( From 66cbcd011bf3f561f183abb4a2538a1475724bde Mon Sep 17 00:00:00 2001 From: Celia Parts Date: Fri, 26 Sep 2025 14:32:02 -0400 Subject: [PATCH 3/4] updating pytest to account for multiple mock messages --- src/tests/test_aladin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_aladin.py b/src/tests/test_aladin.py index f8b61d51..e1cfdb71 100644 --- a/src/tests/test_aladin.py +++ b/src/tests/test_aladin.py @@ -255,7 +255,7 @@ def test_add_graphic_overlay_from_stcs_iterables( mock_send = Mock() monkeypatch.setattr(Aladin, "send", mock_send) aladin.add_graphic_overlay_from_stcs(stcs_strings) - regions_info = mock_send.call_args[0][0]["regions_infos"] + regions_info = mock_send.call_args_list[0].args[0]["regions_infos"] assert isinstance(regions_info, list) assert regions_info[0]["infos"]["stcs"] in stcs_strings From e2773c0fc613ce79dc65021527a0288d34b0581c Mon Sep 17 00:00:00 2001 From: Celia Parts Date: Fri, 3 Oct 2025 10:15:25 -0400 Subject: [PATCH 4/4] updating to js-based implementation --- js/models/message_handler.js | 4 ++++ src/ipyaladin/widget.py | 14 -------------- src/tests/test_aladin.py | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/js/models/message_handler.js b/js/models/message_handler.js index 28c9e266..a022d762 100644 --- a/js/models/message_handler.js +++ b/js/models/message_handler.js @@ -28,6 +28,7 @@ export default class MessageHandler { ); } catalog.addSources(markers); + this.messageHandler.handleGetOverlays(); } handleChangeFoV(msg) { @@ -75,6 +76,7 @@ export default class MessageHandler { handleAddCatalogFromURL(msg) { const options = convertOptionNamesToCamelCase(msg["options"] || {}); this.aladin.addCatalog(A.catalogFromURL(msg["votable_URL"], options)); + this.messageHandler.handleGetOverlays(); } handleAddMOCFromURL(msg) { @@ -138,6 +140,7 @@ export default class MessageHandler { break; } } + this.messageHandler.handleGetOverlays(); } handleRemoveOverlay = (msg) => { @@ -232,6 +235,7 @@ export default class MessageHandler { options, (catalog) => { this.aladin.addCatalog(catalog); + this.messageHandler.handleGetOverlays(); }, false, ); diff --git a/src/ipyaladin/widget.py b/src/ipyaladin/widget.py index 721cccfa..df2cc08e 100644 --- a/src/ipyaladin/widget.py +++ b/src/ipyaladin/widget.py @@ -550,7 +550,6 @@ def add_markers( "options": catalog_options, } ) - self.get_overlays() def _save_file(self, path: str, buffer: bytes) -> None: """Save a file from a buffer. @@ -674,7 +673,6 @@ def add_catalog_from_URL( "options": votable_options, } ) - self.get_overlays() @widget_should_be_loaded def add_fits(self, fits: Union[str, Path, HDUList], **image_options: any) -> None: @@ -880,16 +878,6 @@ def add_table( {"event_name": "add_table", "options": table_options}, buffers=[table_bytes.getvalue()], ) - if not self._ready: - warnings.warn( - "The table has not yet finished loading into the widget, so the " - "overlays list has not been updated. Please call `get_overlays()` " - "to update the list.", - UserWarning, - stacklevel=2, - ) - else: - self.get_overlays() @widget_should_be_loaded def add_graphic_overlay_from_region( @@ -970,7 +958,6 @@ def add_graphic_overlay_from_region( "graphic_options": graphic_options, } ) - self.get_overlays() @widget_should_be_loaded def add_overlay_from_stcs( @@ -1036,7 +1023,6 @@ def add_graphic_overlay_from_stcs( "graphic_options": overlay_options, } ) - self.get_overlays() @widget_should_be_loaded def remove_overlay(self, overlay_name: Union[Iterable[str], str]) -> None: diff --git a/src/tests/test_aladin.py b/src/tests/test_aladin.py index e1cfdb71..f8b61d51 100644 --- a/src/tests/test_aladin.py +++ b/src/tests/test_aladin.py @@ -255,7 +255,7 @@ def test_add_graphic_overlay_from_stcs_iterables( mock_send = Mock() monkeypatch.setattr(Aladin, "send", mock_send) aladin.add_graphic_overlay_from_stcs(stcs_strings) - regions_info = mock_send.call_args_list[0].args[0]["regions_infos"] + regions_info = mock_send.call_args[0][0]["regions_infos"] assert isinstance(regions_info, list) assert regions_info[0]["infos"]["stcs"] in stcs_strings