Skip to content

Commit d584fe1

Browse files
committed
Use copies of style dictionaries in tests
1 parent 1157f21 commit d584fe1

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

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

269269
# Marker-related methods
270270
def load_catalog(self, table: Table, x_colname: str = 'x', y_colname: str = 'y',
271-
skycoord_colname: str = 'coord', use_skycoord: bool = True,
271+
skycoord_colname: str = 'coord', use_skycoord: bool = False,
272272
catalog_label: str | None = None,
273273
catalog_style: dict | None = None) -> None:
274274
try:

src/astro_image_display_api/interface_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def load_catalog(self, table: Table, x_colname: str = 'x', y_colname: str = 'y',
100100
catalog_label: str | None = None,
101101
catalog_style: dict | None = None) -> None:
102102
"""
103-
Add markers to the viewer at positions given by a catalog.
103+
Add catalog entries to the viewer at positions given by the catalog.
104104
105105
Parameters
106106
----------

src/astro_image_display_api/widget_api_test.py

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

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

178178
assert set_style_input == retrieved_style
@@ -366,9 +366,12 @@ def test_load_catalog_with_style_sets_style(self, catalog):
366366
# for that catalog.
367367
style = dict(color='blue', shape='x', size=10)
368368
self.image.load_catalog(catalog, catalog_label='test1',
369-
catalog_style=style)
369+
catalog_style=style.copy())
370370

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

374377
def test_remove_catalog(self):

0 commit comments

Comments
 (0)