Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/astro_image_display_api/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,21 @@ def test_set_get_catalog_style_preserves_extra_keywords(self, catalog):
del retrieved_style["catalog_label"] # Remove the label
assert retrieved_style == style

def test_catalog_has_style_after_loading(self, catalog):
# Check that loading a catalog sets a default style for that catalog.
self.image.load_catalog(catalog, catalog_label="test1")

retrieved_style = self.image.get_catalog_style(catalog_label="test1")
assert isinstance(retrieved_style, dict)
assert "color" in retrieved_style
assert "shape" in retrieved_style
assert "size" in retrieved_style

# Loading again should have the same style
self.image.load_catalog(catalog, catalog_label="test1")
retrieved_style2 = self.image.get_catalog_style(catalog_label="test1")
assert retrieved_style2 == retrieved_style

@pytest.mark.parametrize("catalog_label", ["test1", None])
def test_load_get_single_catalog_with_without_label(self, catalog, catalog_label):
# Make sure we can get a single catalog with or without a label.
Expand Down
5 changes: 5 additions & 0 deletions src/astro_image_display_api/image_viewer_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

__all__ = ["ImageViewerLogic"]


@dataclass
class CatalogInfo:
"""
Expand Down Expand Up @@ -523,7 +524,11 @@ def load_catalog(
# Ensure a catalog always has a style
if catalog_style is None:
if not self._catalogs[catalog_label].style:
# No style has been set, so use the default style
catalog_style = self._default_catalog_style.copy()
else:
# Use the existing style
catalog_style = self._catalogs[catalog_label].style.copy()

self._catalogs[catalog_label].style = catalog_style

Expand Down