Skip to content

Commit 233a247

Browse files
committed
Use copies of style dictionaries in tests
1 parent 5acd0f7 commit 233a247

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
@@ -17,7 +17,7 @@
1717
@dataclass
1818
class CatalogInfo:
1919
"""
20-
A named tuple to hold information about a catalog.
20+
Class to hold information about a catalog.
2121
"""
2222
style: dict[str, Any] = field(default_factory=dict)
2323
data: Table | None = None
@@ -153,7 +153,7 @@ def get_catalog_style(self, catalog_label=None) -> dict[str, Any]:
153153
"""
154154
catalog_label = self._resolve_catalog_label(catalog_label)
155155

156-
style = self._catalogs[catalog_label].style
156+
style = self._catalogs[catalog_label].style.copy()
157157
style["catalog_label"] = catalog_label
158158
return style
159159

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

291291
# Marker-related methods
292292
def load_catalog(self, table: Table, x_colname: str = 'x', y_colname: str = 'y',
293-
skycoord_colname: str = 'coord', use_skycoord: bool = True,
293+
skycoord_colname: str = 'coord', use_skycoord: bool = False,
294294
catalog_label: str | None = None,
295295
catalog_style: dict | None = None) -> None:
296296
try:

src/astro_image_display_api/interface_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def load_catalog(self, table: Table, x_colname: str = 'x', y_colname: str = 'y',
7878
catalog_label: str | None = None,
7979
catalog_style: dict | None = None) -> None:
8080
"""
81-
Add markers to the viewer at positions given by a catalog.
81+
Add catalog entries to the viewer at positions given by the catalog.
8282
8383
Parameters
8484
----------

src/astro_image_display_api/widget_api_test.py

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

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

179179
assert set_style_input == retrieved_style
@@ -367,9 +367,12 @@ def test_load_catalog_with_style_sets_style(self, catalog):
367367
# for that catalog.
368368
style = dict(color='blue', shape='x', size=10)
369369
self.image.load_catalog(catalog, catalog_label='test1',
370-
catalog_style=style)
370+
catalog_style=style.copy())
371371

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

375378
def test_remove_catalog(self):

0 commit comments

Comments
 (0)