Skip to content

Commit

Permalink
Update ginga backend to follow new get_markers API
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Aug 27, 2023
1 parent 942e09e commit 38dbe5b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions astrowidgets/ginga.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ def get_markers(self, x_colname='x', y_colname='y',
Table of markers, if any, or ``None``.
"""
default_column_names = [x_colname, y_colname, skycoord_colname, 'marker name']

empty_table = Table(names=default_column_names)

if marker_name is None:
marker_name = self._default_mark_tag_name

Expand All @@ -574,7 +578,7 @@ def get_markers(self, x_colname='x', y_colname='y',
y_colname=y_colname,
skycoord_colname=skycoord_colname,
marker_name=name)
if table is None:
if len(table) == 0:
# No markers by this name, skip it
continue

Expand All @@ -588,7 +592,7 @@ def get_markers(self, x_colname='x', y_colname='y',

if len(tables) == 0:
# No markers at all, return an empty table
return Table()
return empty_table

stacked = vstack(tables, join_type='exact')

Expand All @@ -601,15 +605,13 @@ def get_markers(self, x_colname='x', y_colname='y',
# where that table is empty will be handled in a moment.
if (marker_name not in self._marktags
and marker_name != self._default_mark_tag_name):
raise ValueError(f"No markers named '{marker_name}' found.")
return empty_table

try:
c_mark = self._viewer.canvas.get_object_by_tag(marker_name)
except Exception:
# No markers in this table. Issue a warning and continue
warnings.warn(f"Marker set named '{marker_name}' is empty",
category=UserWarning)
return None
except Exception: # Keep this broad -- unclear what exceptions can be raised
# No markers in this table.
return empty_table

image = self._viewer.get_image()
xy_col = []
Expand Down

0 comments on commit 38dbe5b

Please sign in to comment.