Skip to content

Commit

Permalink
🎨 Change add_overlay_* to add_graphic_overlay_* and fix example 9
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys authored and ManonMarchand committed May 27, 2024
1 parent 689b81d commit 400c69e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
20 changes: 11 additions & 9 deletions examples/9_Shapes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
")"
]
},
{
Expand Down Expand Up @@ -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\")"
]
},
{
Expand All @@ -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\")"
]
},
{
Expand All @@ -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\")"
]
},
{
Expand All @@ -140,7 +142,7 @@
" unit=\"deg\",\n",
" )\n",
")\n",
"aladin.add_overlay(polygon, color=\"yellow\")"
"aladin.add_graphic_overlay_from_region(polygon, color=\"yellow\")"
]
},
{
Expand All @@ -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\")"
]
}
],
Expand Down
22 changes: 21 additions & 1 deletion src/ipyaladin/aladin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 400c69e

Please sign in to comment.