33import numpy as np
44from glue .core .roi import XRangeROI
55from glue .core .edit_subset_mode import NewMode
6- from ipywidgets .widgets import widget_serialization
76
87from jdaviz .configs .specviz .plugins .line_analysis .line_analysis import _coerce_unit
98from jdaviz .core .events import LineIdentifyMessage
@@ -14,10 +13,8 @@ def test_plugin(specviz_helper, spectrum1d):
1413 label = "Test 1D Spectrum"
1514 specviz_helper .load_spectrum (spectrum1d , data_label = label )
1615
17- specviz_helper .app .state .drawer = True
18- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
19- plugin_index = tray_names .index ('specviz-line-analysis' )
20- specviz_helper .app .state .tray_items_open = [plugin_index ]
16+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
17+ plugin .open_in_tray ()
2118
2219 # continuum should be created, plotted, and visible
2320 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
@@ -33,8 +30,6 @@ def test_plugin(specviz_helper, spectrum1d):
3330 sv .apply_roi (XRangeROI (6500 , 7400 ))
3431 specviz_helper .app .state .drawer = True
3532
36- ipy_model_id = specviz_helper .app .state .tray_items [plugin_index ]['widget' ]
37- plugin = widget_serialization ['from_json' ](ipy_model_id , None )
3833 assert 'Subset 1' in plugin .spectral_subset .labels
3934 plugin .selected_subset = 'Subset 1'
4035 plugin .selected_continuum = 'Surrounding'
@@ -121,10 +116,8 @@ def test_continuum_surrounding_spectral_subset(specviz_helper, spectrum1d):
121116 label = "Test 1D Spectrum"
122117 specviz_helper .load_spectrum (spectrum1d , data_label = label )
123118
124- specviz_helper .app .state .drawer = True
125- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
126- plugin_index = tray_names .index ('specviz-line-analysis' )
127- specviz_helper .app .state .tray_items_open = [plugin_index ]
119+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
120+ plugin .open_in_tray ()
128121
129122 # continuum should be created, plotted, and visible
130123 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
@@ -150,10 +143,8 @@ def test_continuum_spectral_same_value(specviz_helper, spectrum1d):
150143 label = "Test 1D Spectrum"
151144 specviz_helper .load_spectrum (spectrum1d , data_label = label )
152145
153- specviz_helper .app .state .drawer = True
154- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
155- plugin_index = tray_names .index ('specviz-line-analysis' )
156- specviz_helper .app .state .tray_items_open = [plugin_index ]
146+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
147+ plugin .open_in_tray ()
157148
158149 # continuum should be created, plotted, and visible
159150 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
@@ -179,10 +170,8 @@ def test_continuum_surrounding_invalid_width(specviz_helper, spectrum1d):
179170 label = "Test 1D Spectrum"
180171 specviz_helper .load_spectrum (spectrum1d , data_label = label )
181172
182- specviz_helper .app .state .drawer = True
183- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
184- plugin_index = tray_names .index ('specviz-line-analysis' )
185- specviz_helper .app .state .tray_items_open = [plugin_index ]
173+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
174+ plugin .open_in_tray ()
186175
187176 # continuum should be created, plotted, and visible
188177 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
@@ -206,10 +195,8 @@ def test_continuum_subset_spectral_entire(specviz_helper, spectrum1d):
206195 label = "Test 1D Spectrum"
207196 specviz_helper .load_spectrum (spectrum1d , data_label = label )
208197
209- specviz_helper .app .state .drawer = True
210- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
211- plugin_index = tray_names .index ('specviz-line-analysis' )
212- specviz_helper .app .state .tray_items_open = [plugin_index ]
198+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
199+ plugin .open_in_tray ()
213200
214201 # continuum should be created, plotted, and visible
215202 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
@@ -235,10 +222,8 @@ def test_continuum_subset_spectral_subset2(specviz_helper, spectrum1d):
235222 label = "Test 1D Spectrum"
236223 specviz_helper .load_spectrum (spectrum1d , data_label = label )
237224
238- specviz_helper .app .state .drawer = True
239- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
240- plugin_index = tray_names .index ('specviz-line-analysis' )
241- specviz_helper .app .state .tray_items_open = [plugin_index ]
225+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
226+ plugin .open_in_tray ()
242227
243228 # continuum should be created, plotted, and visible
244229 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
@@ -270,10 +255,8 @@ def test_continuum_surrounding_no_right(specviz_helper, spectrum1d):
270255 label = "Test 1D Spectrum"
271256 specviz_helper .load_spectrum (spectrum1d , data_label = label )
272257
273- specviz_helper .app .state .drawer = True
274- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
275- plugin_index = tray_names .index ('specviz-line-analysis' )
276- specviz_helper .app .state .tray_items_open = [plugin_index ]
258+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
259+ plugin .open_in_tray ()
277260
278261 # continuum should be created, plotted, and visible
279262 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
@@ -300,10 +283,8 @@ def test_continuum_surrounding_no_left(specviz_helper, spectrum1d):
300283 label = "Test 1D Spectrum"
301284 specviz_helper .load_spectrum (spectrum1d , data_label = label )
302285
303- specviz_helper .app .state .drawer = True
304- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
305- plugin_index = tray_names .index ('specviz-line-analysis' )
306- specviz_helper .app .state .tray_items_open = [plugin_index ]
286+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
287+ plugin .open_in_tray ()
307288
308289 # continuum should be created, plotted, and visible
309290 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
@@ -330,10 +311,8 @@ def test_subset_changed(specviz_helper, spectrum1d):
330311 label = "Test 1D Spectrum"
331312 specviz_helper .load_spectrum (spectrum1d , data_label = label )
332313
333- specviz_helper .app .state .drawer = True
334- tray_names = [ti ['name' ] for ti in specviz_helper .app .state .tray_items ]
335- plugin_index = tray_names .index ('specviz-line-analysis' )
336- specviz_helper .app .state .tray_items_open = [plugin_index ]
314+ plugin = specviz_helper .app .get_tray_item_from_name ('specviz-line-analysis' )
315+ plugin .open_in_tray ()
337316
338317 # continuum should be created, plotted, and visible
339318 sv = specviz_helper .app .get_viewer ('spectrum-viewer' )
0 commit comments