From 400c69eb138400bf6e37d41f32b48418ee048636 Mon Sep 17 00:00:00 2001 From: Xen0Xys Date: Tue, 21 May 2024 09:43:34 +0200 Subject: [PATCH] :art: Change add_overlay_* to add_graphic_overlay_* and fix example 9 --- examples/9_Shapes.ipynb | 20 +++++++++++--------- src/ipyaladin/aladin.py | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/examples/9_Shapes.ipynb b/examples/9_Shapes.ipynb index 55be15c3..9099b1bc 100644 --- a/examples/9_Shapes.ipynb +++ b/examples/9_Shapes.ipynb @@ -35,7 +35,7 @@ "metadata": {}, "outputs": [], "source": [ - "a.add_overlay(\n", + "a.add_graphic_overlay_from_stcs(\n", " \"\"\"Polygon ICRS 202.63748 47.24951 202.46382 47.32391 202.46379 47.32391 202.45459\n", " 47.32391 202.34527 47.20597 202.34527 47.20596 202.34529 47.19710 202.51870\n", " 47.12286 202.52789 47.12286 202.52791 47.12286 202.63746 47.24063 202.63749\n", @@ -47,7 +47,9 @@ " 47.00226 202.52539 47.12018\"\"\",\n", " color=\"red\",\n", ")\n", - "a.add_overlay(\"Circle ICRS 202.4656816 +47.1999842 0.04\", color=\"#4488ee\")" + "a.add_graphic_overlay_from_stcs(\n", + " \"Circle ICRS 202.4656816 +47.1999842 0.04\", color=\"#4488ee\"\n", + ")" ] }, { @@ -92,7 +94,7 @@ "source": [ "circle = CircleSkyRegion(center=aladin.target, radius=Angle(0.5, \"deg\"))\n", "\n", - "aladin.add_overlay(circle, color=\"red\")" + "aladin.add_graphic_overlay_from_region(circle, color=\"red\")" ] }, { @@ -107,7 +109,7 @@ " width=Angle(1, \"deg\"),\n", " angle=Angle(45, \"deg\"),\n", ")\n", - "aladin.add_overlay(ellipse, color=\"blue\")" + "aladin.add_graphic_overlay_from_region(ellipse, color=\"blue\")" ] }, { @@ -120,7 +122,7 @@ " start=aladin.target,\n", " end=aladin.target.directional_offset_by(Angle(0, \"deg\"), Angle(0.5, \"deg\")),\n", ")\n", - "aladin.add_overlay(line, color=\"green\")" + "aladin.add_graphic_overlay_from_region(line, color=\"green\")" ] }, { @@ -140,7 +142,7 @@ " unit=\"deg\",\n", " )\n", ")\n", - "aladin.add_overlay(polygon, color=\"yellow\")" + "aladin.add_graphic_overlay_from_region(polygon, color=\"yellow\")" ] }, { @@ -151,11 +153,11 @@ "source": [ "rectangle = RectangleSkyRegion(\n", " center=aladin.target,\n", - " width=Angle(0.5, \"deg\"),\n", - " height=Angle(0.5, \"deg\"),\n", + " width=Angle(1, \"deg\"),\n", + " height=Angle(1, \"deg\"),\n", " angle=Angle(45, \"deg\"),\n", ")\n", - "aladin.add_overlay(rectangle, color=\"purple\")" + "aladin.add_graphic_overlay_from_region(rectangle, color=\"purple\")" ] } ], diff --git a/src/ipyaladin/aladin.py b/src/ipyaladin/aladin.py index fb53b2dc..f7393f21 100644 --- a/src/ipyaladin/aladin.py +++ b/src/ipyaladin/aladin.py @@ -375,7 +375,7 @@ def add_table(self, table: Union[QTable, Table], **table_options: any) -> None: buffers=[table_bytes.getvalue()], ) - def add_overlay_from_region( + def add_graphic_overlay_from_region( self, region: SupportedRegion, **graphic_options: any, @@ -443,6 +443,26 @@ def add_overlay_from_stcs( The STC-S string. overlay_options: keyword arguments + """ + warnings.warn( + "add_overlay_from_stcs is deprecated, " + "use add_graphic_overlay_from_stcs instead", + DeprecationWarning, + stacklevel=2, + ) + self.add_overlay_from_region(stc_string, **overlay_options) + + def add_graphic_overlay_from_stcs( + self, stc_string: Union[typing.List[str], str], **overlay_options: any + ) -> None: + """Add an overlay layer defined by an STC-S string. + + Parameters + ---------- + stc_string: str + The STC-S string. + overlay_options: keyword arguments + """ region_list = [stc_string] if not isinstance(stc_string, list) else stc_string