Skip to content

Commit

Permalink
Return an empty table if markers not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Aug 24, 2023
1 parent cd45745 commit 4fc238d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion astrowidgets/ginga.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ def get_markers(self, x_colname='x', y_colname='y',
tables.append(table)

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

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

Expand Down
3 changes: 2 additions & 1 deletion astrowidgets/interface_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def get_markers(self, x_colname: str = 'x', y_colname: str = 'y',
Returns
-------
table : `astropy.table.Table`
The table containing the marker positions.
The table containing the marker positions. If no markers match the
``marker_name`` parameter, an empty table is returned.
"""
raise NotImplementedError

Expand Down
3 changes: 2 additions & 1 deletion astrowidgets/tests/widget_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ def test_remove_marker_accepts_list(self):
self.image.add_markers(tab, marker_name='test2')

self.image.remove_markers(marker_name=['test1', 'test2'])
assert self.image.get_markers(marker_name='all') is None
marks = self.image.get_markers(marker_name='all')
assert isinstance(marks, Table) and len(marks) == 0

def test_adding_markers_as_world(self, data, wcs):
ndd = NDData(data=data, wcs=wcs)
Expand Down

0 comments on commit 4fc238d

Please sign in to comment.