Skip to content

Commit 10bff74

Browse files
committed
Use copies of style dictionaries in tests
1 parent 2d4061a commit 10bff74

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/astro_image_display_api/dummy_viewer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@dataclass
1919
class CatalogInfo:
2020
"""
21-
A named tuple to hold information about a catalog.
21+
Class to hold information about a catalog.
2222
"""
2323
style: dict[str, Any] = field(default_factory=dict)
2424
data: Table | None = None
@@ -143,7 +143,7 @@ def get_catalog_style(self, catalog_label=None) -> dict[str, Any]:
143143
"""
144144
catalog_label = self._resolve_catalog_label(catalog_label)
145145

146-
style = self._catalogs[catalog_label].style
146+
style = self._catalogs[catalog_label].style.copy()
147147
style["catalog_label"] = catalog_label
148148
return style
149149

@@ -280,7 +280,7 @@ def save(self, filename: str | os.PathLike, overwrite: bool = False) -> None:
280280

281281
# Marker-related methods
282282
def load_catalog(self, table: Table, x_colname: str = 'x', y_colname: str = 'y',
283-
skycoord_colname: str = 'coord', use_skycoord: bool = True,
283+
skycoord_colname: str = 'coord', use_skycoord: bool = False,
284284
catalog_label: str | None = None,
285285
catalog_style: dict | None = None) -> None:
286286
try:

src/astro_image_display_api/interface_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def load_catalog(self, table: Table, x_colname: str = 'x', y_colname: str = 'y',
127127
catalog_label: str | None = None,
128128
catalog_style: dict | None = None) -> None:
129129
"""
130-
Add markers to the viewer at positions given by a catalog.
130+
Add catalog entries to the viewer at positions given by the catalog.
131131
132132
Parameters
133133
----------

src/astro_image_display_api/widget_api_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_set_get_catalog_style_no_labels(self, catalog):
158158
self.image.load_catalog(catalog)
159159
# Check that setting a marker style works
160160
marker_settings = dict(color='red', shape='x', size=10)
161-
self.image.set_catalog_style(**marker_settings)
161+
self.image.set_catalog_style(**marker_settings.copy())
162162

163163
retrieved_style = self.image.get_catalog_style()
164164
# Check that the marker style is set correctly
@@ -174,7 +174,7 @@ def test_set_get_catalog_style_with_single_label(self, catalog):
174174
self.image.load_catalog(catalog, catalog_label='test1')
175175
set_style_input = dict(catalog_label='test1', color='blue',
176176
shape='square', size=5)
177-
self.image.set_catalog_style(**set_style_input)
177+
self.image.set_catalog_style(**set_style_input.copy())
178178
retrieved_style = self.image.get_catalog_style()
179179

180180
assert set_style_input == retrieved_style
@@ -368,9 +368,12 @@ def test_load_catalog_with_style_sets_style(self, catalog):
368368
# for that catalog.
369369
style = dict(color='blue', shape='x', size=10)
370370
self.image.load_catalog(catalog, catalog_label='test1',
371-
catalog_style=style)
371+
catalog_style=style.copy())
372372

373373
retrieved_style = self.image.get_catalog_style(catalog_label='test1')
374+
375+
# Add catalog_label to the style for comparison
376+
style['catalog_label'] = 'test1'
374377
assert retrieved_style == style
375378

376379
def test_remove_catalog(self):

0 commit comments

Comments
 (0)