Skip to content

Commit 87b0116

Browse files
committed
Clarify that loading a catalog for an existing catalog replaces the data
1 parent 402d635 commit 87b0116

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/astro_image_display_api/api_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def test_load_catalog_multiple_same_label(self, catalog):
534534
self.image.load_catalog(catalog, catalog_label="test1")
535535

536536
retrieved_catalog = self.image.get_catalog(catalog_label="test1")
537-
assert len(retrieved_catalog) == 2 * len(catalog)
537+
assert len(retrieved_catalog) == len(catalog)
538538

539539
def test_load_catalog_with_skycoord_no_wcs(self, catalog, data):
540540
# Check that loading a catalog with skycoord but no x/y and

src/astro_image_display_api/image_viewer_logic.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from astropy import units as u
1010
from astropy.coordinates import SkyCoord
1111
from astropy.nddata import CCDData, NDData
12-
from astropy.table import Table, vstack
12+
from astropy.table import Table
1313
from astropy.units import Quantity
1414
from astropy.visualization import (
1515
AsymmetricPercentileInterval,
@@ -509,17 +509,8 @@ def load_catalog(
509509

510510
catalog_label = self._resolve_catalog_label(catalog_label)
511511

512-
# Either set new data or append to existing data
513-
if (
514-
catalog_label in self._catalogs
515-
and self._catalogs[catalog_label].data is not None
516-
):
517-
# If the catalog already exists, we append to it
518-
old_table = self._catalogs[catalog_label].data
519-
self._catalogs[catalog_label].data = vstack([old_table, to_add])
520-
else:
521-
# If the catalog does not exist, we create a new one
522-
self._catalogs[catalog_label].data = to_add
512+
# Set the new data
513+
self._catalogs[catalog_label].data = to_add
523514

524515
# Ensure a catalog always has a style
525516
if catalog_style is None:

src/astro_image_display_api/interface_definition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ def load_catalog(
345345
"""
346346
Add catalog entries to the viewer at positions given by the catalog.
347347
348+
Loading a catalog using a ``catalog_label`` that already exists will
349+
overwrite the existing catalog with the new one.
350+
348351
Parameters
349352
----------
350353
table : `astropy.table.Table`

0 commit comments

Comments
 (0)