@@ -48,18 +48,14 @@ class variable does the trick.
4848 """
4949 self .image = self .image_widget_class (image_width = 250 , image_height = 100 )
5050
51- def _assert_empty_marker_table (self , table ):
51+ def _assert_empty_catalog_table (self , table ):
5252 assert isinstance (table , Table )
5353 assert len (table ) == 0
5454 assert sorted (table .colnames ) == sorted (['x' , 'y' , 'coord' , 'marker name' ])
5555
56- def _get_marker_names_as_set (self ):
57- marks = self .image .get_markers (marker_name = "all" )["marker name" ]
58- if hasattr (marks , 'mask' ) and all (marks .mask ):
59- marker_names = set ()
60- else :
61- marker_names = set (marks )
62- return marker_names
56+ def _get_catalog_names_as_set (self ):
57+ marks = self .image .get_catalog_names ()
58+ return set (marks )
6359
6460 def test_width_height (self ):
6561 assert self .image .image_width == 250
@@ -160,111 +156,91 @@ def test_get_catalog_style_with_multiple_labels_raises_error(self):
160156 with pytest .raises (ValueError , match = 'Multiple catalog styles' ):
161157 self .image .get_catalog_style ()
162158
163- def test_add_markers (self ):
159+ def test_load_catalog (self ):
164160 data = np .arange (10 ).reshape (5 , 2 )
165161 orig_tab = Table (data = data , names = ['x' , 'y' ], dtype = ('float' , 'float' ))
166162 tab = Table (data = data , names = ['x' , 'y' ], dtype = ('float' , 'float' ))
167- self .image .add_markers (tab , x_colname = 'x' , y_colname = 'y' ,
168- skycoord_colname = 'coord' , marker_name = 'test1' )
163+ self .image .load_catalog (tab , x_colname = 'x' , y_colname = 'y' ,
164+ skycoord_colname = 'coord' , catalog_label = 'test1' )
169165
170166
171167 # Regression test for GitHub Issue 45:
172168 # Adding markers should not modify the input data table.
173169 assert (tab == orig_tab ).all ()
174170
175171 # Add more markers under different name.
176- self .image .add_markers (tab , x_colname = 'x' , y_colname = 'y' ,
177- skycoord_colname = 'coord' , marker_name = 'test2' )
172+ self .image .load_catalog (tab , x_colname = 'x' , y_colname = 'y' ,
173+ skycoord_colname = 'coord' , catalog_label = 'test2' )
178174
179- marknames = self ._get_marker_names_as_set ()
175+ marknames = self ._get_catalog_names_as_set ()
180176 assert marknames == set (['test1' , 'test2' ])
181- # assert self.image.get_marker_names() == ['test1', 'test2']
182177
183178 # No guarantee markers will come back in the same order, so sort them.
184- t1 = self .image .get_markers ( marker_name = 'test1' )
179+ t1 = self .image .get_catalog ( catalog_label = 'test1' )
185180 # Sort before comparing
186181 t1 .sort ('x' )
187182 tab .sort ('x' )
188183 assert np .all (t1 ['x' ] == tab ['x' ])
189184 assert (t1 ['y' ] == tab ['y' ]).all ()
190185
191- # That should have given us two copies of the input table
192- t2 = self .image .get_markers (marker_name = "all" )
193- expected = vstack ([tab , tab ], join_type = 'exact' )
186+ t2 = self .image .get_catalog (catalog_label = "test2" )
194187 # Sort before comparing
195188 t2 .sort (['x' , 'y' ])
196- expected .sort (['x' , 'y' ])
197- assert (t2 ['x' ] == expected ['x' ]).all ()
198- assert (t2 ['y' ] == expected ['y' ]).all ()
189+ tab .sort (['x' , 'y' ])
190+ assert (t2 ['x' ] == tab ['x' ]).all ()
191+ assert (t2 ['y' ] == tab ['y' ]).all ()
199192
200- self .image .remove_markers ( marker_name = 'test1' )
201- marknames = self ._get_marker_names_as_set ()
193+ self .image .remove_catalog ( catalog_label = 'test1' )
194+ marknames = self ._get_catalog_names_as_set ()
202195 assert marknames == set (['test2' ])
203196
204197 # Add markers with no marker name and check we can retrieve them
205198 # using the default marker name
206- self .image .add_markers (tab , x_colname = 'x' , y_colname = 'y' ,
199+ self .image .load_catalog (tab , x_colname = 'x' , y_colname = 'y' ,
207200 skycoord_colname = 'coord' )
208201 # Don't care about the order of the marker names so use set instead of
209202 # list.
210- marknames = self ._get_marker_names_as_set ()
203+ marknames = self ._get_catalog_names_as_set ()
211204 assert (set (marknames ) == set (['test2' ]))
212205
213206 # Clear markers to not pollute other tests.
214- self .image .reset_markers ( )
215- marknames = self ._get_marker_names_as_set ()
207+ self .image .remove_catalog ( catalog_label = '*' )
208+ marknames = self ._get_catalog_names_as_set ()
216209 assert len (marknames ) == 0
217- self ._assert_empty_marker_table (self .image .get_markers ( marker_name = "all" ))
210+ self ._assert_empty_catalog_table (self .image .get_catalog ( ))
218211 # Check that no markers remain after clearing
219- tab = self .image .get_markers ()
220- self ._assert_empty_marker_table (tab )
212+ tab = self .image .get_catalog ()
213+ self ._assert_empty_catalog_table (tab )
221214
222215 # Check that retrieving a marker set that doesn't exist returns
223216 # an empty table with the right columns
224- tab = self .image .get_markers ( marker_name = 'test1' )
225- self ._assert_empty_marker_table (tab )
217+ tab = self .image .get_catalog ( catalog_label = 'test1' )
218+ self ._assert_empty_catalog_table (tab )
226219
227- def test_get_markers_accepts_list_of_names (self ):
228- # Check that the get_markers method accepts a list of marker names
229- # and returns a table with all the markers from all the named sets.
230- data = np .arange (10 ).reshape ((5 , 2 ))
231- tab = Table (data = data , names = ['x' , 'y' ])
232- self .image .add_markers (tab , marker_name = 'test1' )
233- self .image .add_markers (tab , marker_name = 'test2' )
234-
235- # No guarantee markers will come back in the same order, so sort them.
236- t1 = self .image .get_markers (marker_name = ['test1' , 'test2' ])
237- # Sort before comparing
238- t1 .sort ('x' )
239- expected = vstack ([tab , tab ], join_type = 'exact' )
240- expected .sort ('x' )
241- np .testing .assert_array_equal (t1 ['x' ], expected ['x' ])
242- np .testing .assert_array_equal (t1 ['y' ], expected ['y' ])
243-
244- def test_remove_markers (self ):
220+ def test_remove_catalog (self ):
245221 with pytest .raises (ValueError , match = 'arf' ):
246- self .image .remove_markers ( marker_name = 'arf' )
222+ self .image .remove_catalog ( catalog_label = 'arf' )
247223
248- def test_remove_markers_name_all (self ):
224+ def test_remove_catalogs_name_all (self ):
249225 data = np .arange (10 ).reshape (5 , 2 )
250226 tab = Table (data = data , names = ['x' , 'y' ])
251- self .image .add_markers (tab , marker_name = 'test1' )
252- self .image .add_markers (tab , marker_name = 'test2' )
227+ self .image .load_catalog (tab , catalog_label = 'test1' )
228+ self .image .load_catalog (tab , catalog_label = 'test2' )
253229
254- self .image .remove_markers ( marker_name = 'all ' )
255- self ._assert_empty_marker_table (self .image .get_markers ( marker_name = 'all' ))
230+ self .image .remove_catalog ( catalog_label = '* ' )
231+ self ._assert_empty_catalog_table (self .image .get_catalog ( ))
256232
257- def test_remove_marker_accepts_list (self ):
233+ def test_remove_catalog_accepts_list (self ):
258234 data = np .arange (10 ).reshape (5 , 2 )
259235 tab = Table (data = data , names = ['x' , 'y' ])
260- self .image .add_markers (tab , marker_name = 'test1' )
261- self .image .add_markers (tab , marker_name = 'test2' )
236+ self .image .load_catalog (tab , catalog_label = 'test1' )
237+ self .image .load_catalog (tab , catalog_label = 'test2' )
262238
263- self .image .remove_markers ( marker_name = ['test1' , 'test2' ])
264- marks = self .image .get_markers ( marker_name = 'all' )
265- self ._assert_empty_marker_table (marks )
239+ self .image .remove_catalog ( catalog_label = ['test1' , 'test2' ])
240+ marks = self .image .get_catalog ( )
241+ self ._assert_empty_catalog_table (marks )
266242
267- def test_adding_markers_as_world (self , data , wcs ):
243+ def test_adding_catalog_as_world (self , data , wcs ):
268244 ndd = NDData (data = data , wcs = wcs )
269245 self .image .load_nddata (ndd )
270246
@@ -273,8 +249,8 @@ def test_adding_markers_as_world(self, data, wcs):
273249 marks_pix = Table (data = pixels , names = ['x' , 'y' ], dtype = ('float' , 'float' ))
274250 marks_coords = wcs .pixel_to_world (marks_pix ['x' ], marks_pix ['y' ])
275251 mark_coord_table = Table (data = [marks_coords ], names = ['coord' ])
276- self .image .add_markers (mark_coord_table , use_skycoord = True )
277- result = self .image .get_markers ()
252+ self .image .load_catalog (mark_coord_table , use_skycoord = True )
253+ result = self .image .get_catalog ()
278254 # Check the x, y positions as long as we are testing things...
279255 # The first test had one entry that was zero, so any check
280256 # based on rtol will not work. Added a small atol to make sure
0 commit comments