diff --git a/jdaviz/configs/cubeviz/plugins/moment_maps/tests/test_moment_maps.py b/jdaviz/configs/cubeviz/plugins/moment_maps/tests/test_moment_maps.py index c3543ec418..7b77c52425 100644 --- a/jdaviz/configs/cubeviz/plugins/moment_maps/tests/test_moment_maps.py +++ b/jdaviz/configs/cubeviz/plugins/moment_maps/tests/test_moment_maps.py @@ -27,7 +27,7 @@ def test_user_api(cubeviz_helper, spectrum1d_cube, spectrum1d_cube_sb_unit, cube with warnings.catch_warnings(): warnings.filterwarnings("ignore", message="No observer defined on WCS.*") - cubeviz_helper.load_data(cube, data_label='test') + cubeviz_helper.load(cube, data_label='test') mm = cubeviz_helper.plugins['Moment Maps'] cmc = mm._obj.continuum_marks['center'] @@ -84,7 +84,7 @@ def test_moment_calculation(cubeviz_helper, spectrum1d_cube, dc = cubeviz_helper.app.data_collection with warnings.catch_warnings(): warnings.filterwarnings("ignore", message="No observer defined on WCS.*") - cubeviz_helper.load_data(cube, data_label='test') + cubeviz_helper.load(cube, data_label='test') flux_viewer = cubeviz_helper.app.get_viewer(cubeviz_helper._default_flux_viewer_reference_name) @@ -175,7 +175,7 @@ def test_moment_calculation(cubeviz_helper, spectrum1d_cube, def test_moment_velocity_calculation(cubeviz_helper, spectrum1d_cube): with warnings.catch_warnings(): warnings.filterwarnings("ignore", message="No observer defined on WCS.*") - cubeviz_helper.load_data(spectrum1d_cube, data_label='test') + cubeviz_helper.load_(spectrum1d_cube, data_label='test') uncert_viewer = cubeviz_helper.app.get_viewer("uncert-viewer") @@ -228,7 +228,7 @@ def test_moment_velocity_calculation(cubeviz_helper, spectrum1d_cube): def test_moment_frequency_unit_conversion(cubeviz_helper, spectrum1d_cube_larger): with warnings.catch_warnings(): warnings.filterwarnings("ignore", message="No observer defined on WCS.*") - cubeviz_helper.load_data(spectrum1d_cube_larger, data_label='test') + cubeviz_helper.load(spectrum1d_cube_larger, data_label='test') uc = cubeviz_helper.plugins['Unit Conversion'] mm = cubeviz_helper.plugins['Moment Maps'] @@ -261,7 +261,7 @@ def test_write_momentmap(cubeviz_helper, spectrum1d_cube, tmp_path): with warnings.catch_warnings(): warnings.filterwarnings("ignore", message="No observer defined on WCS.*") - cubeviz_helper.load_data(spectrum1d_cube, data_label='test') + cubeviz_helper.load(spectrum1d_cube, data_label='test') plugin = cubeviz_helper.plugins['Moment Maps'] plugin.calculate_moment() @@ -280,7 +280,7 @@ def test_momentmap_nirspec_prism(cubeviz_helper): with warnings.catch_warnings(): warnings.simplefilter("ignore") - cubeviz_helper.load_data(cached_uri(uri), cache=True) + cubeviz_helper.load(cached_uri(uri), cache=True) uc = cubeviz_helper.plugins["Unit Conversion"] uc.open_in_tray() # plugin has to be open for unit change to take hold uc._obj.show_translator = True @@ -311,7 +311,7 @@ def test_correct_output_spectral_y_units(cubeviz_helper, spectrum1d_cube_custom_ # load surface brigtness cube with warnings.catch_warnings(): warnings.filterwarnings("ignore", message="No observer defined on WCS.*") - cubeviz_helper.load_data(sb_cube, data_label='test') + cubeviz_helper.load(sb_cube, data_label='test') uc = cubeviz_helper.plugins["Unit Conversion"] uc.open_in_tray() # plugin has to be open for unit change to take hold @@ -382,7 +382,7 @@ def test_moment_zero_unit_flux_conversions(cubeviz_helper, # load surface brigtness cube with warnings.catch_warnings(): warnings.filterwarnings("ignore", message="No observer defined on WCS.*") - cubeviz_helper.load_data(sb_cube, data_label='test') + cubeviz_helper.load(sb_cube, data_label='test') # get plugins uc = cubeviz_helper.plugins["Unit Conversion"] diff --git a/jdaviz/configs/cubeviz/plugins/slice/tests/test_slice.py b/jdaviz/configs/cubeviz/plugins/slice/tests/test_slice.py index 834d0e4cc3..50ca36e5f0 100644 --- a/jdaviz/configs/cubeviz/plugins/slice/tests/test_slice.py +++ b/jdaviz/configs/cubeviz/plugins/slice/tests/test_slice.py @@ -20,7 +20,7 @@ def test_slice(cubeviz_helper, spectrum1d_cube): sl.vue_play_start_stop() assert not sl.is_playing - cubeviz_helper.load_data(spectrum1d_cube, data_label='test') + cubeviz_helper.load(spectrum1d_cube, data_label='test') app.add_data_to_viewer("flux-viewer", "test[FLUX]") app.add_data_to_viewer("uncert-viewer", "test[FLUX]") app.add_data_to_viewer("spectrum-viewer", "Spectrum (sum)") @@ -94,7 +94,7 @@ def test_slice(cubeviz_helper, spectrum1d_cube): def test_indicator_settings(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube, data_label='test') + cubeviz_helper.load(spectrum1d_cube, data_label='test') app = cubeviz_helper.app app.add_data_to_viewer("flux-viewer", "test[FLUX]") app.add_data_to_viewer("spectrum-viewer", "Spectrum (sum)") @@ -116,7 +116,7 @@ def test_indicator_settings(cubeviz_helper, spectrum1d_cube): @pytest.mark.filterwarnings('ignore:No observer defined on WCS') def test_init_slice(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube, data_label='test') + cubeviz_helper.load(spectrum1d_cube, data_label='test') fv = cubeviz_helper.app.get_viewer('flux-viewer') sl = cubeviz_helper.plugins['Slice'] diff --git a/jdaviz/configs/cubeviz/plugins/sonify_data/tests/test_sonify_data.py b/jdaviz/configs/cubeviz/plugins/sonify_data/tests/test_sonify_data.py index 7011b69649..904737c5c1 100644 --- a/jdaviz/configs/cubeviz/plugins/sonify_data/tests/test_sonify_data.py +++ b/jdaviz/configs/cubeviz/plugins/sonify_data/tests/test_sonify_data.py @@ -11,7 +11,7 @@ @pytest.mark.skipif(IN_GITHUB_ACTIONS, reason="Test requires computer with audio output.") def test_sonify_data(cubeviz_helper, spectrum1d_cube_larger): - cubeviz_helper.load_data(spectrum1d_cube_larger, data_label="test") + cubeviz_helper.load(spectrum1d_cube_larger, data_label="test") sonify_plg = cubeviz_helper.app.get_tray_item_from_name('cubeviz-sonify-data') assert sonify_plg.stream_active @@ -58,7 +58,7 @@ def test_sonify_data(cubeviz_helper, spectrum1d_cube_larger): @pytest.mark.skipif(not IN_GITHUB_ACTIONS, reason="Plugin disabled only in CI") def test_sonify_data_disabled(cubeviz_helper, spectrum1d_cube_larger): - cubeviz_helper.load_data(spectrum1d_cube_larger, data_label="test") + cubeviz_helper.load(spectrum1d_cube_larger, data_label="test") sonify_plg = cubeviz_helper.app.get_tray_item_from_name('cubeviz-sonify-data') assert sonify_plg.disabled_msg with pytest.raises(ValueError, match='Unable to sonify cube'): diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/tests/test_spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/tests/test_spectral_extraction.py index d273bc0632..94a9f2ae21 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/tests/test_spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/tests/test_spectral_extraction.py @@ -25,10 +25,9 @@ def test_version_after_nddata_update(cubeviz_helper, spectrum1d_cube_with_uncerts): # Also test that plugin is disabled before data is loaded. - plg = cubeviz_helper.plugins['3D Spectral Extraction'] - assert plg._obj.disabled_msg != '' - - cubeviz_helper.load_data(spectrum1d_cube_with_uncerts) + assert '3D Spectral Extraction' not in cubeviz_helper.plugins + cubeviz_helper.load(spectrum1d_cube_with_uncerts) + assert '3D Spectral Extraction' in cubeviz_helper.plugins spectral_cube = cubeviz_helper.app.data_collection[0].get_object(NDDataArray) uncert_cube = cubeviz_helper.app.data_collection[1].get_object(StdDevUncertainty) @@ -64,7 +63,7 @@ def test_gauss_smooth_before_spec_extract(cubeviz_helper, spectrum1d_cube_with_u np.ones_like(spectrum1d_cube_with_uncerts.data) ) - cubeviz_helper.load_data(spectrum1d_cube_with_uncerts) + cubeviz_helper.load(spectrum1d_cube_with_uncerts) gs_plugin = cubeviz_helper.plugins['Gaussian Smooth']._obj gs_plugin.dataset_selected = f'{cubeviz_helper.app.data_collection[0].label}' @@ -125,7 +124,7 @@ def test_subset( CirclePixelRegion(PixCoord(0.5, 0), radius=1.2) ] - cubeviz_helper.load_data(spectrum1d_cube_with_uncerts) + cubeviz_helper.load(spectrum1d_cube_with_uncerts) cubeviz_helper.plugins['Subset Tools'].import_region(regions, combination_mode='new') plg = cubeviz_helper.plugins['3D Spectral Extraction'] @@ -149,7 +148,7 @@ def test_subset( def test_extracted_file_in_export_plugin(cubeviz_helper, spectrum1d_cube_with_uncerts, tmp_path): - cubeviz_helper.load_data(spectrum1d_cube_with_uncerts) + cubeviz_helper.load(spectrum1d_cube_with_uncerts) extract_plugin = cubeviz_helper.plugins['3D Spectral Extraction'] @@ -164,7 +163,7 @@ def test_extracted_file_in_export_plugin(cubeviz_helper, spectrum1d_cube_with_un def test_aperture_markers(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) cubeviz_helper.plugins['Subset Tools'].import_region( [CirclePixelRegion(PixCoord(0.5, 0), radius=1.2)]) @@ -216,7 +215,7 @@ def test_aperture_markers(cubeviz_helper, spectrum1d_cube): def test_cone_aperture_with_different_methods(cubeviz_helper, spectrum1d_cube_largest, subset, aperture_method, expected_flux_1000, expected_flux_2400): - cubeviz_helper.load_data(spectrum1d_cube_largest) + cubeviz_helper.load(spectrum1d_cube_largest) center = PixCoord(5, 10) cubeviz_helper.plugins['Subset Tools'].import_region( CirclePixelRegion(center, radius=2.5), combination_mode='new') @@ -249,7 +248,7 @@ def test_cone_aperture_with_different_methods(cubeviz_helper, spectrum1d_cube_la ) def test_cylindrical_aperture_with_different_methods(cubeviz_helper, spectrum1d_cube_largest, subset, aperture_method, expected_flux_wav): - cubeviz_helper.load_data(spectrum1d_cube_largest, data_label="test") + cubeviz_helper.load(spectrum1d_cube_largest, data_label="test") center = PixCoord(5, 10) cubeviz_helper.plugins['Subset Tools'].import_region([ CirclePixelRegion(center, radius=2.5), @@ -274,7 +273,7 @@ def test_cylindrical_aperture_with_different_methods(cubeviz_helper, spectrum1d_ # NOTE: Not as thorough as circle and ellipse above but good enough. def test_rectangle_aperture_with_exact(cubeviz_helper, spectrum1d_cube_largest): - cubeviz_helper.load_data(spectrum1d_cube_largest) + cubeviz_helper.load(spectrum1d_cube_largest) cubeviz_helper.plugins['Subset Tools'].import_region( RectanglePixelRegion(PixCoord(5, 10), width=4, height=4)) @@ -302,7 +301,7 @@ def test_background_subtraction(cubeviz_helper, spectrum1d_cube_largest): # add constant background: spectrum1d_cube_largest = spectrum1d_cube_largest + 1 * u.Jy - cubeviz_helper.load_data(spectrum1d_cube_largest) + cubeviz_helper.load(spectrum1d_cube_largest) cubeviz_helper.plugins['Subset Tools'].import_region([ CirclePixelRegion(PixCoord(5, 10), radius=2.5), EllipsePixelRegion(PixCoord(13, 10), width=3, height=5)], combination_mode='new') @@ -354,7 +353,7 @@ def test_background_subtraction(cubeviz_helper, spectrum1d_cube_largest): def test_cone_and_cylinder_errors(cubeviz_helper, spectrum1d_cube_largest): - cubeviz_helper.load_data(spectrum1d_cube_largest) + cubeviz_helper.load(spectrum1d_cube_largest) center = PixCoord(5, 10) cubeviz_helper.plugins['Subset Tools'].import_region([ CirclePixelRegion(center, radius=2.5), @@ -382,7 +381,7 @@ def test_cone_and_cylinder_errors(cubeviz_helper, spectrum1d_cube_largest): def test_cone_aperture_with_frequency_units(cubeviz_helper, spectral_cube_wcs): data = Spectrum(flux=np.ones((128, 129, 256)) * u.nJy, wcs=spectral_cube_wcs) - cubeviz_helper.load_data(data, data_label="Test Flux") + cubeviz_helper.load(data, data_label="Test Flux") cubeviz_helper.plugins['Subset Tools'].import_region( [CirclePixelRegion(PixCoord(14, 15), radius=2.5)]) @@ -399,7 +398,7 @@ def test_cone_aperture_with_frequency_units(cubeviz_helper, spectral_cube_wcs): def test_cube_extraction_with_nan(cubeviz_helper, image_cube_hdu_obj): image_cube_hdu_obj[1].data[:, :2, :2] = np.nan - cubeviz_helper.load_data(image_cube_hdu_obj, data_label="with_nan") + cubeviz_helper.load(image_cube_hdu_obj, data_label="with_nan") extract_plg = cubeviz_helper.plugins['3D Spectral Extraction'] sp = extract_plg.extract() # Default settings (sum) assert_allclose(sp.flux.value, 9.6E-16) # (10 x 10) - 4 @@ -412,7 +411,7 @@ def test_cube_extraction_with_nan(cubeviz_helper, image_cube_hdu_obj): def test_autoupdate_results(cubeviz_helper, spectrum1d_cube_largest): - cubeviz_helper.load_data(spectrum1d_cube_largest) + cubeviz_helper.load(spectrum1d_cube_largest) cubeviz_helper.plugins['Subset Tools'].import_region( CircularROI(xc=5, yc=5, radius=2)) @@ -439,7 +438,7 @@ def test_autoupdate_results(cubeviz_helper, spectrum1d_cube_largest): def test_aperture_composite_detection(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) subset_plugin = cubeviz_helper.plugins['Subset Tools'] spec_extr_plugin = cubeviz_helper.plugins['3D Spectral Extraction']._obj @@ -461,7 +460,7 @@ def test_aperture_composite_detection(cubeviz_helper, spectrum1d_cube): def test_extraction_composite_subset(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) subset_plugin = cubeviz_helper.plugins['Subset Tools'] spec_extr_plugin = cubeviz_helper.plugins['3D Spectral Extraction']._obj @@ -502,7 +501,7 @@ def test_extraction_composite_subset(cubeviz_helper, spectrum1d_cube): def test_spectral_extraction_with_correct_sum_units(cubeviz_helper, spectrum1d_cube_fluxunit_jy_per_steradian): - cubeviz_helper.load_data(spectrum1d_cube_fluxunit_jy_per_steradian) + cubeviz_helper.load(spectrum1d_cube_fluxunit_jy_per_steradian) spec_extr_plugin = cubeviz_helper.plugins['3D Spectral Extraction']._obj collapsed = spec_extr_plugin.extract() @@ -528,7 +527,7 @@ def test_default_spectral_extraction(cubeviz_helper, spectrum1d_cube_fluxunit_jy # for a spatial subset that captures all data-containing spaxels. this # regression tests make sure that doesn't happen anymore by accounting # for non-science pixels in the sums: - cubeviz_helper.load_data(spectrum1d_cube_fluxunit_jy_per_steradian) + cubeviz_helper.load(spectrum1d_cube_fluxunit_jy_per_steradian) subset_plugin = cubeviz_helper.plugins['Subset Tools'] @@ -548,7 +547,7 @@ def test_default_spectral_extraction(cubeviz_helper, spectrum1d_cube_fluxunit_jy def test_spectral_extraction_unit_conv_one_spec( cubeviz_helper, spectrum1d_cube_fluxunit_jy_per_steradian ): - cubeviz_helper.load_data(spectrum1d_cube_fluxunit_jy_per_steradian) + cubeviz_helper.load(spectrum1d_cube_fluxunit_jy_per_steradian) spectrum_viewer = cubeviz_helper.app.get_viewer( cubeviz_helper._default_spectrum_viewer_reference_name) uc = cubeviz_helper.plugins["Unit Conversion"] @@ -612,7 +611,7 @@ def test_spectral_extraction_scientific_validation( # load observations into Cubeviz with warnings.catch_warnings(): warnings.simplefilter('ignore') - cubeviz_helper.load_data(cached_uri(uri), cache=True) + cubeviz_helper.load(cached_uri(uri), cache=True) # add a subset with an aperture centered on each source subset_plugin = cubeviz_helper.plugins['Subset Tools'] @@ -666,7 +665,7 @@ def test_spectral_extraction_flux_unit_conversions(cubeviz_helper, sb_cube = spectrum1d_cube_custom_fluxunit(fluxunit=flux_unit / angle_unit, shape=(5, 4, 4), with_uncerts=True) - cubeviz_helper.load_data(sb_cube) + cubeviz_helper.load(sb_cube) spectrum_viewer = cubeviz_helper.app.get_viewer( cubeviz_helper._default_spectrum_viewer_reference_name) diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_aperphot.py b/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_aperphot.py index 1bc586964c..a087e83b53 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_aperphot.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_aperphot.py @@ -117,7 +117,7 @@ def test_cubeviz_aperphot_cube_orig_flux(request, helper_str, image_cube_hdu_obj def test_cubeviz_aperphot_generated_3d_gaussian_smooth(cubeviz_helper, image_cube_hdu_obj_microns): - cubeviz_helper.load_data(image_cube_hdu_obj_microns, data_label="test") + cubeviz_helper.load(image_cube_hdu_obj_microns, data_label="test") flux_unit = u.Unit("erg*s^-1*cm^-2*Angstrom^-1*pix^-2") # actually a sb solid_angle_unit = PIX2 @@ -164,7 +164,7 @@ def test_cubeviz_aperphot_cube_sr_and_pix2(cubeviz_helper, # set so the output values between units will be the same cube = spectrum1d_cube_custom_fluxunit(fluxunit=cube_unit) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test[FLUX]") aper = RectanglePixelRegion(center=PixCoord(x=3, y=1), width=1, height=1) bg = RectanglePixelRegion(center=PixCoord(x=2, y=0), width=1, height=1) @@ -227,7 +227,7 @@ def test_cubeviz_aperphot_cube_orig_flux_mjysr(cubeviz_helper, # but for a single surface brightness unit and without changing the pixel # area to make outputs the same. it was requested in review to keep both tests cube = spectrum1d_cube_custom_fluxunit(fluxunit=u.MJy / u.sr) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test[FLUX]") aper = RectanglePixelRegion(center=PixCoord(x=3, y=1), width=1, height=1) bg = RectanglePixelRegion(center=PixCoord(x=2, y=0), width=1, height=1) @@ -323,7 +323,7 @@ def test_cubeviz_aperphot_unit_conversions(cubeviz_helper, # load cube with specified unit cube = spectrum1d_cube_custom_fluxunit(fluxunit=cube_unit, shape=(5, 5, 4), with_uncerts=True) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") # get plugins st = cubeviz_helper.plugins['Subset Tools'] diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_helper.py b/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_helper.py index b89a6f4aa1..90476f9c5e 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_helper.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_helper.py @@ -42,7 +42,7 @@ def test_remote_server_disable_save_serverside(): def test_get_data_spatial_and_spectral(cubeviz_helper, spectrum1d_cube_larger): - cubeviz_helper.load_data(spectrum1d_cube_larger, data_label="test") + cubeviz_helper.load(spectrum1d_cube_larger, data_label="test") unit = spectrum1d_cube_larger.spectral_axis.unit subset_plugin = cubeviz_helper.plugins['Subset Tools'] subset_plugin.import_region([ diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_unit_conversion.py b/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_unit_conversion.py index 55c03edf2c..c428f42ba4 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_unit_conversion.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_unit_conversion.py @@ -37,7 +37,7 @@ def test_basic_unit_conversions(cubeviz_helper, angle_unit): w, wcs_dict = cubeviz_wcs_dict() flux = np.ones((3, 4, 5), dtype=np.float32) cube = Spectrum(flux=flux * (u.MJy / angle_unit), wcs=w, meta=wcs_dict) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") viewer = cubeviz_helper.app.get_viewer("spectrum-viewer") # get all available flux units for translation. Since cube is loaded @@ -136,7 +136,7 @@ def test_flux_unit_choices(cubeviz_helper, flux_unit, expected_choices): flux = np.zeros((3, 4, 5), dtype=np.float32) # load cube in flux_unit, will become cube in flux_unit / pix2 cube = Spectrum(flux=flux * flux_unit, wcs=w, meta=wcs_dict) - cubeviz_helper.load_data(cube) + cubeviz_helper.load(cube) uc_plg = cubeviz_helper.plugins['Unit Conversion'] @@ -153,7 +153,7 @@ def test_unit_translation(cubeviz_helper, angle_unit): flux = np.zeros((30, 20, 3001), dtype=np.float32) flux[5:15, 1:11, :] = 1 cube = Spectrum(flux=flux * u.MJy / angle_unit, wcs=w, meta=wcs_dict) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") center = PixCoord(5, 10) cubeviz_helper.plugins['Subset Tools'].import_region(CirclePixelRegion(center, radius=2.5)) @@ -199,7 +199,7 @@ def test_sb_unit_conversion(cubeviz_helper, angle_unit): flux = np.zeros((30, 20, 3001), dtype=np.float32) flux[5:15, 1:11, :] = 1 cube = Spectrum(flux=flux * (u.MJy / angle_unit), wcs=w, meta=wcs_dict) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") uc_plg = cubeviz_helper.plugins['Unit Conversion'] uc_plg.open_in_tray() @@ -280,7 +280,7 @@ def test_sb_unit_conversion(cubeviz_helper, angle_unit): def test_contour_unit_conversion(cubeviz_helper, spectrum1d_cube_fluxunit_jy_per_steradian): # custom cube to have Surface Brightness units - cubeviz_helper.load_data(spectrum1d_cube_fluxunit_jy_per_steradian, data_label="test") + cubeviz_helper.load(spectrum1d_cube_fluxunit_jy_per_steradian, data_label="test") uc_plg = cubeviz_helper.plugins['Unit Conversion'] uc_plg.open_in_tray() @@ -320,7 +320,7 @@ def test_cubeviz_flux_sb_translation_counts(cubeviz_helper, angle_unit): flux = np.zeros((30, 20, 3001), dtype=np.float32) flux[5:15, 1:11, :] = 1 cube = Spectrum(flux=flux * (u.ct / angle_unit), wcs=w, meta=wcs_dict) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") uc_plg = cubeviz_helper.plugins['Unit Conversion'] uc_plg.open_in_tray() @@ -372,7 +372,7 @@ def test_limits_on_unit_change(cubeviz_helper, start_unit, end_unit, flux = np.zeros((30, 20, 3001), dtype=np.float32) flux[5:15, 1:11, :] = 1 cube = Spectrum(flux=flux * u.Unit(start_unit), wcs=w, meta=wcs_dict) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") uc_plg = cubeviz_helper.plugins['Unit Conversion'] sv = cubeviz_helper.viewers['spectrum-viewer'] diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_data_retrieval.py b/jdaviz/configs/cubeviz/plugins/tests/test_data_retrieval.py index 414893190e..a0f8561f47 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_data_retrieval.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_data_retrieval.py @@ -24,7 +24,7 @@ def test_data_retrieval(cubeviz_helper): fn = download_file(URL, cache=True) with warnings.catch_warnings(): warnings.filterwarnings("ignore") - cubeviz_helper.load_data(fn) + cubeviz_helper.load(fn) # two ways of retrieving data from the viewer. # They should return the same spectral values diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_export_plots.py b/jdaviz/configs/cubeviz/plugins/tests/test_export_plots.py index 74f7a1645f..f2b5c42189 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_export_plots.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_export_plots.py @@ -12,7 +12,7 @@ def test_export_movie(cubeviz_helper, spectrum1d_cube, tmp_path): orig_path = os.getcwd() os.chdir(tmp_path) try: - cubeviz_helper.load_data(spectrum1d_cube, data_label="test") + cubeviz_helper.load(spectrum1d_cube, data_label="test") plugin = cubeviz_helper.plugins["Export"] assert plugin._obj.i_start == 0 assert plugin._obj.i_end == 1 @@ -26,7 +26,7 @@ def test_export_movie(cubeviz_helper, spectrum1d_cube, tmp_path): @pytest.mark.skipif(HAS_OPENCV, reason="opencv-python is installed") def test_no_opencv(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube, data_label="test") + cubeviz_helper.load(spectrum1d_cube, data_label="test") plugin = cubeviz_helper.plugins["Export"] assert 'mp4' in plugin.viewer_format.choices assert not plugin._obj.movie_enabled @@ -43,7 +43,7 @@ def test_export_movie_not_cubeviz(imviz_helper): @pytest.mark.skipif(not HAS_OPENCV, reason="opencv-python is not installed") def test_export_movie_cubeviz_exceptions(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube, data_label="test") + cubeviz_helper.load(spectrum1d_cube, data_label="test") cubeviz_helper.default_viewer._obj.glue_viewer.shape = (100, 100) cubeviz_helper.app.get_viewer("uncert-viewer").shape = (100, 100) plugin = cubeviz_helper.plugins["Export"] @@ -86,7 +86,7 @@ def test_export_movie_cubeviz_empty(cubeviz_helper): def test_export_plot_exceptions(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube, data_label="test") + cubeviz_helper.load(spectrum1d_cube, data_label="test") plugin = cubeviz_helper.plugins["Export"] plugin.filename = "/fake/path/image.png" diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index 98e78aff0b..1b3684e309 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -14,20 +14,20 @@ @pytest.mark.filterwarnings('ignore') def test_fits_image_hdu_parse(image_cube_hdu_obj, cubeviz_helper): - cubeviz_helper.load_data(image_cube_hdu_obj) + cubeviz_helper.load(image_cube_hdu_obj) assert len(cubeviz_helper.app.data_collection) == 4 # 3 cubes and extracted spectrum assert cubeviz_helper.app.data_collection[0].label == "3D Spectrum [FLUX]" # first load should be successful; subsequent attempts should fail with pytest.raises(RuntimeError, match="Only one cube"): - cubeviz_helper.load_data(image_cube_hdu_obj) + cubeviz_helper.load(image_cube_hdu_obj) @pytest.mark.filterwarnings('ignore') def test_fits_image_hdu_with_microns(image_cube_hdu_obj_microns, cubeviz_helper): # Passing in data_label keyword as posarg. - cubeviz_helper.load_data(image_cube_hdu_obj_microns, 'has_microns') + cubeviz_helper.load(image_cube_hdu_obj_microns, 'has_microns') assert len(cubeviz_helper.app.data_collection) == 4 # 3 cubes and extracted spectrum assert cubeviz_helper.app.data_collection[0].label == 'has_microns[FLUX]' @@ -91,7 +91,7 @@ def test_fits_image_hdu_parse_from_file(tmpdir, image_cube_hdu_obj, cubeviz_help f = tmpdir.join("test_fits_image.fits") path = f.strpath image_cube_hdu_obj.writeto(path, overwrite=True) - cubeviz_helper.load_data(path) + cubeviz_helper.load(path) assert len(cubeviz_helper.app.data_collection) == 4 # 3 cubes and auto-extracted spectrum assert cubeviz_helper.app.data_collection[0].label == "test_fits_image" @@ -125,7 +125,7 @@ def test_spectrum3d_parse(image_cube_hdu_obj, cubeviz_helper): flux = image_cube_hdu_obj[1].data << u.Unit(image_cube_hdu_obj[1].header['BUNIT']) wcs = WCS(image_cube_hdu_obj[1].header, image_cube_hdu_obj) sc = Spectrum(flux=flux, wcs=wcs) - cubeviz_helper.load_data(sc) + cubeviz_helper.load(sc) data = cubeviz_helper.app.data_collection[0] assert len(cubeviz_helper.app.data_collection) == 2 @@ -152,7 +152,7 @@ def test_spectrum3d_parse(image_cube_hdu_obj, cubeviz_helper): @pytest.mark.parametrize("flux_unit", [u.nJy, u.DN, u.DN / u.s]) def test_spectrum3d_no_wcs_parse(cubeviz_helper, flux_unit): sc = Spectrum(flux=np.ones(24).reshape((2, 3, 4)) * flux_unit, spectral_axis_index=2) # x, y, z - cubeviz_helper.load_data(sc) + cubeviz_helper.load(sc) assert sc.spectral_axis.unit == u.pix data = cubeviz_helper.app.data_collection[0] @@ -165,7 +165,7 @@ def test_spectrum3d_no_wcs_parse(cubeviz_helper, flux_unit): def test_spectrum1d_parse(spectrum1d, cubeviz_helper): - cubeviz_helper.load_data(spectrum1d) + cubeviz_helper.load(spectrum1d) assert len(cubeviz_helper.app.data_collection) == 1 assert cubeviz_helper.app.data_collection[0].label.endswith('Spectrum') @@ -181,14 +181,14 @@ def test_numpy_cube(cubeviz_helper): arr = np.ones(24).reshape((4, 3, 2)) # x, y, z with pytest.raises(TypeError, match='Data type must be one of'): - cubeviz_helper.load_data(arr, data_type='foo') + cubeviz_helper.load(arr, data_type='foo') - cubeviz_helper.load_data(arr) - cubeviz_helper.load_data(arr, data_label='uncert_array', data_type='uncert', + cubeviz_helper.load(arr) + cubeviz_helper.load(arr, data_label='uncert_array', data_type='uncert', override_cube_limit=True) with pytest.raises(RuntimeError, match='Only one cube'): - cubeviz_helper.load_data(arr, data_type='mask') + cubeviz_helper.load(arr, data_type='mask') assert len(cubeviz_helper.app.data_collection) == 3 # flux cube, uncert cube, Spectrum (sum) @@ -215,7 +215,7 @@ def test_loading_with_mask(cubeviz_helper): spectral_axis=[1, 2]*u.AA, mask=[[[1, 0], [0, 0]], [[0, 0], [0, 0]]], spectral_axis_index=2) - cubeviz_helper.load_data(custom_spec) + cubeviz_helper.load(custom_spec) uc = cubeviz_helper.plugins['Unit Conversion'] uc.spectral_y_type = "Surface Brightness" @@ -242,7 +242,7 @@ def test_manga_with_mask(cubeviz_helper, function, expected_value): # This also tests that spaxel is converted to pix**2 with warnings.catch_warnings(): warnings.filterwarnings("ignore") - cubeviz_helper.load_data("https://stsci.box.com/shared/static/gts87zqt5265msuwi4w5u003b6typ6h0.gz", cache=True) # noqa + cubeviz_helper.load("https://stsci.box.com/shared/static/gts87zqt5265msuwi4w5u003b6typ6h0.gz", cache=True) # noqa uc = cubeviz_helper.plugins['Unit Conversion'] uc.spectral_y_type = "Surface Brightness" @@ -260,14 +260,14 @@ def test_manga_with_mask(cubeviz_helper, function, expected_value): def test_invalid_data_types(cubeviz_helper): with pytest.raises(ValueError, match=r"no valid loaders found for input.*"): - cubeviz_helper.load_data('does_not_exist.fits') + cubeviz_helper.load('does_not_exist.fits') with pytest.raises(ValueError, match='no valid loaders found for input.*'): - cubeviz_helper.load_data(WCS(naxis=3)) + cubeviz_helper.load(WCS(naxis=3)) with pytest.raises(ValueError, match='no valid loaders found for input.*'): - cubeviz_helper.load_data(Spectrum(flux=np.ones((2, 2)) * u.nJy, spectral_axis_index=1)) + cubeviz_helper.load(Spectrum(flux=np.ones((2, 2)) * u.nJy, spectral_axis_index=1)) with pytest.raises(ValueError, match='no valid loaders found for input.*'): # 1D / 3D would be parsed as fluxes in a Spectrum (1d/3d), 2D not supported in cubeviz - cubeviz_helper.load_data(np.ones((2, 2))) + cubeviz_helper.load(np.ones((2, 2))) diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_regions.py b/jdaviz/configs/cubeviz/plugins/tests/test_regions.py index 7a35486184..833b6bcbfc 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_regions.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_regions.py @@ -17,7 +17,7 @@ class TestLoadRegions(BaseRegionHandler): @pytest.fixture(autouse=True) def setup_class(self, cubeviz_helper, image_cube_hdu_obj_microns): self.cubeviz = cubeviz_helper - cubeviz_helper.load_data(image_cube_hdu_obj_microns, data_label='has_microns') + cubeviz_helper.load(image_cube_hdu_obj_microns, data_label='has_microns') # This is used in BaseRegionHandler self.viewer = cubeviz_helper.default_viewer._obj.glue_viewer self.spectrum_viewer = cubeviz_helper.app.get_viewer( diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_tools.py b/jdaviz/configs/cubeviz/plugins/tests/test_tools.py index ad7b61280d..c39ea5cfa6 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_tools.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_tools.py @@ -5,7 +5,7 @@ def test_spectrum_at_spaxel_no_alt(cubeviz_helper, spectrum1d_cube_with_uncerts): - cubeviz_helper.load_data(spectrum1d_cube_with_uncerts, data_label='test') + cubeviz_helper.load(spectrum1d_cube_with_uncerts, data_label='test') flux_viewer = cubeviz_helper.app.get_viewer("flux-viewer") uncert_viewer = cubeviz_helper.app.get_viewer("uncert-viewer") @@ -92,7 +92,7 @@ def test_spectrum_at_spaxel_altkey_true(cubeviz_helper, spectrum1d_cube, cube = spectrum1d_cube cube_unit = 'Jy / pix2' - cubeviz_helper.load_data(cube, data_label='test') + cubeviz_helper.load(cube, data_label='test') flux_viewer = cubeviz_helper.app.get_viewer("flux-viewer") uncert_viewer = cubeviz_helper.app.get_viewer("uncert-viewer") @@ -165,7 +165,7 @@ def test_spectrum_at_spaxel_with_2d(cubeviz_helper): # Use cube with single slice x = np.array([[[1, 2, 3], [4, 5, 6]]]) - cubeviz_helper.load_data(x, data_label='test') + cubeviz_helper.load(x, data_label='test') flux_viewer = cubeviz_helper.app.get_viewer("flux-viewer") spectrum_viewer = cubeviz_helper.app.get_viewer("spectrum-viewer") diff --git a/jdaviz/configs/default/plugins/collapse/tests/test_collapse.py b/jdaviz/configs/default/plugins/collapse/tests/test_collapse.py index 7e56d2d477..4c3638c106 100644 --- a/jdaviz/configs/default/plugins/collapse/tests/test_collapse.py +++ b/jdaviz/configs/default/plugins/collapse/tests/test_collapse.py @@ -6,7 +6,7 @@ @pytest.mark.filterwarnings('ignore') def test_linking_after_collapse(cubeviz_helper, spectral_cube_wcs): - cubeviz_helper.load_data(Spectrum(flux=np.ones((3, 4, 5)) * u.nJy, wcs=spectral_cube_wcs)) + cubeviz_helper.load(Spectrum(flux=np.ones((3, 4, 5)) * u.nJy, wcs=spectral_cube_wcs)) dc = cubeviz_helper.app.data_collection # TODO: this now fails when instantiating Collapse after initialization @@ -38,7 +38,7 @@ def test_linking_after_collapse(cubeviz_helper, spectral_cube_wcs): def test_collapse_exception_handling(cubeviz_helper, spectral_cube_wcs): - cubeviz_helper.load_data(Spectrum(flux=np.ones((3, 4, 5)) * u.nJy, wcs=spectral_cube_wcs)) + cubeviz_helper.load(Spectrum(flux=np.ones((3, 4, 5)) * u.nJy, wcs=spectral_cube_wcs)) coll = cubeviz_helper.plugins['Collapse']._obj @@ -63,7 +63,7 @@ def test_collapse_exception_handling(cubeviz_helper, spectral_cube_wcs): def test_collapsed_to_extract_plugin(cubeviz_helper, spectral_cube_wcs, tmp_path): - cubeviz_helper.load_data(Spectrum(flux=np.ones((3, 4, 5)) * u.nJy, wcs=spectral_cube_wcs)) + cubeviz_helper.load(Spectrum(flux=np.ones((3, 4, 5)) * u.nJy, wcs=spectral_cube_wcs)) collapse_plugin = cubeviz_helper.plugins['Collapse'] diff --git a/jdaviz/configs/default/plugins/data_quality/tests/test_data_quality.py b/jdaviz/configs/default/plugins/data_quality/tests/test_data_quality.py index 3f9874a2f7..317bfbc597 100644 --- a/jdaviz/configs/default/plugins/data_quality/tests/test_data_quality.py +++ b/jdaviz/configs/default/plugins/data_quality/tests/test_data_quality.py @@ -81,8 +81,8 @@ def test_data_quality_plugin(imviz_helper): with warnings.catch_warnings(): warnings.simplefilter("ignore") - imviz_helper.load_data( - cached_uri(uri), cache=True, ext=('SCI', 'DQ') + imviz_helper.load( + cached_uri(uri), cache=True, extension=('SCI', 'DQ') ) assert len(imviz_helper.app.data_collection) == 2 @@ -179,7 +179,7 @@ def test_data_quality_plugin_hst_wfc3(imviz_helper): uri = "mast:HST/product/hst_17183_02_wfc3_uvis_g280_iexr02mt_flt.fits" with warnings.catch_warnings(): warnings.simplefilter("ignore") - imviz_helper.load_data(cached_uri(uri), cache=True, ext=('SCI', 'DQ')) + imviz_helper.load(cached_uri(uri), cache=True, extension=('SCI', 'DQ')) assert len(imviz_helper.app.data_collection) == 2 @@ -198,7 +198,7 @@ def test_data_quality_plugin_hst_acs(imviz_helper): uri = "mast:HST/product/hst_16968_01_acs_wfc_f606w_jezz01l3_flt.fits" with warnings.catch_warnings(): warnings.simplefilter("ignore") - imviz_helper.load_data(cached_uri(uri), cache=True, ext=('SCI', 'DQ')) + imviz_helper.load(cached_uri(uri), cache=True, extension=('SCI', 'DQ')) assert len(imviz_helper.app.data_collection) == 2 @@ -220,7 +220,7 @@ def test_cubeviz_layer_visibility_bug(cubeviz_helper): uri = "mast:JWST/product/jw02732-c1001_t004_miri_ch1-short_s3d.fits" with warnings.catch_warnings(): warnings.simplefilter("ignore") - cubeviz_helper.load_data(cached_uri(uri), cache=True) + cubeviz_helper.load(cached_uri(uri), cache=True) # create a moment map: mm = cubeviz_helper.plugins['Moment Maps'] diff --git a/jdaviz/configs/default/plugins/export/tests/test_export.py b/jdaviz/configs/default/plugins/export/tests/test_export.py index b1cb68f441..32de12ae65 100644 --- a/jdaviz/configs/default/plugins/export/tests/test_export.py +++ b/jdaviz/configs/default/plugins/export/tests/test_export.py @@ -24,7 +24,7 @@ def test_basic_export_subsets_imviz(self, imviz_helper): data = NDData(np.ones((500, 500)) * u.nJy) - imviz_helper.load_data(data) + imviz_helper.load(data) subset_plugin = imviz_helper.plugins['Subset Tools'] subset_plugin.import_region(CircularROI(xc=250, yc=250, radius=100)) @@ -91,7 +91,7 @@ def test_not_implemented(self, cubeviz_helper, spectral_cube_wcs): data = Spectrum(flux=np.ones((500, 500, 2)) * u.nJy, wcs=spectral_cube_wcs) - cubeviz_helper.load_data(data) + cubeviz_helper.load(data) subset_plugin = cubeviz_helper.plugins['Subset Tools'] subset_plugin.import_region(CircularROI(xc=255, yc=255, radius=50)) subset_plugin.import_region(CircularROI(xc=200, yc=250, radius=50), edit_subset='Subset 1', @@ -110,10 +110,10 @@ def test_export_subsets_wcs(self, imviz_helper, spectral_cube_wcs): data = NDData(np.ones((500, 500)) * u.nJy, wcs=wcs) - imviz_helper.load_data(data) # load data twice so we can link them - imviz_helper.load_data(data) + imviz_helper.load(data) # load data twice so we can link them + imviz_helper.load(data) - imviz_helper.link_data(align_by='wcs') + imviz_helper.plugins['Orientation'].align_by = 'WCS' subset_plugin = imviz_helper.plugins['Subset Tools'] subset_plugin.import_region(CircularROI(xc=8, yc=6, radius=.2)) @@ -136,7 +136,7 @@ def test_basic_export_subsets_cubeviz(self, cubeviz_helper, spectral_cube_wcs): data = Spectrum(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) # Subset 1, Spatial Subset - cubeviz_helper.load_data(data) + cubeviz_helper.load(data) subset_plugin = cubeviz_helper.plugins['Subset Tools'] subset_plugin.import_region(CircularROI(xc=50, yc=50, radius=10)) @@ -283,8 +283,8 @@ def test_export_stcs_circle_ellipse(self, imviz_helper): 'CRPIX2': 1, 'CRVAL2': -33.71313112382379}) arr = np.arange(40000).reshape(200, 200) ndd = NDData(arr, wcs=wcs) - imviz_helper.load_data(ndd) - imviz_helper.link_data(align_by='wcs') + imviz_helper.load(ndd) + imviz_helper.plugins['Orientation'].align_by = 'WCS' subset_plugin = imviz_helper.plugins['Subset Tools'] export_plugin = imviz_helper.plugins['Export']._obj @@ -320,7 +320,7 @@ def test_export_stcs_circle_ellipse(self, imviz_helper): @pytest.mark.usefixtures('_jail') def test_export_cubeviz_spectrum_viewer(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube, data_label='test') + cubeviz_helper.load(spectrum1d_cube, data_label='test') ep = cubeviz_helper.plugins["Export"] ep.viewer = 'spectrum-viewer' @@ -333,7 +333,7 @@ def test_export_cubeviz_spectrum_viewer(cubeviz_helper, spectrum1d_cube): @pytest.mark.usefixtures('_jail') def test_export_data(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube, data_label='test') + cubeviz_helper.load(spectrum1d_cube, data_label='test') mm = cubeviz_helper.plugins["Moment Maps"] mm.dataset = 'test[FLUX]' mm._obj.dataset_selected = 'test[FLUX]' @@ -358,7 +358,7 @@ def test_disable_export_for_unsupported_units(specviz2d_helper): data = np.zeros((5, 10)) data[3] = np.arange(10) data = Spectrum(flux=data*dn_per_s, spectral_axis=data[3]*u.um) - specviz2d_helper.load_data(data) + specviz2d_helper.load(data) gs = specviz2d_helper.plugins["Gaussian Smooth"] smooth_source_dataset = "Spectrum 1D" @@ -385,7 +385,7 @@ def test_basic_export_plugin_plots(self, imviz_helper): """ data = NDData(np.ones((500, 500)) * u.nJy) - imviz_helper.load_data(data) + imviz_helper.load(data) export_plugin = imviz_helper.plugins['Export']._obj export_plugin.plugin_plot.selected = 'Plot Options: stretch_hist' @@ -416,7 +416,7 @@ def test_ap_phot_plot_export(self, imviz_helper): data = NDData(np.ones((500, 500)) * u.nJy) - imviz_helper.load_data(data) + imviz_helper.load(data) export_plugin = imviz_helper.plugins['Export']._obj subset_plugin = imviz_helper.plugins['Subset Tools'] @@ -445,7 +445,7 @@ def test_figure_export(self, imviz_helper): data = NDData(np.ones((500, 500)) * u.nJy) - imviz_helper.load_data(data) + imviz_helper.load(data) export_plugin = imviz_helper.plugins['Export']._obj @@ -459,7 +459,7 @@ def test_figure_export(self, imviz_helper): def test_filepath_convention(self, imviz_helper): data = NDData(np.ones((500, 500)) * u.nJy) - imviz_helper.load_data(data) + imviz_helper.load(data) export_plugin = imviz_helper.plugins['Export']._obj # Set filename value using OS-independent Path methods diff --git a/jdaviz/configs/default/plugins/gaussian_smooth/tests/test_gaussian_smooth.py b/jdaviz/configs/default/plugins/gaussian_smooth/tests/test_gaussian_smooth.py index fbbe4e26fb..c54ed6e362 100644 --- a/jdaviz/configs/default/plugins/gaussian_smooth/tests/test_gaussian_smooth.py +++ b/jdaviz/configs/default/plugins/gaussian_smooth/tests/test_gaussian_smooth.py @@ -8,7 +8,7 @@ def test_linking_after_spectral_smooth(cubeviz_helper, spectrum1d_cube): app = cubeviz_helper.app dc = app.data_collection data_label = 'test' - cubeviz_helper.load_data(spectrum1d_cube, data_label=data_label) + cubeviz_helper.load(spectrum1d_cube, data_label=data_label) spec_viewer = cubeviz_helper.app.get_viewer('spectrum-viewer') assert len(dc) == 2 @@ -106,7 +106,7 @@ def test_linking_after_spectral_smooth(cubeviz_helper, spectrum1d_cube): def test_spatial_convolution(cubeviz_helper, spectrum1d_cube): data_label = 'test' dc = cubeviz_helper.app.data_collection - cubeviz_helper.load_data(spectrum1d_cube, data_label=data_label) + cubeviz_helper.load(spectrum1d_cube, data_label=data_label) gs = cubeviz_helper.plugins['Gaussian Smooth']._obj gs.mode_selected = 'Spatial' @@ -130,7 +130,7 @@ def test_spatial_convolution(cubeviz_helper, spectrum1d_cube): def test_specviz_smooth(specviz_helper, spectrum1d): data_label = 'test' dc = specviz_helper.app.data_collection - specviz_helper.load_data(spectrum1d, data_label=data_label) + specviz_helper.load(spectrum1d, data_label=data_label) spec_viewer = specviz_helper.app.get_viewer('spectrum-viewer') gs = specviz_helper.plugins['Gaussian Smooth']._obj @@ -170,7 +170,7 @@ def test_specviz_smooth(specviz_helper, spectrum1d): def test_specviz2d_smooth(specviz2d_helper, spectrum2d): data_label = 'test' dc = specviz2d_helper.app.data_collection - specviz2d_helper.load_data(spectrum_2d=spectrum2d, spectrum_2d_label=data_label) + specviz2d_helper.load(spectrum2d, data_label=data_label) gs_plugin = specviz2d_helper.plugins['Gaussian Smooth'] diff --git a/jdaviz/configs/default/plugins/line_lists/tests/test_line_lists.py b/jdaviz/configs/default/plugins/line_lists/tests/test_line_lists.py index ef0ac33af4..3d88b1640c 100644 --- a/jdaviz/configs/default/plugins/line_lists/tests/test_line_lists.py +++ b/jdaviz/configs/default/plugins/line_lists/tests/test_line_lists.py @@ -19,7 +19,7 @@ class TestLineLists: def test_line_lists(self, specviz_helper): spec = Spectrum(flux=np.random.rand(100)*u.Jy, spectral_axis=np.arange(6000, 7000, 10)*u.AA) - specviz_helper.load_data(spec) + specviz_helper.load(spec) lt = QTable() lt['linename'] = ['O III', 'Halpha'] @@ -57,7 +57,7 @@ def test_redshift(self, specviz_helper, spectrum1d): assert ll_plugin.disabled_msg label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) assert not ll_plugin.disabled_msg @@ -106,7 +106,7 @@ def test_redshift(self, specviz_helper, spectrum1d): def test_load_available_preset_lists(self, specviz_helper, spectrum1d): """ Loads all available line lists and checks the medium requirement """ label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) # Check to make sure we got our line lists available_linelists = get_available_linelists() @@ -127,7 +127,7 @@ def test_load_available_preset_lists(self, specviz_helper, spectrum1d): assert 'medium' in list def test_line_identify(self, specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) lt = QTable() lt['linename'] = ['O III', 'Halpha'] @@ -146,7 +146,7 @@ def test_line_identify(self, specviz_helper, spectrum1d): assert line.get('identify', False) is False def test_global_redshift_applied(self, specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) # Create a table with redshift included lt = QTable({'linename': ['O III', 'Halpha'], @@ -169,7 +169,7 @@ def test_global_redshift_applied(self, specviz_helper, spectrum1d): assert np.allclose([line.redshift for line in viewer_lines], 0.01) def test_global_redshift_applied_to_all(self, specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) # Create a table with redshift included lt = QTable({'linename': ['O III', 'Halpha', 'O I'], diff --git a/jdaviz/configs/default/plugins/markers/tests/test_markers_plugin.py b/jdaviz/configs/default/plugins/markers/tests/test_markers_plugin.py index 260cf01b62..4edc5c8948 100644 --- a/jdaviz/configs/default/plugins/markers/tests/test_markers_plugin.py +++ b/jdaviz/configs/default/plugins/markers/tests/test_markers_plugin.py @@ -28,7 +28,7 @@ def _assert_dict_allclose(dict1, dict2): def test_markers_cubeviz(tmp_path, cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube, "test") + cubeviz_helper.load(spectrum1d_cube, data_label="test") fv = cubeviz_helper.app.get_viewer('flux-viewer') sv = cubeviz_helper.app.get_viewer('spectrum-viewer') sb_unit = 'Jy / pix2' # cubes loaded in Jy have sb unit of Jy / pix2 @@ -208,7 +208,7 @@ def test_markers_cubeviz_flux_unit_conversion(cubeviz_helper, cube = spectrum1d_cube_custom_fluxunit(fluxunit=flux_unit / angle_unit, shape=(5, 5, 4), with_uncerts=True) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") # get plugins mp = cubeviz_helper.plugins['Markers'] @@ -248,7 +248,7 @@ def test_markers_specviz2d_unit_conversion(specviz2d_helper): data = np.zeros((5, 10)) data[3] = np.arange(10) spectrum2d = Spectrum(flux=data*u.MJy, spectral_axis=data[3]*u.AA) - specviz2d_helper.load_data(spectrum2d) + specviz2d_helper.load(spectrum2d) uc = specviz2d_helper.plugins['Unit Conversion'] uc.open_in_tray() @@ -430,7 +430,7 @@ def _get_distance_marks_from_viewer(viewer): def test_distance_tool_live_preview_image(cubeviz_helper, spectrum1d_cube): """Tests the rubber band line and live UI update in an image viewer.""" - cubeviz_helper.load_data(spectrum1d_cube, "test") + cubeviz_helper.load(spectrum1d_cube, "test") fv = cubeviz_helper.app.get_viewer('flux-viewer') mp = cubeviz_helper.plugins['Markers'] mp.open_in_tray() @@ -453,7 +453,7 @@ def test_distance_tool_live_preview_image(cubeviz_helper, spectrum1d_cube): def test_distance_tool_profile(cubeviz_helper, spectrum1d_cube): """Tests the rubber band line and live UI update in a profile viewer.""" - cubeviz_helper.load_data(spectrum1d_cube, "test") + cubeviz_helper.load(spectrum1d_cube, "test") sv = cubeviz_helper.app.get_viewer('spectrum-viewer') mp = cubeviz_helper.plugins['Markers'] mp.open_in_tray() @@ -501,7 +501,7 @@ def test_distance_tool_profile(cubeviz_helper, spectrum1d_cube): def test_distance_tool_snapping(cubeviz_helper, spectrum1d_cube): """Tests that the distance tool can snap to existing markers.""" - cubeviz_helper.load_data(spectrum1d_cube, "test") + cubeviz_helper.load(spectrum1d_cube, "test") fv = cubeviz_helper.app.get_viewer('flux-viewer') mp = cubeviz_helper.plugins['Markers'] mp.open_in_tray() @@ -522,7 +522,7 @@ def test_distance_tool_snapping(cubeviz_helper, spectrum1d_cube): def test_distance_tool_clearing(cubeviz_helper, spectrum1d_cube): """Tests that clearing the measurements table removes marks from the viewer.""" - cubeviz_helper.load_data(spectrum1d_cube, "test") + cubeviz_helper.load(spectrum1d_cube, "test") fv = cubeviz_helper.app.get_viewer('flux-viewer') mp = cubeviz_helper.plugins['Markers'] mp.open_in_tray() @@ -545,7 +545,7 @@ def test_distance_tool_clearing(cubeviz_helper, spectrum1d_cube): def test_distance_tool_reset_on_orientation_change(cubeviz_helper, spectrum1d_cube): """Tests that an in-progress measurement is cancelled on orientation change.""" - cubeviz_helper.load_data(spectrum1d_cube, "test") + cubeviz_helper.load(spectrum1d_cube, "test") fv = cubeviz_helper.app.get_viewer('flux-viewer') mp = cubeviz_helper.plugins['Markers'] mp.open_in_tray() @@ -563,7 +563,7 @@ def test_distance_tool_reset_on_orientation_change(cubeviz_helper, spectrum1d_cu def test_distance_tool_imviz_pixel_only(imviz_helper): """Tests the distance tool in a pixel-only context in Imviz.""" # Use the imviz_helper fixture and load a simple array with no WCS - imviz_helper.load_data(np.zeros((20, 20))) + imviz_helper.load(np.zeros((20, 20))) iv = imviz_helper.app.get_viewer('imviz-0') mp = imviz_helper.plugins['Markers'] mp.open_in_tray() @@ -592,7 +592,7 @@ def test_distance_tool_imviz_pixel_only(imviz_helper): def test_markers_specviz_config(specviz_helper, spectrum1d): """Tests the marker plugin's basic functionality in a Specviz context.""" - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) sv = specviz_helper.app.get_viewer('spectrum-viewer') mp = specviz_helper.plugins['Markers'] mp.open_in_tray() @@ -616,7 +616,7 @@ def test_distance_tool_snapping_by_pixel_scale(cubeviz_helper, spectrum1d_cube): Tests the snapping functionality that relies on viewer pixel scales, covering both image and profile viewer cases to improve test coverage. """ - cubeviz_helper.load_data(spectrum1d_cube, "test") + cubeviz_helper.load(spectrum1d_cube, "test") fv = cubeviz_helper.app.get_viewer('flux-viewer') sv = cubeviz_helper.app.get_viewer('spectrum-viewer') mp = cubeviz_helper.plugins['Markers'] diff --git a/jdaviz/configs/default/plugins/metadata_viewer/tests/test_metadata_viewer.py b/jdaviz/configs/default/plugins/metadata_viewer/tests/test_metadata_viewer.py index cbbc60726c..78cecf9ad8 100644 --- a/jdaviz/configs/default/plugins/metadata_viewer/tests/test_metadata_viewer.py +++ b/jdaviz/configs/default/plugins/metadata_viewer/tests/test_metadata_viewer.py @@ -22,11 +22,11 @@ def test_view_dict(imviz_helper): ndd_4[0].header['APERTURE'] = ('#TODO', 'Aperture') ndd_4[1].name = 'DATA' - imviz_helper.load_data(ndd_1, data_label='has_simple_meta') - imviz_helper.load_data(ndd_2, data_label='has_nested_meta') - imviz_helper.load_data(ndd_3, data_label='has_primary') - imviz_helper.load_data(ndd_4, data_label='has_primary_2') - imviz_helper.load_data(arr, data_label='no_meta') + imviz_helper.load(ndd_1, data_label='has_simple_meta') + imviz_helper.load(ndd_2, data_label='has_nested_meta') + imviz_helper.load(ndd_3, data_label='has_primary') + imviz_helper.load(ndd_4, data_label='has_primary_2') + imviz_helper.load(arr, data_label='no_meta') assert mv.dataset.labels == ['has_simple_meta[DATA]', 'has_nested_meta[DATA]', 'has_primary[DATA,1]', 'has_primary_2[DATA,1]', 'no_meta'] diff --git a/jdaviz/configs/default/plugins/model_fitting/tests/test_fitting.py b/jdaviz/configs/default/plugins/model_fitting/tests/test_fitting.py index c9bdfdfbc7..9adacd09fa 100644 --- a/jdaviz/configs/default/plugins/model_fitting/tests/test_fitting.py +++ b/jdaviz/configs/default/plugins/model_fitting/tests/test_fitting.py @@ -62,7 +62,7 @@ def test_model_params(): def test_check_poly_order_function(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) plugin = specviz_helper.plugins["Model Fitting"]._obj plugin.dataset_selected = '1D Spectrum' @@ -109,7 +109,7 @@ def test_check_poly_order_function(specviz_helper, spectrum1d): def test_check_poly_order_observer(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) plugin = specviz_helper.plugins["Model Fitting"]._obj plugin.dataset_selected = '1D Spectrum' @@ -153,10 +153,10 @@ def test_check_poly_order_observer(specviz_helper, spectrum1d): def test_model_ids(cubeviz_helper, spectral_cube_wcs): - cubeviz_helper.load_data(Spectrum(flux=np.ones((3, 4, 5)) * u.nJy, wcs=spectral_cube_wcs), - data_label='test') + cubeviz_helper.load(Spectrum(flux=np.ones((3, 4, 5)) * u.nJy, wcs=spectral_cube_wcs), + data_label='test') plugin = cubeviz_helper.plugins["Model Fitting"]._obj - plugin.dataset_selected = 'Spectrum (sum)' + plugin.dataset_selected = 'test (sum)' plugin.component_models = [{'id': 'valid_string_already_exists'}] plugin.model_comp_selected = 'Linear1D' @@ -181,7 +181,7 @@ def test_parameter_retrieval(cubeviz_helper, spectral_cube_wcs): flux = np.ones((3, 4, 5)) flux[2, 2, :] = [1, 2, 3, 4, 5] - cubeviz_helper.load_data(Spectrum(flux=flux * flux_unit, wcs=spectral_cube_wcs), + cubeviz_helper.load(Spectrum(flux=flux * flux_unit, wcs=spectral_cube_wcs), data_label='test') plugin = cubeviz_helper.plugins["Model Fitting"] @@ -394,7 +394,7 @@ def test_cube_fitting_backend(cubeviz_helper, unc, n_cpu, tmp_path): [coo_expected[1].ra.deg, coo_expected[1].dec.deg]) # Check Cubeviz roundtrip. This should automatically go through wcs1d-fits reader. - cubeviz_helper.load_data(out_fn) + cubeviz_helper.load(out_fn) assert len(cubeviz_helper.app.data_collection) == 3 data_sci = cubeviz_helper.app.data_collection["fitted_cube"] flux_sci = data_sci.get_component("flux") @@ -413,7 +413,7 @@ def test_cube_fitting_backend(cubeviz_helper, unc, n_cpu, tmp_path): def test_results_table(specviz_helper, spectrum1d): data_label = 'test' - specviz_helper.load_data(spectrum1d, data_label=data_label) + specviz_helper.load(spectrum1d, data_label=data_label) mf = specviz_helper.plugins['Model Fitting'] mf.create_model_component('Linear1D') @@ -474,7 +474,7 @@ def test_results_table(specviz_helper, spectrum1d): def test_equation_validation(specviz_helper, spectrum1d): data_label = 'test' - specviz_helper.load_data(spectrum1d, data_label=data_label) + specviz_helper.load(spectrum1d, data_label=data_label) mf = specviz_helper.plugins['Model Fitting'] mf.create_model_component('Const1D') @@ -501,7 +501,7 @@ def test_equation_validation(specviz_helper, spectrum1d): def test_incompatible_units(specviz_helper, spectrum1d): data_label = 'test' - specviz_helper.load_data(spectrum1d, data_label=data_label) + specviz_helper.load(spectrum1d, data_label=data_label) mf = specviz_helper.plugins['Model Fitting'] mf.create_model_component('Linear1D') @@ -532,7 +532,7 @@ def test_cube_fit_with_nans(cubeviz_helper): flux = np.ones((7, 8, 9)) * u.nJy flux[:, :, 0] = np.nan spec = Spectrum(flux=flux, spectral_axis_index=2) - cubeviz_helper.load_data(spec, data_label="test") + cubeviz_helper.load(spec, data_label="test") mf = cubeviz_helper.plugins["Model Fitting"] mf.cube_fit = True @@ -557,7 +557,7 @@ def test_cube_fit_with_subset_and_nans(cubeviz_helper): flux[:, :, 0] = np.nan spec = Spectrum(flux=flux, spectral_axis_index=2) spec.flux[5, 5, 7] = 10 * u.nJy - cubeviz_helper.load_data(spec, data_label="test") + cubeviz_helper.load(spec, data_label="test") sv = cubeviz_helper.app.get_viewer('spectrum-viewer') sv.apply_roi(XRangeROI(0, 5)) @@ -580,7 +580,7 @@ def test_fit_with_count_units(cubeviz_helper): spectral_axis = np.linspace(4000, 5000, flux.shape[-1]) * u.AA spec = Spectrum(flux=flux, spectral_axis=spectral_axis, spectral_axis_index=2) - cubeviz_helper.load_data(spec, data_label="test") + cubeviz_helper.load(spec, data_label="test") mf = cubeviz_helper.plugins["Model Fitting"] mf.cube_fit = True @@ -603,7 +603,7 @@ def test_fit_with_count_units(cubeviz_helper): def test_cube_fit_after_unit_change(cubeviz_helper, solid_angle_unit): cube = _create_spectrum1d_cube_with_fluxunit(fluxunit=u.Jy / solid_angle_unit, shape=(10, 4, 5), with_uncerts=True) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") solid_angle_string = str(solid_angle_unit) uc = cubeviz_helper.plugins['Unit Conversion'] @@ -719,7 +719,7 @@ def test_deconf_mf_with_subset(deconfigged_helper): 'SimplexLSQFitter']) def test_different_fitters(specviz_helper, spectrum1d, fitter): data_label = 'test' - specviz_helper.load_data(spectrum1d, data_label=data_label) + specviz_helper.load(spectrum1d, data_label=data_label) mf = specviz_helper.plugins['Model Fitting']._obj if fitter == 'SimplexLSQFitter': @@ -759,7 +759,7 @@ def test_specviz2d_linking(specviz2d_helper): # Create a continuous 2D data = np.sin(x_values[:, np.newaxis]) * np.cos(y_values) * u.one spectrum_data = Spectrum(data, wcs=wcs, meta=header) - specviz2d_helper.load_data(spectrum_2d=spectrum_data) + specviz2d_helper.load(spectrum_data) viewer_1d = specviz2d_helper.app.get_viewer( specviz2d_helper._default_spectrum_viewer_reference_name) @@ -802,7 +802,7 @@ def test_model_equation_with_different_flux_units(specviz_helper): # Create spectrum spec = Spectrum(spectral_axis=wavelength, flux=flux, uncertainty=uncertainty) data_label = 'test' - specviz_helper.load_data(spec, data_label=data_label) + specviz_helper.load(spec, data_label=data_label) mf = specviz_helper.plugins['Model Fitting'] uc = specviz_helper.plugins['Unit Conversion'] diff --git a/jdaviz/configs/default/plugins/model_fitting/tests/test_plugin.py b/jdaviz/configs/default/plugins/model_fitting/tests/test_plugin.py index fafbf044b3..05388ed62f 100644 --- a/jdaviz/configs/default/plugins/model_fitting/tests/test_plugin.py +++ b/jdaviz/configs/default/plugins/model_fitting/tests/test_plugin.py @@ -23,7 +23,7 @@ def test_default_model_labels(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) modelfit_plugin = specviz_helper.plugins['Model Fitting'] # By default, the spectral region should be the entire spectrum assert modelfit_plugin._obj.spectral_subset_selected == "Entire Spectrum" @@ -49,7 +49,7 @@ def test_default_model_labels(specviz_helper, spectrum1d): def test_custom_model_labels(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) modelfit_plugin = specviz_helper.plugins['Model Fitting'] for i, model in enumerate(MODELS): @@ -71,7 +71,7 @@ def test_register_model_with_uncertainty_weighting(specviz_helper, spectrum1d): spectrum1d.uncertainty = StdDevUncertainty(spectrum1d.flux * 0.1) with warnings.catch_warnings(): warnings.simplefilter('ignore') - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) modelfit_plugin = specviz_helper.plugins['Model Fitting'] # Test registering a simple linear fit @@ -105,7 +105,7 @@ def test_register_model_uncertainty_is_none(specviz_helper, spectrum1d): spectrum1d.uncertainty = None with warnings.catch_warnings(): warnings.simplefilter('ignore') - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) modelfit_plugin = specviz_helper.plugins['Model Fitting'] # Test registering a simple linear fit @@ -137,7 +137,7 @@ def test_register_model_uncertainty_is_none(specviz_helper, spectrum1d): def test_register_cube_model(cubeviz_helper, spectrum1d_cube): with warnings.catch_warnings(): warnings.simplefilter('ignore') - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) modelfit_plugin = cubeviz_helper.plugins['Model Fitting'] # Test custom model label @@ -161,7 +161,7 @@ def test_register_cube_model(cubeviz_helper, spectrum1d_cube): def test_initialize_gaussian_with_cube(cubeviz_helper, spectrum1d_cube_larger): with warnings.catch_warnings(): warnings.simplefilter('ignore') - cubeviz_helper.load_data(spectrum1d_cube_larger) + cubeviz_helper.load(spectrum1d_cube_larger) modelfit_plugin = cubeviz_helper.plugins['Model Fitting'] modelfit_plugin.cube_fit = True @@ -175,7 +175,7 @@ def test_fit_cube_no_wcs(cubeviz_helper): flux = np.ones((7, 8, 9)) * u.nJy flux[0, 0, 0] = np.nan sp = Spectrum(flux=flux, spectral_axis_index=2) # ny, nx, nz - cubeviz_helper.load_data(sp, data_label="test_cube") + cubeviz_helper.load(sp, data_label="test_cube") mf = cubeviz_helper.plugins['Model Fitting'] mf.create_model_component('Linear1D') mf.cube_fit = True @@ -196,7 +196,7 @@ def test_fit_cube_no_wcs(cubeviz_helper): def test_toggle_cube_fit_subset(cubeviz_helper): sp = Spectrum(flux=np.ones((7, 8, 9)) * u.nJy, spectral_axis_index=2) # ny, nx, nz - cubeviz_helper.load_data(sp, data_label="test_cube") + cubeviz_helper.load(sp, data_label="test_cube") mf = cubeviz_helper.plugins['Model Fitting'] unit = u.Unit(cubeviz_helper.plugins['Unit Conversion'].spectral_unit.selected) @@ -208,7 +208,7 @@ def test_toggle_cube_fit_subset(cubeviz_helper): def test_refit_plot_options(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) modelfit_plugin = specviz_helper.plugins['Model Fitting'] modelfit_plugin._obj.model_comp_selected = 'Const1D' @@ -239,7 +239,7 @@ def test_refit_plot_options(specviz_helper, spectrum1d): def test_user_api(specviz_helper, spectrum1d): with warnings.catch_warnings(): warnings.simplefilter('ignore') - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) p = specviz_helper.plugins['Model Fitting'] with pytest.raises(ValueError, match="blah is not a valid attribute and cannot be set"): @@ -280,7 +280,7 @@ def test_user_api(specviz_helper, spectrum1d): def test_fit_gaussian_with_fixed_mean(specviz_helper, spectrum1d): with warnings.catch_warnings(): warnings.simplefilter('ignore') - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) modelfit_plugin = specviz_helper.plugins['Model Fitting'] modelfit_plugin.create_model_component('Gaussian1D', 'G') @@ -302,7 +302,7 @@ def test_fit_gaussian_with_fixed_mean(specviz_helper, spectrum1d): def test_reestimate_parameters(specviz_helper, spectrum1d): with warnings.catch_warnings(): warnings.simplefilter('ignore') - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) mf = specviz_helper.plugins['Model Fitting'] mf.create_model_component('Gaussian1D', 'G') @@ -329,7 +329,7 @@ def test_reestimate_parameters(specviz_helper, spectrum1d): def test_spectral_first_cube(cubeviz_helper, image_cube_hdu_obj_microns): - cubeviz_helper.load_data(image_cube_hdu_obj_microns, data_label="test") + cubeviz_helper.load(image_cube_hdu_obj_microns, data_label="test") subset = cubeviz_helper.plugins['Subset Tools'] subset.import_region(SpectralRegion(4 * u.Unit('um'), 6 * u.Unit('um'))) @@ -345,7 +345,7 @@ def test_spectral_first_cube(cubeviz_helper, image_cube_hdu_obj_microns): def test_subset_masks(cubeviz_helper, spectrum1d_cube_larger): - cubeviz_helper.load_data(spectrum1d_cube_larger) + cubeviz_helper.load(spectrum1d_cube_larger) assert spectrum1d_cube_larger.mask is None # create a "Subset 1" entry in spatial dimension, selected "interactively" @@ -387,12 +387,12 @@ def test_subset_masks(cubeviz_helper, spectrum1d_cube_larger): def test_invalid_subset(specviz_helper, spectrum1d): # 6000-8000 - specviz_helper.load_data(spectrum1d, data_label="right_spectrum") + specviz_helper.load(spectrum1d, data_label="right_spectrum") # 5000-7000 sp2 = Spectrum(spectral_axis=spectrum1d.spectral_axis - 1000*spectrum1d.spectral_axis.unit, flux=spectrum1d.flux * 1.25) - specviz_helper.load_data(sp2, data_label="left_spectrum") + specviz_helper.load(sp2, data_label="left_spectrum") # apply subset that overlaps on left_spectrum, but not right_spectrum # NOTE: using a subset that overlaps the right_spectrum (reference) results in errors when @@ -427,7 +427,7 @@ def test_fitting_with_nans(specviz_helper, fill_val): spec = Spectrum(flux=np.array([0, 1, 2, fill_val, fill_val, fill_val, 6, 7, 8, 9]) * u.Jy, spectral_axis=np.arange(10) * u.nm) - specviz_helper.load_data(spec) + specviz_helper.load(spec) plugin = specviz_helper.plugins['Model Fitting'] plugin.model_component = 'Linear1D' @@ -463,7 +463,7 @@ def test_fitting_partial_overlap_subset(specviz_helper, fill_val): spec = Spectrum(flux=np.array([0, 1, 2, fill_val, fill_val, fill_val, 6, 7, 8, 9]) * u.Jy, spectral_axis=np.arange(10) * u.nm) - specviz_helper.load_data(spec) + specviz_helper.load(spec) plugin = specviz_helper.plugins['Model Fitting'] plugin.model_component = 'Linear1D' @@ -499,7 +499,7 @@ def test_all_nan_uncert(specviz_helper): uncertainty = StdDevUncertainty([np.nan, np.nan, np.nan, np.nan, np.nan, np.nan] * u.Jy) spec = Spectrum(flux=[1, 2, 3, 4, 5, 6]*u.Jy, uncertainty=uncertainty) - specviz_helper.load_data(spec) + specviz_helper.load(spec) plugin = specviz_helper.plugins['Model Fitting'] plugin.create_model_component('Linear1D') @@ -526,7 +526,7 @@ def test_all_nan_uncert_subset(specviz_helper): uncertainty = StdDevUncertainty([1, 1, np.nan, np.nan, np.nan, np.nan] * u.Jy) spec = Spectrum(flux=[2, 4, 3, 4, 5, 6]*u.Jy, uncertainty=uncertainty) - specviz_helper.load_data(spec) + specviz_helper.load(spec) plugin = specviz_helper.plugins['Model Fitting'] plugin.create_model_component('Linear1D') diff --git a/jdaviz/configs/default/plugins/plot_options/tests/test_plot_options.py b/jdaviz/configs/default/plugins/plot_options/tests/test_plot_options.py index 827adb4d79..00c4d10aae 100644 --- a/jdaviz/configs/default/plugins/plot_options/tests/test_plot_options.py +++ b/jdaviz/configs/default/plugins/plot_options/tests/test_plot_options.py @@ -11,7 +11,7 @@ @pytest.mark.filterwarnings('ignore') def test_multiselect(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) po = cubeviz_helper.app.get_tray_item_from_name('g-plot-options') # default selection for viewer should be flux-viewer (first in list) and nothing for layer @@ -74,7 +74,7 @@ def test_multiselect(cubeviz_helper, spectrum1d_cube): @pytest.mark.filterwarnings('ignore') def test_stretch_histogram(cubeviz_helper, spectrum1d_cube_with_uncerts): - cubeviz_helper.load_data(spectrum1d_cube_with_uncerts) + cubeviz_helper.load(spectrum1d_cube_with_uncerts) po = cubeviz_helper.app.get_tray_item_from_name('g-plot-options') po.plugin_opened = True @@ -149,7 +149,7 @@ def test_stretch_histogram(cubeviz_helper, spectrum1d_cube_with_uncerts): @pytest.mark.filterwarnings('ignore') def test_user_api(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) po = cubeviz_helper.plugins['Plot Options'] assert po.multiselect is False @@ -206,7 +206,7 @@ def test_user_api(cubeviz_helper, spectrum1d_cube): def test_stretch_spline(imviz_helper): image_1 = NDData(make_4gaussians_image(), unit=u.nJy) # Load the test data into imviz - imviz_helper.load_data(image_1) + imviz_helper.load(image_1) po = imviz_helper.plugins['Plot Options'] # Configure initial stretch options and select "Spline" function @@ -274,7 +274,7 @@ def test_apply_presets(imviz_helper): # Test applying presets with < 6 layers for i in range(4): - imviz_helper.load_data(arr, data_label=f"array_{i}") + imviz_helper.load(arr, data_label=f"array_{i}") po.image_color_mode = "Color" po.apply_RGB_presets() @@ -288,7 +288,7 @@ def test_apply_presets(imviz_helper): # Test applying presets with > 5 layers for i in range(4): - imviz_helper.load_data(arr, data_label=f"array_{i+4}") + imviz_helper.load(arr, data_label=f"array_{i+4}") po.layer = "array_5" po.image_visible = False @@ -330,7 +330,7 @@ def test_track_mixed_states(imviz_helper): rgb_colors = ["#ff0000", "#00ff00", "#0000ff"] for i in range(3): - imviz_helper.load_data(arr, data_label=f"array_{i}") + imviz_helper.load(arr, data_label=f"array_{i}") po.image_color_mode_value = 'One color per layer' for i in range(3): @@ -419,7 +419,7 @@ def test_segmentation_image(imviz_helper): in_circle = np.hypot(xx - x0, yy - y0) < radius segmentation_map[in_circle] = 1 - imviz_helper.load_data(segmentation_map) + imviz_helper.load(segmentation_map) plot_opts = imviz_helper.plugins['Plot Options'] plot_opts.image_colormap = 'Random' @@ -446,7 +446,7 @@ def test_imviz_select_all_layers(imviz_helper): # load three images in one viewer with imviz_helper.batch_load(): for i in range(3): - imviz_helper.load_data(arr, data_label=f"data_{i}") + imviz_helper.load(arr, data_label=f"data_{i}") plot_options = imviz_helper.plugins['Plot Options'] diff --git a/jdaviz/configs/default/plugins/subset_tools/subset_tools.py b/jdaviz/configs/default/plugins/subset_tools/subset_tools.py index 3af9b6361b..2624d3ad79 100644 --- a/jdaviz/configs/default/plugins/subset_tools/subset_tools.py +++ b/jdaviz/configs/default/plugins/subset_tools/subset_tools.py @@ -249,7 +249,7 @@ def get_regions(self, region_type=None, list_of_subset_labels=None, >>> import numpy as np >>> import astropy.units as u >>> imviz = Imviz() - >>> imviz.link_data(align_by='pixels') + >>> imviz.plugins['Orientation'].align_by = 'Pixels' >>> data = NDData(np.ones((128, 128)) * u.nJy, wcs=getfixture('image_2d_wcs')) >>> imviz.load_data(data) >>> plg = imviz.plugins['Subset Tools'] diff --git a/jdaviz/configs/default/plugins/subset_tools/tests/test_subset_tools.py b/jdaviz/configs/default/plugins/subset_tools/tests/test_subset_tools.py index a93adb64c6..8d5e2dbe49 100644 --- a/jdaviz/configs/default/plugins/subset_tools/tests/test_subset_tools.py +++ b/jdaviz/configs/default/plugins/subset_tools/tests/test_subset_tools.py @@ -22,7 +22,7 @@ def test_plugin(specviz_helper, spectrum1d): with warnings.catch_warnings(): warnings.simplefilter("ignore") - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) p = specviz_helper.plugins['Subset Tools'] # regression test for https://github.com/spacetelescope/jdaviz/issues/1693 @@ -39,7 +39,7 @@ def test_plugin(specviz_helper, spectrum1d): def test_subset_definition_with_composite_subset(cubeviz_helper, spectrum1d_cube): with warnings.catch_warnings(): warnings.simplefilter('ignore') - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) cubeviz_helper.app.get_tray_item_from_name('g-subset-tools') @@ -101,8 +101,8 @@ def test_circle_recenter_linking(roi_class, subset_info, imviz_helper, image_2d_ arr = np.ones((10, 10)) ndd = NDData(arr, wcs=image_2d_wcs) - imviz_helper.load_data(ndd, data_label='dataset1') - imviz_helper.load_data(ndd, data_label='dataset2') + imviz_helper.load(ndd, data_label='dataset1') + imviz_helper.load(ndd, data_label='dataset2') # apply subset roi_params = {key: subset_info[key]['initial_value'] for key in subset_info} @@ -147,7 +147,7 @@ def test_circle_recenter_linking(roi_class, subset_info, imviz_helper, image_2d_ # remove subsets and change link type to wcs dc = imviz_helper.app.data_collection dc.remove_subset_group(dc.subset_groups[0]) - imviz_helper.link_data(align_by='wcs') + imviz_helper.plugins['Orientation'].align_by = 'WCS' assert plugin.display_sky_coordinates # linking change should trigger change to True # apply original subset. transform sky coord of original subset to new pixels @@ -205,7 +205,7 @@ def test_circle_recenter_linking(roi_class, subset_info, imviz_helper, image_2d_ ) def test_import_spectral_region(cubeviz_helper, spectrum1d_cube, spec_regions, mode, len_subsets, len_subregions, subset_label): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) plg = cubeviz_helper.plugins['Subset Tools'] plg.import_region(spec_regions, combination_mode=mode, subset_label=subset_label) subsets = cubeviz_helper.app.get_subsets() @@ -227,7 +227,7 @@ def test_bad_labels(cubeviz_helper, spectrum1d_cube): SpectralRegion(6.494371022809778 * u.um, 6.724270682553864 * u.um), SpectralRegion(7.004748267441649 * u.um, 7.3404016303483965 * u.um)] - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) plg = cubeviz_helper.plugins['Subset Tools'] with pytest.raises(ValueError, match="Each subset label must be unique"): subset_label = ["Test", "Test", "Test"] @@ -239,7 +239,7 @@ def test_bad_labels(cubeviz_helper, spectrum1d_cube): def test_import_spectral_regions_file(cubeviz_helper, spectrum1d_cube, tmp_path): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) plg = cubeviz_helper.plugins['Subset Tools'] s = SpectralRegion(5*u.um, 6*u.um) local_path = str(tmp_path / 'spectral_region.ecsv') @@ -265,7 +265,7 @@ def test_import_spectral_regions_file(cubeviz_helper, spectrum1d_cube, tmp_path) def test_import_sky_region_in_cubeviz(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) plg = cubeviz_helper.plugins['Subset Tools'] ra = 339.0149557 * u.deg @@ -284,7 +284,7 @@ def test_get_regions(cubeviz_helper, spectrum1d_cube, imviz_helper): """Test Subset Tools.get regions.""" - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) plg = cubeviz_helper.plugins['Subset Tools'] # load one spectral region, which will become 'Subset 1' @@ -349,7 +349,7 @@ def test_get_regions_composite(imviz_helper): using subset_tools.get_regions """ a = np.ones((200, 200)) - imviz_helper.load_data(a, data_label="test") + imviz_helper.load(a, data_label="test") plg = imviz_helper.plugins['Subset Tools'] # apply two (not concentric) circular subsets @@ -407,7 +407,7 @@ def test_get_regions_composite(imviz_helper): def test_get_regions_composite_wcs_linked(imviz_helper, image_2d_wcs): data = NDData(np.ones((128, 128)) * u.nJy, wcs=image_2d_wcs) - imviz_helper.load_data(data) + imviz_helper.load(data) imviz_helper.plugins['Orientation'].align_by = 'WCS' @@ -438,8 +438,8 @@ def test_get_regions_composite_wcs_linked(imviz_helper, image_2d_wcs): def test_get_regions_composite_pixel_linked(imviz_helper, image_2d_wcs): data = NDData(np.ones((128, 128)) * u.nJy, wcs=image_2d_wcs) - imviz_helper.load_data(data, 'test 1') - imviz_helper.load_data(data, 'test 2') + imviz_helper.load(data, 'test 1') + imviz_helper.load(data, 'test 2') imviz_helper.plugins['Orientation'].align_by = 'Pixels' @@ -493,7 +493,7 @@ def test_get_composite_sky_region_remove(imviz_helper, image_2d_wcs): correctly retrieving the second subset. """ data = NDData(np.ones((128, 128)) * u.nJy, wcs=image_2d_wcs) - imviz_helper.load_data(data) + imviz_helper.load(data) imviz_helper.plugins['Orientation'].align_by = 'WCS' @@ -527,7 +527,7 @@ def test_check_valid_subset_label(imviz_helper): # imviz instance with some data data = NDData(np.ones((50, 50)) * u.nJy) - imviz_helper.load_data(data) + imviz_helper.load(data) st = imviz_helper.plugins["Subset Tools"] @@ -549,7 +549,7 @@ def test_check_valid_subset_label(imviz_helper): def test_rename_subset(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) plg = cubeviz_helper.plugins['Subset Tools'] spatial_reg = CirclePixelRegion(center=PixCoord(x=2, y=2), radius=2) @@ -572,7 +572,7 @@ def test_rename_subset(cubeviz_helper, spectrum1d_cube): def test_delete_subset(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) plg = cubeviz_helper.plugins['Subset Tools'] spatial_reg = CirclePixelRegion(center=PixCoord(x=2, y=2), radius=2) @@ -587,7 +587,7 @@ def test_delete_subset(cubeviz_helper, spectrum1d_cube): def test_update_subset(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) plg = cubeviz_helper.plugins['Subset Tools'] spatial_reg = CirclePixelRegion(center=PixCoord(x=2, y=2), radius=2) @@ -616,7 +616,7 @@ def test_update_subset(cubeviz_helper, spectrum1d_cube): def test_data_menu_subset_delete(cubeviz_helper, spectrum1d_cube): - cubeviz_helper.load_data(spectrum1d_cube) + cubeviz_helper.load(spectrum1d_cube) dm = cubeviz_helper.viewers['spectrum-viewer'].data_menu plg = cubeviz_helper.plugins['Subset Tools'] diff --git a/jdaviz/configs/default/tests/test_aida.py b/jdaviz/configs/default/tests/test_aida.py index f9b893b553..aae0df77c3 100644 --- a/jdaviz/configs/default/tests/test_aida.py +++ b/jdaviz/configs/default/tests/test_aida.py @@ -19,7 +19,7 @@ def assert_angle_close(angle1, angle2, atol=1 * u.arcsec): def test_get_viewport_sky(imviz_helper, image_hdu_wcs): - imviz_helper.load_data(image_hdu_wcs) + imviz_helper.load(image_hdu_wcs) imviz_helper.plugins['Orientation'].align_by = 'WCS' viewer = imviz_helper.app.get_viewer('imviz-0') @@ -48,7 +48,7 @@ def test_get_viewport_sky(imviz_helper, image_hdu_wcs): def test_set_viewport_sky(imviz_helper, image_hdu_wcs): - imviz_helper.load_data(image_hdu_wcs) + imviz_helper.load(image_hdu_wcs) imviz_helper.plugins['Orientation'].align_by = 'WCS' viewer = imviz_helper.app.get_viewer('imviz-0') @@ -70,7 +70,7 @@ def test_set_viewport_sky(imviz_helper, image_hdu_wcs): def test_set_viewport_sky_rotation(imviz_helper, image_hdu_wcs): - imviz_helper.load_data(image_hdu_wcs) + imviz_helper.load(image_hdu_wcs) imviz_helper.plugins['Orientation'].align_by = 'WCS' viewer = imviz_helper.app.get_viewer('imviz-0') @@ -90,7 +90,7 @@ def test_set_viewport_sky_rotation(imviz_helper, image_hdu_wcs): def test_get_viewport_external_update(imviz_helper, image_hdu_wcs): # arrange - imviz_helper.load_data(image_hdu_wcs) + imviz_helper.load(image_hdu_wcs) imviz_helper.plugins['Orientation'].align_by = 'WCS' viewer = imviz_helper.app.get_viewer('imviz-0') @@ -113,7 +113,7 @@ def test_get_viewport_external_update(imviz_helper, image_hdu_wcs): def test_set_viewport_pixel(imviz_helper, image_hdu_wcs): - imviz_helper.load_data(image_hdu_wcs) + imviz_helper.load(image_hdu_wcs) viewer = imviz_helper.app.get_viewer('imviz-0') diff --git a/jdaviz/configs/default/tests/test_data_menu.py b/jdaviz/configs/default/tests/test_data_menu.py index e6a65a6306..ac79a966b5 100644 --- a/jdaviz/configs/default/tests/test_data_menu.py +++ b/jdaviz/configs/default/tests/test_data_menu.py @@ -10,9 +10,9 @@ def test_data_menu_toggles(specviz_helper, spectrum1d): # which should be removed once the old data menu is removed from jdaviz # load 2 data entries - specviz_helper.load_data(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test") new_spec = specviz_helper.get_spectra(apply_slider_redshift=True)["test"]*0.9 - specviz_helper.load_data(new_spec, data_label="test2") + specviz_helper.load(new_spec, data_label="test2") # check that both are enabled in the data menu sv = specviz_helper.viewers['spectrum-viewer'] @@ -42,9 +42,9 @@ def test_data_menu_toggles(specviz_helper, spectrum1d): def test_data_menu_selection(specviz_helper, spectrum1d): # load 2 data entries - specviz_helper.load_data(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test") new_spec = specviz_helper.get_spectra(apply_slider_redshift=True)["test"]*0.9 - specviz_helper.load_data(new_spec, data_label="test2") + specviz_helper.load(new_spec, data_label="test2") sv = specviz_helper.viewers['spectrum-viewer'] dm = sv._obj.glue_viewer.data_menu @@ -73,7 +73,7 @@ def test_data_menu_selection(specviz_helper, spectrum1d): def test_data_menu_add_remove_data(imviz_helper): for i in range(3): - imviz_helper.load_data(np.zeros((2, 2)) + i, data_label=f'image_{i}', show_in_viewer=False) + imviz_helper.load(np.zeros((2, 2)) + i, data_label=f'image_{i}', show_in_viewer=False) dm = imviz_helper.viewers['imviz-0']._obj.glue_viewer.data_menu assert len(dm._obj.layer_items) == 0 @@ -104,7 +104,7 @@ def test_data_menu_add_remove_data(imviz_helper): def test_remove_all_data_cubeviz(cubeviz_helper, image_cube_hdu_obj_microns): - cubeviz_helper.load_data(image_cube_hdu_obj_microns, data_label="test") + cubeviz_helper.load(image_cube_hdu_obj_microns, data_label="test") dm1 = cubeviz_helper.viewers['flux-viewer']._obj.glue_viewer.data_menu dm2 = cubeviz_helper.viewers['uncert-viewer']._obj.glue_viewer.data_menu dm3 = cubeviz_helper.viewers['spectrum-viewer']._obj.glue_viewer.data_menu @@ -128,7 +128,7 @@ def test_remove_all_data_cubeviz(cubeviz_helper, image_cube_hdu_obj_microns): def test_data_menu_create_subset(imviz_helper): - imviz_helper.load_data(np.zeros((2, 2)), data_label='image', show_in_viewer=True) + imviz_helper.load(np.zeros((2, 2)), data_label='image', show_in_viewer=True) dm = imviz_helper.viewers['imviz-0']._obj.glue_viewer.data_menu assert imviz_helper.app.session.edit_subset_mode.edit_subset == [] @@ -140,9 +140,9 @@ def test_data_menu_create_subset(imviz_helper): def test_data_menu_remove_subset(specviz_helper, spectrum1d): # load 2 data entries - specviz_helper.load_data(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test") new_spec = specviz_helper.get_spectra(apply_slider_redshift=True)["test"]*0.9 - specviz_helper.load_data(new_spec, data_label="test2") + specviz_helper.load(new_spec, data_label="test2") dm = specviz_helper.viewers['spectrum-viewer']._obj.glue_viewer.data_menu sp = specviz_helper.plugins['Subset Tools'] @@ -179,7 +179,7 @@ def test_data_menu_dq_layers(imviz_helper): hdu_dq.name = 'DQ' data = fits.HDUList([fits.PrimaryHDU(), hdu_data, hdu_dq]) - imviz_helper.load_data(data, data_label="image", ext=('SCI', 'DQ'), show_in_viewer=True) + imviz_helper.load(data, data_label="image", ext=('SCI', 'DQ'), show_in_viewer=True) dm = imviz_helper.viewers['imviz-0']._obj.glue_viewer.data_menu assert dm.layer.choices == ['image[DQ,1]', 'image[SCI,1]'] @@ -203,7 +203,7 @@ def test_data_menu_dq_layers(imviz_helper): def test_data_menu_subset_appearance(specviz_helper, spectrum1d): # NOTE: this test is similar to above - the subset is appearing in time IF there # are two data entries, but not in this case with just one - specviz_helper.load_data(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test") dm = specviz_helper.viewers['spectrum-viewer']._obj.glue_viewer.data_menu sp = specviz_helper.plugins['Subset Tools'] @@ -217,9 +217,9 @@ def test_data_menu_subset_appearance(specviz_helper, spectrum1d): def test_data_menu_view_info(specviz_helper, spectrum1d): # load 2 data entries - specviz_helper.load_data(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test") new_spec = specviz_helper.get_spectra(apply_slider_redshift=True)["test"]*0.9 - specviz_helper.load_data(new_spec, data_label="test2") + specviz_helper.load(new_spec, data_label="test2") dm = specviz_helper.viewers['spectrum-viewer']._obj.glue_viewer.data_menu mp = specviz_helper.plugins['Metadata'] diff --git a/jdaviz/configs/imviz/tests/test_astrowidgets_api.py b/jdaviz/configs/imviz/tests/test_astrowidgets_api.py index 656618c7eb..cab409dacd 100644 --- a/jdaviz/configs/imviz/tests/test_astrowidgets_api.py +++ b/jdaviz/configs/imviz/tests/test_astrowidgets_api.py @@ -342,7 +342,7 @@ def test_markers_gwcs_lonlat(imviz_helper): with asdf.open(gw_file) as af: gw = af.tree['wcs'] ndd = NDData(np.ones((10, 10), dtype=np.float32), wcs=gw, unit='MJy/sr') - imviz_helper.load_data(ndd, data_label='MIRI_i2d') + imviz_helper.load(ndd, data_label='MIRI_i2d') assert imviz_helper.app.data_collection[0].label == 'MIRI_i2d[DATA]' assert imviz_helper.app.data_collection[0].components == [ 'Pixel Axis 0 [y]', 'Pixel Axis 1 [x]', 'Lat', 'Lon', 'DATA'] diff --git a/jdaviz/configs/imviz/tests/test_catalogs.py b/jdaviz/configs/imviz/tests/test_catalogs.py index e447446a6d..92ae7fbcbf 100644 --- a/jdaviz/configs/imviz/tests/test_catalogs.py +++ b/jdaviz/configs/imviz/tests/test_catalogs.py @@ -47,7 +47,7 @@ def test_plugin_image_no_result(self, imviz_helper, image_2d_wcs): arr = np.ones((10, 10)) ndd = NDData(arr, wcs=image_2d_wcs) - imviz_helper.load_data(ndd, data_label='no_results_data') + imviz_helper.load(ndd, data_label='no_results_data') catalogs_plugin = imviz_helper.plugins["Catalog Search"]._obj catalogs_plugin.plugin_opened = True @@ -87,7 +87,7 @@ def test_plugin_image_with_result(self, imviz_helper, tmp_path): 'CRPIX2': 745.0, 'CRVAL2': 1.54470013629, 'NAXIS2': 1489}) - imviz_helper.load_data(hdu1, data_label='has_wcs') + imviz_helper.load(hdu1, data_label='has_wcs') catalogs_plugin = imviz_helper.plugins["Catalog Search"] catalogs_plugin._obj.plugin_opened = True @@ -255,7 +255,7 @@ def test_catalog_reingestion(imviz_helper, tmp_path): 'CRPIX2': 745.0, 'CRVAL2': 1.54470013629, 'NAXIS2': 1489}) - imviz_helper.load_data(hdu1, data_label='has_wcs') + imviz_helper.load(hdu1, data_label='has_wcs') catalog_plg = imviz_helper.plugins['Catalog Search'] export_plg = imviz_helper.plugins['Export'] @@ -298,7 +298,7 @@ def test_offline_ecsv_catalog(imviz_helper, image_2d_wcs, tmp_path): n_entries = len(tbl) ndd = NDData(np.ones((10, 10)), wcs=image_2d_wcs) - imviz_helper.load_data(ndd, data_label='data_with_wcs') + imviz_helper.load(ndd, data_label='data_with_wcs') assert len(imviz_helper.app.data_collection) == 1 catalogs_plugin = imviz_helper.plugins['Catalog Search'] @@ -378,7 +378,7 @@ def test_zoom_to_selected(imviz_helper, image_2d_wcs): arr = np.ones((500, 500)) ndd = NDData(arr, wcs=image_2d_wcs) - imviz_helper.load_data(ndd) + imviz_helper.load(ndd) # sources at pixel coords ~(100, 100), ~(200, 200) sky_coord = SkyCoord(ra=[337.49056532, 337.46086081], @@ -443,7 +443,7 @@ def test_zoom_to_selected(imviz_helper, image_2d_wcs): def test_select_tool(imviz_helper, image_2d_wcs): arr = np.ones((500, 500)) ndd = NDData(arr, wcs=image_2d_wcs) - imviz_helper.load_data(ndd) + imviz_helper.load(ndd) # write out catalog to file so we can read it back in # todo: if tables can be loaded directly at some point, do that @@ -516,7 +516,7 @@ def test_offline_ecsv_catalog_with_extra_columns(imviz_helper, image_2d_wcs): }) ndd = NDData(np.ones((10, 10)), wcs=image_2d_wcs) - imviz_helper.load_data(ndd, data_label='data_with_wcs') + imviz_helper.load(ndd, data_label='data_with_wcs') assert len(imviz_helper.app.data_collection) == 1 catalogs_plugin = imviz_helper.plugins['Catalog Search'] @@ -541,7 +541,7 @@ def test_select_catalog_table_rows(imviz_helper, image_2d_wcs): arr = np.ones((500, 500)) ndd = NDData(arr, wcs=image_2d_wcs) - imviz_helper.load_data(ndd) + imviz_helper.load(ndd) sky_coord = SkyCoord(ra=[337.49, 337.46, 337.47, 337.48, 337.49, 337.50], dec=[-20.81, -20.78, -20.79, -20.80, -20.77, -20.76], diff --git a/jdaviz/configs/imviz/tests/test_delete_data.py b/jdaviz/configs/imviz/tests/test_delete_data.py index 3b4f1ae7f2..afcf32a5f2 100644 --- a/jdaviz/configs/imviz/tests/test_delete_data.py +++ b/jdaviz/configs/imviz/tests/test_delete_data.py @@ -23,9 +23,9 @@ def test_delete_with_subset_wcs(self): # First data with WCS, same as the one in BaseImviz_WCS_NoWCS. hdu3 = NDData(arr, wcs=self.wcs_1) - self.imviz.load_data(hdu3, data_label='has_wcs_3') + self.imviz.load(hdu3, data_label='has_wcs_3') - self.imviz.link_data(align_by='wcs', wcs_fallback_scheme=None) + self.imviz.plugins['Orientation'].align_by = 'WCS' # Add a subset reg = CirclePixelRegion(PixCoord(2, 2), 3).to_sky(self.wcs_1) diff --git a/jdaviz/configs/imviz/tests/test_footprints.py b/jdaviz/configs/imviz/tests/test_footprints.py index f0e77dac8f..1061905223 100644 --- a/jdaviz/configs/imviz/tests/test_footprints.py +++ b/jdaviz/configs/imviz/tests/test_footprints.py @@ -22,8 +22,8 @@ def test_user_api(imviz_helper, image_2d_wcs, tmp_path): arr = np.ones((10, 10)) ndd = NDData(arr, wcs=image_2d_wcs) # load the image twice to test linking - imviz_helper.load_data(ndd) - imviz_helper.load_data(ndd) + imviz_helper.load(ndd) + imviz_helper.load(ndd) plugin = imviz_helper.plugins['Footprints'] default_color = plugin.color @@ -209,8 +209,8 @@ def test_api_after_linking(imviz_helper): viewer = imviz_helper.app.get_viewer_by_id('imviz-0') ndd = NDData(arr, wcs=image_2d_wcs) - imviz_helper.load_data(ndd) - imviz_helper.load_data(ndd) + imviz_helper.load(ndd) + imviz_helper.load(ndd) plugin = imviz_helper.plugins['Footprints'] with plugin.as_active(): @@ -228,7 +228,7 @@ def test_api_after_linking(imviz_helper): assert no_marks_displayed is True # link by wcs and retest - imviz_helper.link_data(align_by='wcs') + imviz_helper.plugins['Orientation'].align_by = 'WCS' viewer_marks = _get_markers_from_viewer(viewer) # distinguish default from custom overlay with color @@ -250,8 +250,8 @@ def test_footprint_updates_on_rotation(imviz_helper): arr = np.random.normal(size=(10, 10)) ndd = NDData(arr, wcs=image_2d_wcs) - imviz_helper.load_data(ndd) - imviz_helper.link_data(align_by='wcs') + imviz_helper.load(ndd) + imviz_helper.plugins['Orientation'].align_by = 'WCS' footprints = imviz_helper.plugins['Footprints'] footprints.keep_active = True @@ -311,7 +311,7 @@ def test_footprint_select(imviz_helper): 'CRPIX2': 1, 'CRVAL2': -33.71313112382379}) arr = np.arange(40000).reshape(200, 200) ndd = NDData(arr, wcs=wcs) - imviz_helper.load_data(ndd) + imviz_helper.load(ndd) fp = imviz_helper.plugins["Footprints"] fp._obj.toggle_custom_toolbar() toolbar = imviz_helper.viewers['imviz-0']._obj.glue_viewer.toolbar @@ -338,7 +338,7 @@ def test_footprint_loaders(imviz_helper, image_2d_wcs): arr = np.ones((10, 10)) ndd = NDData(arr, wcs=image_2d_wcs) # load the image twice to test linking - imviz_helper.load_data(ndd) + imviz_helper.load(ndd) imviz_helper.plugins['Orientation'].align_by = 'WCS' plg = imviz_helper.plugins['Footprints'] diff --git a/jdaviz/configs/imviz/tests/test_helper.py b/jdaviz/configs/imviz/tests/test_helper.py index 44bf7d3aee..0598a8249d 100644 --- a/jdaviz/configs/imviz/tests/test_helper.py +++ b/jdaviz/configs/imviz/tests/test_helper.py @@ -18,7 +18,7 @@ def test_create_new_viewer(imviz_helper, image_2d_wcs): data_label = 'image-data' viewer_name = 'user-created-viewer' - imviz_helper.load_data(arr, data_label=data_label, show_in_viewer=False) + imviz_helper.load(arr, data_label=data_label, show_in_viewer=False) imviz_helper.create_image_viewer(viewer_name=viewer_name) returned_data = imviz_helper.get_data(data_label) diff --git a/jdaviz/configs/imviz/tests/test_line_profile_xy.py b/jdaviz/configs/imviz/tests/test_line_profile_xy.py index c22f1a53d7..b8f3186b57 100644 --- a/jdaviz/configs/imviz/tests/test_line_profile_xy.py +++ b/jdaviz/configs/imviz/tests/test_line_profile_xy.py @@ -148,7 +148,7 @@ def test_plugin(self): def test_line_profile_with_nan(imviz_helper): arr = np.ones((10, 10)) arr[5, 5] = np.nan - imviz_helper.load_data(arr) + imviz_helper.load(arr) lp_plugin = imviz_helper.plugins['Image Profiles (XY)']._obj lp_plugin.plugin_opened = True diff --git a/jdaviz/configs/imviz/tests/test_linking.py b/jdaviz/configs/imviz/tests/test_linking.py index 8c2861d5e3..adf2cb5462 100644 --- a/jdaviz/configs/imviz/tests/test_linking.py +++ b/jdaviz/configs/imviz/tests/test_linking.py @@ -26,7 +26,7 @@ def check_all_wcs_links(self): assert all([isinstance(link, (AffineLink, OffsetLink)) for link in links]) def test_pixel_linking(self): - self.imviz.link_data(align_by='pixels') + self.imviz.plugins['Orientation'].align_by = 'Pixels' self.check_all_pixel_links() @property @@ -282,7 +282,7 @@ def test_wcslink_rotated(self): class TestLink_GWCS_GWCS(BaseImviz_GWCS_GWCS): def test_pixel_linking(self): - self.imviz.link_data(align_by='pixels') + self.imviz.plugins['Orientation'].align_by = 'Pixels' # Check the coordinates display: Last loaded is on top. label_mouseover = self.imviz._coords_info diff --git a/jdaviz/configs/imviz/tests/test_parser.py b/jdaviz/configs/imviz/tests/test_parser.py index 13f6db9bba..751f37d617 100644 --- a/jdaviz/configs/imviz/tests/test_parser.py +++ b/jdaviz/configs/imviz/tests/test_parser.py @@ -84,7 +84,7 @@ def test_parse_numpy_array_1d_2d(self, imviz_helper): parse_data(imviz_helper.app, np.zeros(2)) # Passing in data_label keyword as posarg. - imviz_helper.load_data(np.zeros((2, 2)), 'some_array', show_in_viewer=False) + imviz_helper.load(np.zeros((2, 2)), data_label='some_array', viewer=[]) data = imviz_helper.app.data_collection[0] comp = data.get_component('DATA') assert data.label == 'some_array' @@ -101,11 +101,11 @@ def test_parse_numpy_array_3d(self, imviz_helper, manual_loop): if not manual_loop: # We use higher level load_data() here to make sure linking does not crash. - imviz_helper.load_data(arr, data_label=data_label) + imviz_helper.load(arr, data_label=data_label) else: with imviz_helper.batch_load(): for i in range(n_slices): - imviz_helper.load_data(arr[i, :, :], data_label=data_label) + imviz_helper.load(arr[i, :, :], data_label=data_label) assert len(imviz_helper.app.data_collection) == n_slices assert len(imviz_helper.app.data_collection.links) == 8 @@ -120,7 +120,7 @@ def test_parse_numpy_array_3d(self, imviz_helper, manual_loop): @pytest.mark.filterwarnings('ignore:.*path should be string, bytes, os.PathLike or integer, not ndarray.*:DeprecationWarning') # noqa def test_parse_numpy_array_3d_too_many(self, imviz_helper): with pytest.warns(UserWarning, match='16 or more 3D slices found'): - imviz_helper.load_data(np.ones((17, 5, 5))) + imviz_helper.load(np.ones((17, 5, 5))) assert len(imviz_helper.app.data_collection) == 16 assert imviz_helper.app.data_collection[0].shape == (5, 5) @@ -128,20 +128,20 @@ def test_parse_numpy_array_3d_too_many(self, imviz_helper): def test_parse_numpy_array_4d(self, imviz_helper): # Check logic is in higher level method. - imviz_helper.load_data(np.ones((1, 2, 5, 5))) + imviz_helper.load(np.ones((1, 2, 5, 5))) assert len(imviz_helper.app.data_collection) == 2 assert imviz_helper.app.data_collection[0].shape == (5, 5) assert imviz_helper.app.data_collection[1].shape == (5, 5) with pytest.raises(ValueError, match='cannot load this array with ndim'): - imviz_helper.load_data(np.ones((2, 2, 5, 5))) + imviz_helper.load(np.ones((2, 2, 5, 5))) def test_parse_nddata_simple(self, imviz_helper): with pytest.raises(ValueError, match='Imviz cannot load this NDData with ndim=1'): parse_data(imviz_helper.app, NDData([1, 2, 3, 4])) ndd = NDData([[1, 2], [3, 4]]) - imviz_helper.load_data(ndd, data_label='some_data', show_in_viewer=False) + imviz_helper.load(ndd, data_label='some_data', viewer=[]) data = imviz_helper.app.data_collection[0] comp = data.get_component('DATA') assert data.label == 'some_data[DATA]' @@ -156,7 +156,7 @@ def test_parse_nddata_simple(self, imviz_helper): (NDData([[1, 2], [3, 4]], uncertainty=StdDevUncertainty([[0.1, 0.2], [0.3, 0.4]])), ['DATA', 'UNCERTAINTY'])]) def test_parse_nddata_with_one_only(self, imviz_helper, ndd, attributes): - imviz_helper.load_data(ndd, data_label='some_data', show_in_viewer=False) + imviz_helper.load(ndd, data_label='some_data', viewer=[]) for i, attrib in enumerate(attributes): data = imviz_helper.app.data_collection[i] comp = data.get_component(attrib) @@ -169,7 +169,7 @@ def test_parse_nddata_with_everything(self, imviz_helper): ndd = NDData([[1, 2], [3, 4]], mask=[[True, False], [False, False]], uncertainty=StdDevUncertainty([[0.1, 0.2], [0.3, 0.4]]), unit=u.MJy/u.sr, wcs=WCS(naxis=2), meta={'name': 'my_ndd'}) - imviz_helper.load_data(ndd, data_label='some_data', show_in_viewer=False) + imviz_helper.load(ndd, data_label='some_data', viewer=[]) for i, attrib in enumerate(['DATA', 'MASK', 'UNCERTAINTY']): data = imviz_helper.app.data_collection[i] comp = data.get_component(attrib) @@ -195,7 +195,7 @@ def test_parse_rgba(self, imviz_helper, tmp_path, format): filename = str(tmp_path / f'myimage.{format}') imsave(filename, a) - imviz_helper.load_data(filename, show_in_viewer=False) + imviz_helper.load(filename, viewer=[]) data = imviz_helper.app.data_collection[0] assert data.label == 'myimage' assert data.shape == (10, 10) @@ -212,7 +212,7 @@ def test_filelist(self, imviz_helper, tmp_path): hdu.writeto(fpath, overwrite=True) flist = ','.join(flist) - imviz_helper.load_data(flist, show_in_viewer=False) + imviz_helper.load(flist, viewer=[]) for i in range(2): data = imviz_helper.app.data_collection[i] @@ -223,7 +223,7 @@ def test_filelist(self, imviz_helper, tmp_path): np.testing.assert_allclose(comp.data.mean(), i) with pytest.raises(ValueError, match='Do not manually overwrite data_label'): - imviz_helper.load_data(flist, data_label='foo', show_in_viewer=False) + imviz_helper.load(flist, data_label='foo', viewer=[]) def test_parse_asdf_in_fits_4d(self, imviz_helper, tmp_path): hdulist = fits.HDUList([ @@ -240,7 +240,7 @@ def test_parse_asdf_in_fits_4d(self, imviz_helper, tmp_path): def test_parse_jwst_nircam_level2(self, imviz_helper): # Default behavior: Science image - imviz_helper.load_data(self.jwst_asdf_url_1, timeout=100, gwcs_to_fits_sip=False) + imviz_helper.load(self.jwst_asdf_url_1, timeout=100, gwcs_to_fits_sip=False) data = imviz_helper.app.data_collection[0] comp = data.get_component('data') @@ -321,9 +321,9 @@ def test_parse_jwst_nircam_level2(self, imviz_helper): # --- Back to parser testing below. --- # Request specific extension (name + ver, but ver is not used), use given label - imviz_helper.load_data(self.jwst_asdf_url_1, cache=True, ext='DQ', + imviz_helper.load(self.jwst_asdf_url_1, cache=True, extension='DQ', data_label='jw01072001001_01101_00001_nrcb1_cal', - show_in_viewer=False) + viewer=[]) data = imviz_helper.app.data_collection[1] comp = data.get_component('dq') assert data.label == 'jw01072001001_01101_00001_nrcb1_cal[DQ,1]' @@ -333,9 +333,9 @@ def test_parse_jwst_nircam_level2(self, imviz_helper): # Pass in HDUList directly + ext (name only), use given label filename = download_file(self.jwst_asdf_url_1, cache=True) with fits.open(filename) as pf: - imviz_helper.load_data(pf, ext='SCI', + imviz_helper.load(pf, extension='SCI', data_label='jw01072001001_01101_00001_nrcb1_cal', - show_in_viewer=False) + viewer=[]) data = imviz_helper.app.data_collection[2] comp = data.get_component('data') # SCI = DATA assert data.label == 'jw01072001001_01101_00001_nrcb1_cal[SCI,1]' @@ -344,17 +344,17 @@ def test_parse_jwst_nircam_level2(self, imviz_helper): # Test duplicate label functionality imviz_helper.app.data_collection.clear() - imviz_helper.load_data(pf, ext='SCI', data_label='TEST', show_in_viewer=False) + imviz_helper.load(pf, extension='SCI', data_label='TEST', viewer=[]) data = imviz_helper.app.data_collection[0] assert data.label.endswith('[SCI,1]') - imviz_helper.load_data(pf, ext='SCI', data_label='TEST', show_in_viewer=False) + imviz_helper.load(pf, extension='SCI', data_label='TEST', viewer=[]) data = imviz_helper.app.data_collection[1] assert data.label.endswith('[SCI,1] (1)') # Load all extensions imviz_helper.app.data_collection.clear() - imviz_helper.load_data(pf, ext='*', show_in_viewer=False) + imviz_helper.load(pf, extension='*', viewer=[]) data = imviz_helper.app.data_collection assert len(data.labels) == 7 assert data.labels[0].endswith('[SCI,1]') @@ -367,11 +367,11 @@ def test_parse_jwst_nircam_level2(self, imviz_helper): # Invalid ASDF attribute (extension) with pytest.raises(KeyError, match='does_not_exist'): - parse_data(imviz_helper.app, filename, ext='DOES_NOT_EXIST', data_label='foo') + parse_data(imviz_helper.app, filename, extension='DOES_NOT_EXIST', data_label='foo') @pytest.mark.remote_data def test_parse_jwst_niriss_grism(self, imviz_helper): - imviz_helper.load_data(self.jwst_asdf_url_2, cache=True, show_in_viewer=False) + imviz_helper.load(self.jwst_asdf_url_2, cache=True, viewer=[]) data = imviz_helper.app.data_collection[0] for label in ('SCI,1', 'data'): if label in data.component_ids(): @@ -390,7 +390,7 @@ def test_parse_hst_drz(self, imviz_helper): filename = download_file(url, cache=True) # Default behavior: Load first image - imviz_helper.load_data(url, cache=True) + imviz_helper.load(url, cache=True) data = imviz_helper.app.data_collection[0] comp = data.get_component('SCI,1') expected_label = os.path.splitext(os.path.basename(url))[0] + '[SCI,1]' @@ -444,8 +444,8 @@ def test_parse_hst_drz(self, imviz_helper): assert_quantity_allclose(tbl[0]['mean'], 0.049325 * data_unit, rtol=1e-3) # Request specific extension (name only), use given label - imviz_helper.load_data(filename, ext='CTX', data_label='jclj01010_drz', - show_in_viewer=False) + imviz_helper.load(filename, extension='CTX', data_label='jclj01010_drz', + viewer=[]) data = imviz_helper.app.data_collection[1] comp = data.get_component('CTX,1') assert data.label == 'jclj01010_drz[CTX,1]' @@ -453,8 +453,8 @@ def test_parse_hst_drz(self, imviz_helper): assert comp.units == '' # BUNIT is not set # Request specific extension and use given label - imviz_helper.load_data(filename, ext='WHT', data_label='jclj01010_drz', - show_in_viewer=False) + imviz_helper.load(filename, extension='WHT', data_label='jclj01010_drz', + viewer=[]) data = imviz_helper.app.data_collection[2] comp = data.get_component('WHT,1') assert data.label == 'jclj01010_drz[WHT,1]' @@ -464,21 +464,21 @@ def test_parse_hst_drz(self, imviz_helper): # Pass in file obj directly with fits.open(filename) as pf: # Default behavior: Load first image - imviz_helper.load_data(pf, show_in_viewer=False) + imviz_helper.load(pf, viewer=[]) data = imviz_helper.app.data_collection[3] assert data.label.startswith('Image') and data.label.endswith('[SCI,1]') assert_allclose(data.meta['PHOTFLAM'], 7.8711728E-20) assert 'SCI,1' in data.components # Request specific extension (name only), use given label - imviz_helper.load_data(pf, ext='CTX', show_in_viewer=False) + imviz_helper.load(pf, extension='CTX', viewer=[]) data = imviz_helper.app.data_collection[4] assert data.label.startswith('Image') and data.label.endswith('[CTX,1]') assert data.meta['EXTNAME'] == 'CTX' assert 'CTX,1' in data.components # Pass in HDU directly, use given label - imviz_helper.load_data(pf[2], data_label='foo', show_in_viewer=False) + imviz_helper.load(pf[2], data_label='foo', viewer=[]) data = imviz_helper.app.data_collection[5] assert data.label == 'foo[WHT,1]' assert data.meta['EXTNAME'] == 'WHT' @@ -486,7 +486,7 @@ def test_parse_hst_drz(self, imviz_helper): # Load all extensions imviz_helper.app.data_collection.clear() - imviz_helper.load_data(filename, ext='*', show_in_viewer=False) + imviz_helper.load(filename, extension='*', viewer=[]) data = imviz_helper.app.data_collection assert len(data.labels) == 3 assert data.labels[0].endswith('[SCI,1]') @@ -511,7 +511,7 @@ def test_gwcs_to_fits_sip(self, gwcs_to_fits_sip, expected_cls, imviz_helper): Test gwcs_to_fits_sip as an argument to load_data until it is fully deprecated. """ - imviz_helper.load_data(self.jwst_asdf_url_1, cache=True, + imviz_helper.load(self.jwst_asdf_url_1, cache=True, gwcs_to_fits_sip=gwcs_to_fits_sip) data = imviz_helper.app.data_collection[0] @@ -521,11 +521,11 @@ def test_gwcs_to_fits_sip(self, gwcs_to_fits_sip, expected_cls, imviz_helper): def test_load_valid_not_valid(imviz_helper): # Load something valid. arr = np.ones((5, 5)) - imviz_helper.load_data(arr, data_label='valid', show_in_viewer=False) + imviz_helper.load(arr, data_label='valid', viewer=[]) # Load something invalid. with pytest.raises(ValueError, match='no valid loaders found for input'): - imviz_helper.load_data(np.zeros(2), show_in_viewer=False) + imviz_helper.load(np.zeros(2), viewer=[]) # Make sure valid data is still there. assert (len(imviz_helper.app.data_collection) == 1 @@ -535,5 +535,5 @@ def test_load_valid_not_valid(imviz_helper): @pytest.mark.skipif(not HAS_ROMAN_DATAMODELS, reason="roman_datamodels is not installed") def test_roman_parser(imviz_helper, roman_imagemodel): - imviz_helper.load_data(roman_imagemodel, data_label='roman_wfi_image_model', ext='data') + imviz_helper.load(roman_imagemodel, data_label='roman_wfi_image_model', extension='data') assert len(imviz_helper.app.data_collection) == 1 diff --git a/jdaviz/configs/imviz/tests/test_parser_asdf.py b/jdaviz/configs/imviz/tests/test_parser_asdf.py index bd0d73263b..6328da7b43 100644 --- a/jdaviz/configs/imviz/tests/test_parser_asdf.py +++ b/jdaviz/configs/imviz/tests/test_parser_asdf.py @@ -20,7 +20,7 @@ def test_asdf_not_rdm(imviz_helper): } af = asdf.AsdfFile(tree=tree) - imviz_helper.load_data(af) + imviz_helper.load(af) out_component = imviz_helper.app.data_collection[0].get_component('DATA') np.testing.assert_array_equal(in_data.value, out_component.data) assert str(in_unit) == out_component.units diff --git a/jdaviz/configs/imviz/tests/test_parser_roman.py b/jdaviz/configs/imviz/tests/test_parser_roman.py index f29f848332..e92ef07dfc 100644 --- a/jdaviz/configs/imviz/tests/test_parser_roman.py +++ b/jdaviz/configs/imviz/tests/test_parser_roman.py @@ -12,7 +12,7 @@ ('data', 1), (['data', 'var_rnoise'], 2)]) def test_roman_wfi_ext_options(imviz_helper, roman_imagemodel, ext_list, n_dc): - imviz_helper.load_data(roman_imagemodel, data_label='roman_wfi_image_model', ext=ext_list) + imviz_helper.load(roman_imagemodel, data_label='roman_wfi_image_model', ext=ext_list) dc = imviz_helper.app.data_collection assert len(dc) == n_dc diff --git a/jdaviz/configs/imviz/tests/test_regions.py b/jdaviz/configs/imviz/tests/test_regions.py index b9608f6af6..9851206de4 100644 --- a/jdaviz/configs/imviz/tests/test_regions.py +++ b/jdaviz/configs/imviz/tests/test_regions.py @@ -210,10 +210,10 @@ def setup_class(self): def test_ds9_load_all(self, imviz_helper): with pytest.raises(ValueError, match="Cannot load regions without data"): - imviz_helper.load_data(self.region_file) + imviz_helper.load(self.region_file) self.viewer = imviz_helper.default_viewer._obj.glue_viewer - imviz_helper.load_data(self.arr, data_label='my_image') + imviz_helper.load(self.arr, data_label='my_image') bad_regions = imviz_helper.plugins['Subset Tools'].import_region( self.region_file, return_bad_regions=True) assert len(bad_regions) == 1 @@ -231,7 +231,7 @@ def test_ds9_load_all(self, imviz_helper): def test_ds9_load_two_good(self, imviz_helper): self.viewer = imviz_helper.default_viewer._obj.glue_viewer - imviz_helper.load_data(self.arr, data_label='my_image') + imviz_helper.load(self.arr, data_label='my_image') bad_regions = imviz_helper.plugins['Subset Tools'].import_region( self.region_file, max_num_regions=2, return_bad_regions=True) assert len(bad_regions) == 0 @@ -241,7 +241,7 @@ def test_ds9_load_two_good(self, imviz_helper): def test_ds9_load_one_bad(self, imviz_helper): self.viewer = imviz_helper.default_viewer._obj.glue_viewer - imviz_helper.load_data(self.arr, data_label='my_image') + imviz_helper.load(self.arr, data_label='my_image') bad_regions = imviz_helper.plugins['Subset Tools'].import_region( self.raw_regions[6], return_bad_regions=True) assert len(bad_regions) == 1 @@ -250,7 +250,7 @@ def test_ds9_load_one_bad(self, imviz_helper): def test_ds9_load_one_good_one_bad(self, imviz_helper): self.viewer = imviz_helper.default_viewer._obj.glue_viewer - imviz_helper.load_data(self.arr, data_label='my_image') + imviz_helper.load(self.arr, data_label='my_image') bad_regions = imviz_helper.plugins['Subset Tools'].import_region( [self.raw_regions[3], self.raw_regions[6]], return_bad_regions=True) assert len(bad_regions) == 1 diff --git a/jdaviz/configs/imviz/tests/test_simple_aper_phot.py b/jdaviz/configs/imviz/tests/test_simple_aper_phot.py index 21fcf5842a..96b9f356b2 100644 --- a/jdaviz/configs/imviz/tests/test_simple_aper_phot.py +++ b/jdaviz/configs/imviz/tests/test_simple_aper_phot.py @@ -272,14 +272,14 @@ class TestAdvancedAperPhot: def setup_class(self, imviz_helper): # Reference image fn_1 = get_pkg_data_filename('data/gauss100_fits_wcs.fits') - imviz_helper.load_data(fn_1) + imviz_helper.load(fn_1) # Different pixel scale - imviz_helper.load_data(get_pkg_data_filename('data/gauss100_fits_wcs_block_reduced.fits')) + imviz_helper.load(get_pkg_data_filename('data/gauss100_fits_wcs_block_reduced.fits')) # Different pixel scale + rotated - imviz_helper.load_data(get_pkg_data_filename('data/gauss100_fits_wcs_block_reduced_rotated.fits')) # noqa: E501 + imviz_helper.load(get_pkg_data_filename('data/gauss100_fits_wcs_block_reduced_rotated.fits')) # noqa: E501 # Link them by WCS - imviz_helper.link_data(align_by='wcs') + imviz_helper.plugins['Orientation'].align_by = 'WCS' w = imviz_helper.app.data_collection[0].coords # Regions to be used for aperture photometry @@ -344,8 +344,8 @@ def test_annulus_background(imviz_helper): bg_4gauss_3 = 45.416834 bg_4gauss_4 = 4.939397 - imviz_helper.load_data(gauss4, data_label='four_gaussians') - imviz_helper.load_data(ones, data_label='ones') + imviz_helper.load(gauss4, data_label='four_gaussians') + imviz_helper.load(ones, data_label='ones') phot_plugin = imviz_helper.plugins['Aperture Photometry'] phot_plugin.dataset.selected = 'ones' @@ -421,7 +421,7 @@ def test_fit_radial_profile_with_nan(imviz_helper): # Insert NaN gauss4[25, 150] = np.nan - imviz_helper.load_data(gauss4, data_label='four_gaussians') + imviz_helper.load(gauss4, data_label='four_gaussians') # Mark an object of interest circle_1 = CirclePixelRegion(center=PixCoord(x=150, y=25), radius=7) @@ -508,7 +508,7 @@ def test_curve_of_growth(with_unit): def test_cubeviz_batch(cubeviz_helper, spectrum1d_cube_fluxunit_jy_per_steradian): - cubeviz_helper.load_data(spectrum1d_cube_fluxunit_jy_per_steradian, data_label='test') + cubeviz_helper.load(spectrum1d_cube_fluxunit_jy_per_steradian, data_label='test') phot_plugin = cubeviz_helper.plugins['Aperture Photometry'] uc_plugin = cubeviz_helper.plugins['Unit Conversion'] subset_plugin = cubeviz_helper.plugins['Subset Tools'] diff --git a/jdaviz/configs/imviz/tests/test_tools.py b/jdaviz/configs/imviz/tests/test_tools.py index c9eec3e6b7..b56516c5aa 100644 --- a/jdaviz/configs/imviz/tests/test_tools.py +++ b/jdaviz/configs/imviz/tests/test_tools.py @@ -87,8 +87,8 @@ def test_panzoom_click_center_linking(imviz_helper, align_by): arr_small = np.ones((20, 15), dtype=int) w_small = create_example_gwcs(arr_small.shape) - imviz_helper.load_data(NDData(arr_big, wcs=w_big), data_label="big") - imviz_helper.load_data(NDData(arr_small, wcs=w_small), data_label="small") + imviz_helper.load(NDData(arr_big, wcs=w_big), data_label="big") + imviz_helper.load(NDData(arr_small, wcs=w_small), data_label="small") lc_plugin = imviz_helper.plugins['Orientation'] lc_plugin.align_by = align_by @@ -117,7 +117,7 @@ def test_blink(imviz_helper): viewer = imviz_helper.default_viewer._obj.glue_viewer for i in range(3): - imviz_helper.load_data(np.zeros((2, 2)) + i, data_label=f'image_{i}') + imviz_helper.load(np.zeros((2, 2)) + i, data_label=f'image_{i}') label_mouseover = imviz_helper._coords_info viewer.on_mouse_or_key_event({'event': 'keydown', 'key': 'b', 'domain': {'x': 0, 'y': 0}}) @@ -147,12 +147,12 @@ def test_compass_open_while_load(imviz_helper): plg._obj.plugin_opened = True # Should not crash even if Compass is open in tray. - imviz_helper.load_data(np.ones((2, 2))) + imviz_helper.load(np.ones((2, 2))) assert len(imviz_helper.app.data_collection) == 1 def test_tool_visibility(imviz_helper): - imviz_helper.load_data(np.ones((2, 2))) + imviz_helper.load(np.ones((2, 2))) tb = imviz_helper.default_viewer._obj.glue_viewer.toolbar assert not tb.tools_data['jdaviz:boxzoommatch']['visible'] diff --git a/jdaviz/configs/imviz/tests/test_viewers.py b/jdaviz/configs/imviz/tests/test_viewers.py index b88dd78961..7e6bcfd0c4 100644 --- a/jdaviz/configs/imviz/tests/test_viewers.py +++ b/jdaviz/configs/imviz/tests/test_viewers.py @@ -48,7 +48,7 @@ def test_create_destroy_viewer(imviz_helper, desired_name, actual_name): def test_create_viewer_align_by_wcs(imviz_helper, image_2d_wcs): data = NDData(np.ones((128, 128)) * u.nJy, wcs=image_2d_wcs) - imviz_helper.load_data(data, data_label='my_data') + imviz_helper.load(data, data_label='my_data') imviz_helper.create_image_viewer(viewer_name='new-viewer') dm = imviz_helper.viewers['new-viewer'].data_menu @@ -64,7 +64,7 @@ def test_create_viewer_align_by_wcs(imviz_helper, image_2d_wcs): def test_align_by_wcs_create_viewer(imviz_helper, image_2d_wcs): data = NDData(np.ones((128, 128)) * u.nJy, wcs=image_2d_wcs) - imviz_helper.load_data(data, data_label='my_data') + imviz_helper.load(data, data_label='my_data') imviz_helper.plugins['Orientation'].align_by = 'WCS' @@ -97,7 +97,7 @@ def test_destroy_viewer_invalid(imviz_helper): def test_destroy_viewer_with_subset(imviz_helper): """Regression test for https://github.com/spacetelescope/jdaviz/issues/1614""" arr = np.ones((10, 10)) - imviz_helper.load_data(arr, data_label='my_array') + imviz_helper.load(arr, data_label='my_array') # Create a second viewer. imviz_helper.create_image_viewer(viewer_name='second') @@ -140,7 +140,7 @@ def test_mastviz_config(): def test_zoom_center_radius_init(imviz_helper): """Regression test for https://github.com/spacetelescope/jdaviz/issues/3217""" arr = np.ones((10, 10)) - imviz_helper.load_data(arr, data_label='my_array') + imviz_helper.load(arr, data_label='my_array') assert imviz_helper.default_viewer._obj.glue_viewer.state.zoom_center_x > 0 assert imviz_helper.default_viewer._obj.glue_viewer.state.zoom_center_y > 0 assert imviz_helper.default_viewer._obj.glue_viewer.state.zoom_radius > 0 @@ -148,7 +148,7 @@ def test_zoom_center_radius_init(imviz_helper): def test_catalog_in_image_viewer(imviz_helper, image_2d_wcs, source_catalog): data = NDData(np.ones((128, 128)) * u.nJy, wcs=image_2d_wcs) - imviz_helper.load_data(data, data_label='my_data') + imviz_helper.load(data, data_label='my_data') imviz_helper.plugins['Orientation'].align_by = 'WCS' # TODO: remove once dev-flag no longer required @@ -201,7 +201,7 @@ def test_catalog_in_image_viewer(imviz_helper, image_2d_wcs, source_catalog): assert 'my_catalog' not in po.layer.choices # test loading/removing another image dataset, which involves linking - imviz_helper.load_data(data, data_label='my_data_2') + imviz_helper.load(data, data_label='my_data_2') dm.layer.selected = ['my_data_2[DATA]'] dm.remove_from_app() diff --git a/jdaviz/configs/imviz/tests/test_wcs_utils.py b/jdaviz/configs/imviz/tests/test_wcs_utils.py index 96b87aa996..008719b6a0 100644 --- a/jdaviz/configs/imviz/tests/test_wcs_utils.py +++ b/jdaviz/configs/imviz/tests/test_wcs_utils.py @@ -132,7 +132,7 @@ def test_non_wcs_layer_labels(self): data_label="fits_wcs[DATA]", rotation_angle=5 * u.deg ) - self.imviz.load_data(ndd, data_label='ndd') + self.imviz.load(ndd, data_label='ndd') assert self.imviz.app.data_collection[3].label == 'ndd' # Confirm that all data in collection are labeled. @@ -149,7 +149,7 @@ def test_non_wcs_layer_labels(self): data_label="fits_wcs[DATA]", rotation_angle=45 * u.deg ) - self.imviz.load_data(ndd2, data_label="rot: 45.00 deg") + self.imviz.load(ndd2, data_label="rot: 45.00 deg") assert self.imviz.app.data_collection[4].label == "rot: 45.00 deg" # Confirm that all data in collection are labeled. @@ -167,7 +167,7 @@ def test_non_wcs_layer_labels(self): def test_get_rotated_nddata_from_label_no_wcs(imviz_helper): a = np.zeros((2, 2), dtype=np.int8) - imviz_helper.load_data(a, data_label="no_wcs") + imviz_helper.load(a, data_label="no_wcs") with pytest.raises(ValueError, match=r".*has no WCS for rotation"): wcs_utils._get_rotated_nddata_from_label(imviz_helper.app, "no_wcs", 0 * u.deg) diff --git a/jdaviz/configs/imviz/tests/utils.py b/jdaviz/configs/imviz/tests/utils.py index b270686aae..245df53f71 100644 --- a/jdaviz/configs/imviz/tests/utils.py +++ b/jdaviz/configs/imviz/tests/utils.py @@ -55,11 +55,11 @@ class BaseImviz_WCS_NoWCS: def setup_class(self, imviz_helper): # Data with WCS hdu_wcs = _image_hdu_wcs(arr=np.arange(100).reshape((10, 10))) - imviz_helper.load_data(hdu_wcs, data_label='has_wcs') + imviz_helper.load(hdu_wcs, data_label='has_wcs') # Data without WCS hdu_nowcs = _image_hdu_nowcs(arr=np.arange(100).reshape((10, 10))) - imviz_helper.load_data(hdu_nowcs, data_label='no_wcs') + imviz_helper.load(hdu_nowcs, data_label='no_wcs') imviz_helper.app.data_collection[1].coords = None self.wcs = WCS(hdu_wcs.header) diff --git a/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py b/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py index a4f95beda8..9fe536262f 100644 --- a/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py +++ b/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py @@ -16,7 +16,7 @@ def test_plugin(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -58,7 +58,7 @@ def test_spatial_subset(cubeviz_helper, image_cube_hdu_obj): Not checking the value attempts to circumvent the issue we ran into here: https://github.com/spacetelescope/jdaviz/pull/1564#discussion_r949427663 """ - cubeviz_helper.load_data(image_cube_hdu_obj, data_label="Test Cube") + cubeviz_helper.load(image_cube_hdu_obj, data_label="Test Cube") # add a spatial region cubeviz_helper.plugins['Subset Tools'].import_region( @@ -96,7 +96,7 @@ def test_cubeviz_units(cubeviz_helper, spectrum1d_cube_custom_fluxunit, """ cube = spectrum1d_cube_custom_fluxunit(fluxunit=u.Jy / sq_angle_unit, shape=(25, 25, 4), with_uncerts=True) - cubeviz_helper.load_data(cube, data_label="Test Cube") + cubeviz_helper.load(cube, data_label="Test Cube") uc = cubeviz_helper.plugins['Unit Conversion'] assert uc.spectral_y_type == 'Flux' # initial selection should be Flux @@ -167,7 +167,7 @@ def test_cubeviz_units(cubeviz_helper, spectrum1d_cube_custom_fluxunit, def test_user_api(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) specviz_helper.plugins['Subset Tools'].import_region(SpectralRegion(6500 * unit, @@ -198,7 +198,7 @@ def test_user_api(specviz_helper, spectrum1d): def test_line_identify(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) lt = QTable() lt['linename'] = ['O III', 'Halpha'] @@ -274,7 +274,7 @@ def test_coerce_unit(): def test_continuum_surrounding_spectral_subset(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -303,7 +303,7 @@ def test_continuum_surrounding_spectral_subset(specviz_helper, spectrum1d): def test_continuum_spectral_same_value(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -332,7 +332,7 @@ def test_continuum_spectral_same_value(specviz_helper, spectrum1d): def test_continuum_surrounding_invalid_width(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -359,7 +359,7 @@ def test_continuum_surrounding_invalid_width(specviz_helper, spectrum1d): def test_continuum_subset_spectral_entire(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -388,7 +388,7 @@ def test_continuum_subset_spectral_entire(specviz_helper, spectrum1d): def test_continuum_subset_spectral_subset2(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -423,7 +423,7 @@ def test_continuum_subset_spectral_subset2(specviz_helper, spectrum1d): def test_continuum_surrounding_no_right(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -453,7 +453,7 @@ def test_continuum_surrounding_no_right(specviz_helper, spectrum1d): def test_continuum_surrounding_no_left(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -483,7 +483,7 @@ def test_continuum_surrounding_no_left(specviz_helper, spectrum1d): def test_subset_changed(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') plugin.keep_active = True @@ -518,12 +518,12 @@ def test_subset_changed(specviz_helper, spectrum1d): def test_invalid_subset(specviz_helper, spectrum1d): # 6000-8000 - specviz_helper.load_data(spectrum1d, data_label="right_spectrum") + specviz_helper.load(spectrum1d, data_label="right_spectrum") # 5000-7000 sp2 = Spectrum(spectral_axis=spectrum1d.spectral_axis - 1000*spectrum1d.spectral_axis.unit, flux=spectrum1d.flux * 1.25) - specviz_helper.load_data(sp2, data_label="left_spectrum") + specviz_helper.load(sp2, data_label="left_spectrum") # apply subset that overlaps on left_spectrum, but not right_spectrum # NOTE: using a subset that overlaps the right_spectrum (reference) results in errors when diff --git a/jdaviz/configs/specviz/plugins/line_analysis/tests/test_lineflux.py b/jdaviz/configs/specviz/plugins/line_analysis/tests/test_lineflux.py index cb5f7728c7..c539877a41 100644 --- a/jdaviz/configs/specviz/plugins/line_analysis/tests/test_lineflux.py +++ b/jdaviz/configs/specviz/plugins/line_analysis/tests/test_lineflux.py @@ -84,7 +84,7 @@ def test_cubeviz_collapse_fluxunits( # Initialize Cubeviz with specific data and collapse function data_label = "Test Cube" - cubeviz_helper.load_data(data, data_label=data_label) + cubeviz_helper.load(data, data_label=data_label) cubeviz_helper.app.get_viewer('spectrum-viewer').state.function = function lineflux_result = _calculate_line_flux(cubeviz_helper) @@ -104,7 +104,7 @@ def test_unit_gaussian(specviz_helper, test_case): Test an Area 1 Gaussian and ensure the result returns in W/m2 Test provided by Patrick Ogle ''' - specviz_helper.load_data(test_case) + specviz_helper.load(test_case) lineflux_result = _calculate_line_flux(specviz_helper) assert_quantity_allclose(float(lineflux_result['result']) * u.Unit(lineflux_result['unit']), @@ -124,7 +124,7 @@ def test_unit_gaussian_mixed_units_per_steradian(specviz_helper): flx_wave = _gauss_with_unity_area(lam_a.value, mn, sig)*1E3*u.erg/u.s/u.cm**2/u.Angstrom fl_wave = Spectrum(spectral_axis=lam_a, flux=flx_wave) - specviz_helper.load_data(fl_wave) + specviz_helper.load(fl_wave) lineflux_result = _calculate_line_flux(specviz_helper) assert_quantity_allclose(float(lineflux_result['result']) * u.Unit(lineflux_result['unit']), 1*u.Unit('W/(m2)')) diff --git a/jdaviz/configs/specviz/plugins/unit_conversion/tests/test_unit_conversion.py b/jdaviz/configs/specviz/plugins/unit_conversion/tests/test_unit_conversion.py index ad707d6868..0089eb19ee 100644 --- a/jdaviz/configs/specviz/plugins/unit_conversion/tests/test_unit_conversion.py +++ b/jdaviz/configs/specviz/plugins/unit_conversion/tests/test_unit_conversion.py @@ -15,7 +15,7 @@ ("micron", "fail", "micron", "Jy")]) def test_value_error_exception(specviz_helper, spectrum1d, new_spectral_axis, new_flux, expected_spectral_axis, expected_flux): - specviz_helper.load_data(spectrum1d, data_label="Test 1D Spectrum") + specviz_helper.load(spectrum1d, data_label="Test 1D Spectrum") viewer = specviz_helper.app.get_viewer('spectrum-viewer') plg = specviz_helper.plugins["Unit Conversion"] @@ -37,7 +37,7 @@ def test_value_error_exception(specviz_helper, spectrum1d, new_spectral_axis, ne def test_initialize_specviz_sb(specviz_helper, spectrum1d): spec_sb = Spectrum(spectrum1d.flux/u.sr, spectrum1d.spectral_axis) - specviz_helper.load_data(spec_sb, data_label="Test 1D Spectrum") + specviz_helper.load(spec_sb, data_label="Test 1D Spectrum") plg = specviz_helper.plugins["Unit Conversion"] assert plg._obj.flux_unit == "Jy" assert plg._obj.spectral_y_type == "Surface Brightness" @@ -48,7 +48,7 @@ def test_initialize_specviz_sb(specviz_helper, spectrum1d): def test_conv_wave_only(specviz_helper, spectrum1d, uncert): if uncert is False: spectrum1d.uncertainty = None - specviz_helper.load_data(spectrum1d, data_label="Test 1D Spectrum") + specviz_helper.load(spectrum1d, data_label="Test 1D Spectrum") viewer = specviz_helper.app.get_viewer('spectrum-viewer') plg = specviz_helper.plugins["Unit Conversion"] @@ -64,7 +64,7 @@ def test_conv_wave_only(specviz_helper, spectrum1d, uncert): def test_conv_flux_only(specviz_helper, spectrum1d, uncert): if uncert is False: spectrum1d.uncertainty = None - specviz_helper.load_data(spectrum1d, data_label="Test 1D Spectrum") + specviz_helper.load(spectrum1d, data_label="Test 1D Spectrum") viewer = specviz_helper.app.get_viewer('spectrum-viewer') plg = specviz_helper.plugins["Unit Conversion"] @@ -80,7 +80,7 @@ def test_conv_flux_only(specviz_helper, spectrum1d, uncert): def test_conv_wave_flux(specviz_helper, spectrum1d, uncert): if uncert is False: spectrum1d.uncertainty = None - specviz_helper.load_data(spectrum1d, data_label="Test 1D Spectrum") + specviz_helper.load(spectrum1d, data_label="Test 1D Spectrum") viewer = specviz_helper.app.get_viewer('spectrum-viewer') plg = specviz_helper.plugins["Unit Conversion"] @@ -104,7 +104,7 @@ def test_conv_no_data(specviz_helper, spectrum1d): plg.spectral_unit = "micron" assert len(specviz_helper.app.data_collection) == 0 - specviz_helper.load_data(spectrum1d, data_label="Test 1D Spectrum") + specviz_helper.load(spectrum1d, data_label="Test 1D Spectrum") # make sure we don't expose translations in Specviz assert hasattr(plg, 'flux_unit') @@ -124,7 +124,7 @@ def test_non_stddev_uncertainty(specviz_helper): spectral_axis=wavelength ) - specviz_helper.load_data(spec) + specviz_helper.load(spec) po = specviz_helper.plugins['Plot Options'] po.uncertainty_visible = True @@ -148,7 +148,7 @@ def test_flux_unit_choices(specviz_helper, flux_unit, expected_choices): """ spec = Spectrum([1, 2, 3] * flux_unit, [4, 5, 6] * u.um) - specviz_helper.load_data(spec) + specviz_helper.load(spec) uc_plg = specviz_helper.plugins['Unit Conversion'] @@ -161,7 +161,7 @@ def test_mosviz_viewer_mouseover_flux(specviz2d_helper): data[3] = np.arange(10) spectrum2d = Spectrum(flux=data*u.MJy, spectral_axis=data[3]*u.um) - specviz2d_helper.load_data(spectrum2d) + specviz2d_helper.load(spectrum2d) viewer = specviz2d_helper.app.get_viewer('spectrum-viewer') plg = specviz2d_helper.plugins["Unit Conversion"] @@ -209,7 +209,7 @@ def test_mosviz_viewer_mouseover_sb(specviz2d_helper): data[3] = np.arange(10) spectrum2d = Spectrum(flux=data*u.MJy/u.sr, spectral_axis=data[3]*u.um) - specviz2d_helper.load_data(spectrum2d) + specviz2d_helper.load(spectrum2d) spectrum_viewer = specviz2d_helper.app.get_viewer("spectrum-viewer") spectrum2d_viewer = specviz2d_helper.app.get_viewer('spectrum-2d-viewer') plg = specviz2d_helper.plugins["Unit Conversion"] @@ -326,7 +326,7 @@ def test_data_unload_reload(specviz2d_helper): data[3] = np.arange(10) spectrum2d = Spectrum(flux=data*u.MJy, spectral_axis=data[3]*u.um) - specviz2d_helper.load_data(spectrum2d) + specviz2d_helper.load(spectrum2d) # remove data from viewer viewer = specviz2d_helper.app.get_viewer('spectrum-viewer') @@ -341,7 +341,7 @@ def test_data_unload_reload(specviz2d_helper): # re-load data with new units into the spectrum viewer spectrum2d_new = Spectrum(flux=data*u.Jy/u.sr, spectral_axis=data[3]*u.nm) - specviz2d_helper.load_data(spectrum2d_new) + specviz2d_helper.load(spectrum2d_new) # make sure newly loaded data did not change unit conversion selection, # and that the plugin traitlets and viewer attributes still match the diff --git a/jdaviz/configs/specviz/tests/test_helper.py b/jdaviz/configs/specviz/tests/test_helper.py index 8f33cb0eef..adf6255d62 100644 --- a/jdaviz/configs/specviz/tests/test_helper.py +++ b/jdaviz/configs/specviz/tests/test_helper.py @@ -22,7 +22,7 @@ def setup_class(self, specviz_helper, spectrum1d, multi_order_spectrum_list): self.multi_order_spectrum_list = multi_order_spectrum_list self.label = "Test 1D Spectrum" - self.spec_app.load_data(spectrum1d, data_label=self.label) + self.spec_app.load(spectrum1d, data_label=self.label) def test_load_spectrum1d(self): # starts with a single loaded spectrum1d object: @@ -50,7 +50,7 @@ def test_load_hdulist(self): spectrum_table.header['INSTRUME'] = 'Fake Instrument' fake_hdulist = fits.HDUList([primary_hdu, spectrum_table]) self.label = "Test 1D Spectrum" - self.spec_app.load_data(fake_hdulist) + self.spec_app.load(fake_hdulist) data = self.spec_app.get_data(data_label=self.label) # HDUList should load as Spectrum assert isinstance(data, Spectrum) @@ -63,7 +63,7 @@ def test_load_hdulist(self): def test_load_spectrum_list_with_kwargs(self, kwargs): # When loading via the ``data_label`` argument, the length of the # list must match the number of sources in the SpectrumList. - self.spec_app.load_data(self.spec_list, **kwargs) + self.spec_app.load(self.spec_list, **kwargs) assert len(self.spec_app.app.data_collection) == 4 if 'load' in list(kwargs.keys())[0]: for i in (1, 2, 3): @@ -72,19 +72,19 @@ def test_load_spectrum_list_with_kwargs(self, kwargs): def test_load_multi_order_spectrum_list(self): assert len(self.spec_app.app.data_collection) == 1 # now load ten spectral orders from a SpectrumList: - self.spec_app.load_data(self.multi_order_spectrum_list, sources='*') + self.spec_app.load(self.multi_order_spectrum_list, sources='*') assert len(self.spec_app.app.data_collection) == 11 def test_mismatched_label_length(self): # NOTE: will be removed after load_data deprecation is removed with pytest.raises(ValueError, match='Length'): labels = ["List test 1", "List test 2"] - self.spec_app.load_data(self.spec_list, data_label=labels) + self.spec_app.load(self.spec_list, data_label=labels) def test_load_spectrum_collection(self): with pytest.raises(ValueError): collection = SpectrumCollection([1]*u.AA) - self.spec_app.load_data(collection) + self.spec_app.load(collection) def test_get_spectra_no_viewer_reference(self): """ @@ -301,18 +301,18 @@ def test_get_spectra_no_spectra_label_redshift_error(specviz_helper, spectrum1d) def test_add_spectrum_after_subset(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test") subset = SpectralRegion(6200 * spectrum1d.spectral_axis.unit, 7000 * spectrum1d.spectral_axis.unit) specviz_helper.plugins['Subset Tools'].import_region(subset) new_spec = specviz_helper.get_spectra(apply_slider_redshift=True)["test"]*0.9 - specviz_helper.load_data(new_spec, data_label="test2") + specviz_helper.load(new_spec, data_label="test2") def test_get_spectral_regions_unit(specviz_helper, spectrum1d): # Ensure units we put in are the same as the units we get out - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) subset = SpectralRegion(6200 * spectrum1d.spectral_axis.unit, 7000 * spectrum1d.spectral_axis.unit) specviz_helper.plugins['Subset Tools'].import_region(subset) @@ -336,7 +336,7 @@ def test_get_spectral_regions_unit_conversion(specviz_helper, spectrum1d): # If the reference (visible) data changes via unit conversion, # check that the region's units convert too - specviz_helper.load_data(spectrum1d) # Originally Angstrom + specviz_helper.load(spectrum1d) # Originally Angstrom # Also check coordinates info panel. # x=0 -> 6000 A, x=1 -> 6222.222 A @@ -384,7 +384,7 @@ def test_get_spectral_regions_unit_conversion(specviz_helper, spectrum1d): def test_subset_default_thickness(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) sv = specviz_helper.app.get_viewer('spectrum-viewer') sv.toolbar.active_tool = sv.toolbar.tools['bqplot:xrange'] @@ -399,7 +399,7 @@ def test_subset_default_thickness(specviz_helper, spectrum1d): def test_app_links(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) sv = specviz_helper.app.get_viewer('spectrum-viewer') assert isinstance(sv.jdaviz_app, Application) assert isinstance(sv.jdaviz_helper, Specviz) @@ -418,7 +418,7 @@ def test_load_spectrum_list_directory(tmpdir, specviz_helper): # Load two NIRISS x1d files from FITS. They have 19 and 20 EXTRACT1D # extensions per file, for a total of 39 spectra to load: with pytest.warns(UserWarning, match='SRCTYPE is missing or UNKNOWN in JWST x1d loader'): - specviz_helper.load_data(data_path) + specviz_helper.load(data_path) # NOTE: the length was 3 before specutils 1.9 (https://github.com/astropy/specutils/pull/982) expected_len = 39 @@ -447,7 +447,7 @@ def test_load_spectrum_list_directory_concat(tmpdir, specviz_helper): # spectra common to each file into one "Combined" spectrum to load per file. # Now the total is (19 EXTRACT 1D + 1 Combined) + (20 EXTRACT 1D + 1 Combined) = 41. with pytest.warns(UserWarning, match='SRCTYPE is missing or UNKNOWN in JWST x1d loader'): - specviz_helper.load_data(data_path, concat_by_file=True) + specviz_helper.load(data_path, concat_by_file=True) assert len(specviz_helper.app.data_collection) == 41 @@ -457,7 +457,7 @@ def test_load_2d_flux(specviz_helper): spec = Spectrum(spectral_axis=np.linspace(4000, 6000, 10)*u.Angstrom, flux=np.ones((4, 10))*u.Unit("1e-17 erg / (Angstrom cm2 s)")) - specviz_helper.load_data(spec, data_label="test", sources='*') + specviz_helper.load(spec, data_label="test", sources='*') assert len(specviz_helper.app.data_collection) == 4 assert specviz_helper.app.data_collection[0].label == "test_index-0" @@ -467,14 +467,14 @@ def test_load_2d_flux(specviz_helper): # Make sure 2D spectra in a SpectrumList also get split properly. spec_list = SpectrumList([spec, spec2]) - specviz_helper.load_data(spec_list, data_label="second test", sources='*') + specviz_helper.load(spec_list, data_label="second test", sources='*') assert len(specviz_helper.app.data_collection) == 6 assert specviz_helper.app.data_collection[-1].label == "second test_index-1" def test_plot_uncertainties(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) specviz_viewer = specviz_helper.app.get_viewer('spectrum-viewer') @@ -510,7 +510,7 @@ def test_plugin_user_apis(specviz_helper): def test_data_label_as_posarg(specviz_helper, spectrum1d): # Passing in data_label keyword as posarg. - specviz_helper.load_data(spectrum1d, 'my_spec') + specviz_helper.load(spectrum1d, 'my_spec') assert specviz_helper.app.data_collection[0].label == 'my_spec' @@ -525,8 +525,8 @@ def test_spectra_partial_overlap(specviz_helper): flux_2 = ([60] * wave_2.size) * u.nJy sp_2 = Spectrum(flux=flux_2, spectral_axis=wave_2) - specviz_helper.load_data(sp_1, data_label='left') - specviz_helper.load_data(sp_2, data_label='right') + specviz_helper.load(sp_1, data_label='left') + specviz_helper.load(sp_2, data_label='right') # Test mouseover outside of left but in range for right. # Should show right spectrum even when mouse is near left flux. @@ -547,9 +547,9 @@ def test_spectra_incompatible_flux(specviz_helper): flux3 = ([1, 1.1, 1] * u.MJy).to(u.erg / u.s / u.cm / u.cm / u.AA, u.spectral_density(wav)) sp3 = Spectrum(flux=flux3, spectral_axis=wav) - specviz_helper.load_data(sp2, data_label="2") # OK - specviz_helper.load_data(sp1, data_label="1") # Not OK - specviz_helper.load_data(sp3, data_label="3") # OK + specviz_helper.load(sp2, data_label="2") # OK + specviz_helper.load(sp1, data_label="1") # Not OK + specviz_helper.load(sp3, data_label="3") # OK # all 3 load into data-collection, but only two in the viewer (with snackbar error) assert len(specviz_helper.app.data_collection.labels) == 3 @@ -557,8 +557,8 @@ def test_spectra_incompatible_flux(specviz_helper): def test_delete_data_with_subsets(specviz_helper, spectrum1d, spectrum1d_nm): - specviz_helper.load_data(spectrum1d, 'my_spec_AA') - specviz_helper.load_data(spectrum1d_nm, 'my_spec_nm') + specviz_helper.load(spectrum1d, 'my_spec_AA') + specviz_helper.load(spectrum1d_nm, 'my_spec_nm') spectral_axis_unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) @@ -587,16 +587,16 @@ def test_load_data_errors(self, specviz_helper, spectrum1d): Test that errors from load_data. """ with pytest.raises(NotImplementedError, match='format is ignored'): - specviz_helper.load_data(spectrum1d, format='some_format') + specviz_helper.load(spectrum1d, format='some_format') with pytest.raises(ValueError, match='Cannot set both'): - specviz_helper.load_data(spectrum1d, load_as_list=True, concat_by_file=True) + specviz_helper.load(spectrum1d, load_as_list=True, concat_by_file=True) def test_load_data_with_cache_timeout_local_path(self, specviz_helper, spectrum1d, tmpdir): """ Test load_data with cache, timeout, and local_path kwargs. """ - specviz_helper.load_data( + specviz_helper.load( spectrum1d, data_label='test_cache', cache=True, @@ -610,14 +610,14 @@ def test_load_data_with_sources_and_exposures(self, specviz_helper, premade_spec """ Test load_data with sources and exposures kwargs. """ - specviz_helper.load_data(premade_spectrum_list, sources='*') + specviz_helper.load(premade_spectrum_list, sources='*') assert len(specviz_helper.app.data_collection) == 5 def test_load_data_show_in_viewer_false(self, specviz_helper, spectrum1d): """ Test load_data with show_in_viewer=False. """ - specviz_helper.load_data( + specviz_helper.load( spectrum1d, data_label='hidden_spec', show_in_viewer=False @@ -630,7 +630,7 @@ def test_load_data_concat_by_file(self, specviz_helper, premade_spectrum_list): """ initial_count = len(specviz_helper.app.data_collection) with pytest.warns(UserWarning, match='default source selection'): - specviz_helper.load_data( + specviz_helper.load( premade_spectrum_list, data_label='concatenated', concat_by_file=True @@ -642,7 +642,7 @@ def test_load_data_with_load_as_list(self, specviz_helper, premade_spectrum_list Test load_data with load_as_list=True. """ with pytest.warns(UserWarning, match='default source selection'): - specviz_helper.load_data( + specviz_helper.load( premade_spectrum_list, data_label='as_list', load_as_list=True @@ -658,7 +658,7 @@ def test_x_limits(self, specviz_helper, spectrum1d): """ Test deprecated x_limits. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') sv = specviz_helper.app.get_viewer('spectrum-viewer') specviz_helper.x_limits() @@ -682,7 +682,7 @@ def test_y_limits(self, specviz_helper, spectrum1d): """ Test deprecated y_limits. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') sv = specviz_helper.app.get_viewer('spectrum-viewer') specviz_helper.y_limits() @@ -707,7 +707,7 @@ def test_autoscale_x_deprecated(self, specviz_helper, spectrum1d): """ Test deprecated autoscale_x method. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') specviz_helper.autoscale_x() sv = specviz_helper.app.get_viewer('spectrum-viewer') @@ -718,7 +718,7 @@ def test_autoscale_y_deprecated(self, specviz_helper, spectrum1d): """ Test deprecated autoscale_y method. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') specviz_helper.autoscale_y() sv = specviz_helper.app.get_viewer('spectrum-viewer') @@ -729,7 +729,7 @@ def test_flip_x(self, specviz_helper, spectrum1d): """ Test deprecated flip_x method. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') sv = specviz_helper.app.get_viewer('spectrum-viewer') original_min = sv.scale_x.min @@ -744,7 +744,7 @@ def test_flip_y(self, specviz_helper, spectrum1d): """ Test deprecated flip_y method. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') sv = specviz_helper.app.get_viewer('spectrum-viewer') original_min = sv.scale_y.min @@ -759,20 +759,20 @@ def test_set_spectrum_tick_format_x_axis(self, specviz_helper, spectrum1d): """ Test deprecated set_spectrum_tick_format for x-axis. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') specviz_helper.set_spectrum_tick_format('0.2f', axis=0) def test_set_spectrum_tick_format_y_axis(self, specviz_helper, spectrum1d): """ Test deprecated set_spectrum_tick_format for y-axis. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') specviz_helper.set_spectrum_tick_format('0.1e', axis=1) def test_set_spectrum_tick_format_invalid_axis(self, specviz_helper, spectrum1d): """ Test deprecated set_spectrum_tick_format with invalid axis. """ - specviz_helper.load_data(spectrum1d, data_label='test_spec') + specviz_helper.load(spectrum1d, data_label='test_spec') with pytest.warns(UserWarning, match='Please use either 0 or 1'): specviz_helper.set_spectrum_tick_format('0.2f', axis=2) diff --git a/jdaviz/configs/specviz/tests/test_tools.py b/jdaviz/configs/specviz/tests/test_tools.py index 424354eac2..2f9fecd58b 100644 --- a/jdaviz/configs/specviz/tests/test_tools.py +++ b/jdaviz/configs/specviz/tests/test_tools.py @@ -6,7 +6,7 @@ def test_homezoom_matchx(specviz_helper, spectrum1d): """ Test HomeZoomMatchX tool activates and resets zoom in viewer. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') # Change the zoom @@ -26,7 +26,7 @@ def test_boxzoom_matchx(specviz_helper, spectrum1d): """ Test BoxZoomMatchX tool with zoom interaction. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') # Activate box zoom tool @@ -45,7 +45,7 @@ def test_xrangezoom_matchx(specviz_helper, spectrum1d): """ Test XRangeZoomMatchX tool with horizontal zoom interaction. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') # Activate x-range zoom tool @@ -66,7 +66,7 @@ def test_panzoom_matchx(specviz_helper, spectrum1d): """ Test PanZoomMatchX tool activation and deactivation. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') # Activate pan zoom tool @@ -85,7 +85,7 @@ def test_panzoomx_matchx(specviz_helper, spectrum1d): """ Test PanZoomXMatchX tool for horizontal-only panning. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') # Activate pan zoom x tool @@ -104,7 +104,7 @@ def test_matched_zoom_between_viewers(specviz_helper, spectrum1d): """ Test that matched zoom tools synchronize x-limits between viewers. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') # Activate matched box zoom @@ -219,7 +219,7 @@ def test_is_matched_viewer(specviz_helper, spectrum1d): """ Test the _is_matched_viewer method identifies correct viewer types. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') tool = viewer.toolbar.tools['jdaviz:homezoom_matchx'] @@ -236,7 +236,7 @@ def test_matched_zoom_disable_in_other_viewer(specviz_helper, spectrum1d): """ Test that activating matched zoom disables it in other viewers. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') tool = viewer.toolbar.tools['jdaviz:boxzoom_matchx'] @@ -258,7 +258,7 @@ def test_match_axes_property(specviz_helper, spectrum1d): """ Test that matched zoom tools have correct match_axes property. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') tool = viewer.toolbar.tools['jdaviz:homezoom_matchx'] @@ -273,7 +273,7 @@ def test_tool_icons_exist(specviz_helper, spectrum1d): """ Test that all matched zoom tools have valid icon paths. """ - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') viewer = specviz_helper.app.get_viewer('spectrum-viewer') tool_ids = [ diff --git a/jdaviz/configs/specviz/tests/test_viewers.py b/jdaviz/configs/specviz/tests/test_viewers.py index aa3dd9007d..cc0e0c267e 100644 --- a/jdaviz/configs/specviz/tests/test_viewers.py +++ b/jdaviz/configs/specviz/tests/test_viewers.py @@ -22,7 +22,7 @@ def test_spectrum_viewer_axis_labels(specviz_helper, input_unit, y_axis_label): with warnings.catch_warnings(): warnings.filterwarnings("ignore", message=".*contains multiple slashes, which is discouraged by the FITS standard.*") # noqa - specviz_helper.load_data(spec) + specviz_helper.load(spec) label = specviz_helper._spectrum_viewer.figure.axes[1].label @@ -30,7 +30,7 @@ def test_spectrum_viewer_axis_labels(specviz_helper, input_unit, y_axis_label): def test_spectrum_viewer_keep_unit_when_removed(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d, data_label="Test") + specviz_helper.load(spectrum1d, data_label="Test") uc = specviz_helper.plugins["Unit Conversion"] assert uc.flux_unit == "Jy" uc.flux_unit = "MJy" @@ -47,7 +47,7 @@ def test_limits_on_unit_change(specviz_helper, spectrum1d): """ Test that the x-limits are reset when changing units """ - specviz_helper.load_data(spectrum1d, data_label="Test") + specviz_helper.load(spectrum1d, data_label="Test") uc = specviz_helper.plugins["Unit Conversion"] sv = specviz_helper.viewers['spectrum-viewer'] @@ -72,7 +72,7 @@ class TestResetLimitsTwoTests: def test_reset_limits_01(self, specviz_helper, spectrum1d): """This should run first.""" - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) sv = specviz_helper.app.get_viewer('spectrum-viewer') orig_xlims = (sv.state.x_min, sv.state.x_max) @@ -92,7 +92,7 @@ def test_reset_limits_01(self, specviz_helper, spectrum1d): def test_reset_limits_02(self, specviz_helper, spectrum1d_nm): """This should run second and see if first polutes it.""" - specviz_helper.load_data(spectrum1d_nm) + specviz_helper.load(spectrum1d_nm) sv = specviz_helper.app.get_viewer('spectrum-viewer') orig_xlims = (sv.state.x_min, sv.state.x_max) diff --git a/jdaviz/configs/specviz2d/plugins/cross_dispersion_profile/tests/test_cross_dispersion_profile.py b/jdaviz/configs/specviz2d/plugins/cross_dispersion_profile/tests/test_cross_dispersion_profile.py index fc1ff8e7a7..af56f802a6 100644 --- a/jdaviz/configs/specviz2d/plugins/cross_dispersion_profile/tests/test_cross_dispersion_profile.py +++ b/jdaviz/configs/specviz2d/plugins/cross_dispersion_profile/tests/test_cross_dispersion_profile.py @@ -19,7 +19,7 @@ def test_cross_dispersion_profile(specviz2d_helper): arr[:, i] = Gaussian1D(amplitude=i, mean=5, stddev=1)(y) data = Spectrum(flux=arr * u.Jy, spectral_axis=x * u.nm) - specviz2d_helper.load_data(data) + specviz2d_helper.load(data) cdp = specviz2d_helper.plugins['Cross Dispersion Profile'] cdp.open_in_tray() diff --git a/jdaviz/configs/specviz2d/plugins/spectral_extraction/tests/test_spectral_extraction.py b/jdaviz/configs/specviz2d/plugins/spectral_extraction/tests/test_spectral_extraction.py index f664decd53..3736543aa9 100644 --- a/jdaviz/configs/specviz2d/plugins/spectral_extraction/tests/test_spectral_extraction.py +++ b/jdaviz/configs/specviz2d/plugins/spectral_extraction/tests/test_spectral_extraction.py @@ -29,7 +29,7 @@ def test_plugin(specviz2d_helper): fn = download_file('https://stsci.box.com/shared/static/exnkul627fcuhy5akf2gswytud5tazmw.fits', cache=True, timeout=100) - specviz2d_helper.load_data(spectrum_2d=fn) + specviz2d_helper.load(fn) pext = specviz2d_helper.app.get_tray_item_from_name('spectral-extraction-2d') @@ -187,7 +187,7 @@ def test_plugin(specviz2d_helper): def test_user_api(specviz2d_helper): fn = download_file('https://stsci.box.com/shared/static/exnkul627fcuhy5akf2gswytud5tazmw.fits', cache=True) # noqa - specviz2d_helper.load_data(spectrum_2d=fn) + specviz2d_helper.load(fn) pext = specviz2d_helper.plugins['2D Spectral Extraction'] pext.keep_active = True @@ -211,7 +211,7 @@ def test_user_api(specviz2d_helper): @pytest.mark.filterwarnings("ignore::astropy.wcs.wcs.FITSFixedWarning") def test_background_extraction_and_display(specviz2d_helper): uri = 'mast:jwst/product/jw01538-o161_t002-s000000001_nirspec_f290lp-g395h-s1600a1_s2d.fits' - specviz2d_helper.load_data(spectrum_2d=cached_uri(uri), cache=True) + specviz2d_helper.load(cached_uri(uri), cache=True) pext = specviz2d_helper.app.get_tray_item_from_name('spectral-extraction-2d') # check that the background extraction method and parameters are as expected diff --git a/jdaviz/configs/specviz2d/tests/test_helper.py b/jdaviz/configs/specviz2d/tests/test_helper.py index 9d0a4d493c..4e6a33a766 100644 --- a/jdaviz/configs/specviz2d/tests/test_helper.py +++ b/jdaviz/configs/specviz2d/tests/test_helper.py @@ -5,7 +5,7 @@ def test_helper(specviz2d_helper, mos_spectrum2d): - specviz2d_helper.load_data(spectrum_2d=mos_spectrum2d) + specviz2d_helper.load(mos_spectrum2d) assert isinstance(specviz2d_helper.specviz, Specviz) specviz2d_helper.app.data_collection[0].meta['Trace'] = "Test" diff --git a/jdaviz/configs/specviz2d/tests/test_parsers.py b/jdaviz/configs/specviz2d/tests/test_parsers.py index 87ef9e843b..0823a9993d 100644 --- a/jdaviz/configs/specviz2d/tests/test_parsers.py +++ b/jdaviz/configs/specviz2d/tests/test_parsers.py @@ -14,7 +14,7 @@ def test_2d_parser_jwst(specviz2d_helper): fn = download_file('https://stsci.box.com/shared/static/exnkul627fcuhy5akf2gswytud5tazmw.fits', cache=True) # noqa - specviz2d_helper.load_data(spectrum_2d=fn) + specviz2d_helper.load(fn) assert len(specviz2d_helper.app.data_collection) == 2 dc_0 = specviz2d_helper.app.data_collection[0] @@ -83,7 +83,7 @@ def test_hlsp_goods_s2d_deconfigged(deconfigged_helper): def test_2d_parser_no_unit(specviz2d_helper, mos_spectrum2d): - specviz2d_helper.load_data(mos_spectrum2d, spectrum_2d_label='my_2d_spec') + specviz2d_helper.load(mos_spectrum2d, spectrum_2d_label='my_2d_spec') assert len(specviz2d_helper.app.data_collection) == 2 dc_0 = specviz2d_helper.app.data_collection[0] @@ -133,7 +133,7 @@ def test_2d_parser_hdulist_ext(tmp_path, specviz2d_helper, mos_spectrum2d_as_hdu } stdatamodels.asdf_in_fits.write(in_filename, tree, mos_spectrum2d_as_hdulist, overwrite=True) - specviz2d_helper.load_data(in_filename, ext=1) + specviz2d_helper.load(in_filename, ext=1) assert len(specviz2d_helper.app.data_collection) == 2 dc_0 = specviz2d_helper.app.data_collection[0] @@ -148,7 +148,7 @@ def test_2d_parser_hdulist_ext(tmp_path, specviz2d_helper, mos_spectrum2d_as_hdu def test_1d_parser(specviz2d_helper, spectrum1d): - specviz2d_helper.load_data(spectrum_1d=spectrum1d) + specviz2d_helper.load(spectrum1d) assert len(specviz2d_helper.app.data_collection) == 1 dc_0 = specviz2d_helper.app.data_collection[0] assert dc_0.label == 'Spectrum 1D' @@ -156,7 +156,8 @@ def test_1d_parser(specviz2d_helper, spectrum1d): def test_2d_1d_parser(specviz2d_helper, mos_spectrum2d, spectrum1d): - specviz2d_helper.load_data(spectrum_2d=mos_spectrum2d, spectrum_1d=spectrum1d) + specviz2d_helper.load(mos_spectrum2d) + specviz2d_helper.load(spectrum1d) assert specviz2d_helper.app.data_collection.labels == ['Spectrum 2D', 'Spectrum 1D'] spec2d_viewer = specviz2d_helper.app.get_viewer('spectrum-2d-viewer') @@ -181,4 +182,4 @@ def test_2d_1d_parser(specviz2d_helper, mos_spectrum2d, spectrum1d): def test_parser_no_data(specviz2d_helper): with pytest.raises(ValueError, match='Must provide spectrum_2d or spectrum_1d'): - specviz2d_helper.load_data() + specviz2d_helper.load() diff --git a/jdaviz/conftest.py b/jdaviz/conftest.py index 822c94e754..3823d514d9 100644 --- a/jdaviz/conftest.py +++ b/jdaviz/conftest.py @@ -116,12 +116,12 @@ def default_data_label_from_resolver(self): @pytest.fixture def cubeviz_helper(): - return Cubeviz() + return App() @pytest.fixture def imviz_helper(): - return Imviz() + return App() @pytest.fixture @@ -131,12 +131,12 @@ def mosviz_helper(): @pytest.fixture def specviz_helper(): - return Specviz() + return App() @pytest.fixture def specviz2d_helper(): - return Specviz2d() + return App() @pytest.fixture diff --git a/jdaviz/core/loaders/resolvers/virtual_observatory/tests/test_vo_imviz.py b/jdaviz/core/loaders/resolvers/virtual_observatory/tests/test_vo_imviz.py index f6bf21784a..5d4a6a9556 100644 --- a/jdaviz/core/loaders/resolvers/virtual_observatory/tests/test_vo_imviz.py +++ b/jdaviz/core/loaders/resolvers/virtual_observatory/tests/test_vo_imviz.py @@ -92,7 +92,7 @@ def test_link_type_autocoord(imviz_helper): "NAXIS2": 10, } ) - imviz_helper.load_data(hdu1, data_label="has_wcs_1") + imviz_helper.load(hdu1, data_label="has_wcs_1") # Second data with WCS, similar to above but dithered by 1 pixel in X. hdu2 = fits.ImageHDU(np.ones((10, 10)), name="SCI") @@ -112,7 +112,7 @@ def test_link_type_autocoord(imviz_helper): "NAXIS2": 10, } ) - imviz_helper.load_data(hdu2, data_label="has_wcs_2") + imviz_helper.load(hdu2, data_label="has_wcs_2") vo_ldr = imviz_helper.loaders["virtual observatory"]._obj vo_ldr.viewer.selected = "imviz-0" diff --git a/jdaviz/core/loaders/tests/test_loaders.py b/jdaviz/core/loaders/tests/test_loaders.py index 57437f7c84..a3df828b9a 100644 --- a/jdaviz/core/loaders/tests/test_loaders.py +++ b/jdaviz/core/loaders/tests/test_loaders.py @@ -116,7 +116,7 @@ def test_markers_specviz2d_unit_conversion(specviz2d_helper, spectrum2d): data = np.zeros((5, 10)) data[3] = np.arange(10) spectrum2d = Spectrum(flux=data*u.MJy, spectral_axis=data[3]*u.AA) - specviz2d_helper.load_data(spectrum2d) + specviz2d_helper.load(spectrum2d, format='2D Spectrum') @pytest.mark.remote_data @@ -320,7 +320,7 @@ def test_invoke_from_plugin(specviz_helper, spectrum1d, tmp_path): local_path = str(tmp_path / 'spectral_region.ecsv') s.write(local_path) - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) loader = specviz_helper.plugins['Subset Tools'].loaders['file'] @@ -371,7 +371,7 @@ def test_load_image_mult_sci_extension(imviz_helper): ]) # imviz_helper._load(hdul, extension=('SCI,1', 'SCI,2', 'ERR,2')) - imviz_helper.load_data(hdul, ext=('SCI,1', 'SCI,2', 'ERR,2')) + imviz_helper.load(hdul, ext=('SCI,1', 'SCI,2', 'ERR,2')) assert len(imviz_helper.app.data_collection) == 3 assert [d.label for d in imviz_helper.app.data_collection] == ['Image[SCI,1]', 'Image[SCI,2]', 'Image[ERR,2]'] # noqa diff --git a/jdaviz/core/tests/test_helpers.py b/jdaviz/core/tests/test_helpers.py index 37aa7dd35d..d93894f74b 100644 --- a/jdaviz/core/tests/test_helpers.py +++ b/jdaviz/core/tests/test_helpers.py @@ -193,7 +193,7 @@ def setup_class(self, cubeviz_helper, deconfigged_helper, image_cube_hdu_obj): # self.config_helper = deconfigged_helper self.config_helper = cubeviz_helper # self.config_helper.load(image_cube_hdu_obj, format='Spectral Cube') - self.config_helper.load_data(image_cube_hdu_obj) + self.config_helper.load(image_cube_hdu_obj) self.data = self.config_helper.app.data_collection[0] self.label = self.data.label @@ -311,7 +311,7 @@ def test_get_data_cls_spectrum_for_specviz2d(specviz2d_helper, spectrum2d): """ Test _get_data: cls inferred as Spectrum for specviz2d config. """ - specviz2d_helper.load_data(spectrum2d) + specviz2d_helper.load(spectrum2d) # Get the actual label from data collection label = specviz2d_helper.app.data_collection[0].label @@ -359,7 +359,7 @@ def test_delete_region_with_invalid_subset(cubeviz_helper, image_cube_hdu_obj): """ Test _delete_region with an invalid subset label (early return). """ - cubeviz_helper.load_data(image_cube_hdu_obj) + cubeviz_helper.load(image_cube_hdu_obj) # Try to delete a non-existent subset (should not raise error, just return) cubeviz_helper._delete_region('NonExistentSubset') diff --git a/jdaviz/core/tests/test_template_mixin.py b/jdaviz/core/tests/test_template_mixin.py index 576d7522af..d74b454b3e 100644 --- a/jdaviz/core/tests/test_template_mixin.py +++ b/jdaviz/core/tests/test_template_mixin.py @@ -15,7 +15,7 @@ def test_spectralsubsetselect(specviz_helper, spectrum1d): mask = spectrum1d.flux < spectrum1d.flux.mean() spectrum1d.mask = mask - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) sv = specviz_helper.app.get_viewer('spectrum-viewer') # create a "Subset 1" entry subset_plugin = specviz_helper.plugins['Subset Tools'] @@ -63,7 +63,7 @@ def test_spectralsubsetselect(specviz_helper, spectrum1d): @pytest.mark.filterwarnings('ignore:No observer defined on WCS') def test_viewer_select(cubeviz_helper, spectrum1d_cube): app = cubeviz_helper.app - cubeviz_helper.load_data(spectrum1d_cube, data_label='test') + cubeviz_helper.load(spectrum1d_cube, data_label='test') fv = app.get_viewer("flux-viewer") sv = app.get_viewer('spectrum-viewer') diff --git a/jdaviz/core/tests/test_tools.py b/jdaviz/core/tests/test_tools.py index 032ca4da78..20a9768611 100644 --- a/jdaviz/core/tests/test_tools.py +++ b/jdaviz/core/tests/test_tools.py @@ -9,7 +9,7 @@ def test_boxzoom(cubeviz_helper, image_cube_hdu_obj_microns): - cubeviz_helper.load_data(image_cube_hdu_obj_microns, data_label="Test Flux") + cubeviz_helper.load(image_cube_hdu_obj_microns, data_label="Test Flux") flux_viewer = cubeviz_helper.app.get_viewer('flux-viewer') @@ -32,7 +32,7 @@ def _get_lims(viewer): def test_rangezoom(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d, data_label='test') + specviz_helper.load(spectrum1d, data_label='test') sv = specviz_helper.app.get_viewer('spectrum-viewer') assert_allclose(_get_lims(sv), [6000, 8000, 12.30618014327326, 16.542560043585965]) @@ -51,7 +51,7 @@ def test_rangezoom(specviz_helper, spectrum1d): def test_stretch_bounds(imviz_helper): - imviz_helper.load_data(np.ones((2, 2))) + imviz_helper.load(np.ones((2, 2))) plot_options = imviz_helper.plugins['Plot Options']._obj stretch_tool = plot_options.stretch_histogram.toolbar.tools["jdaviz:stretch_bounds"] @@ -82,7 +82,7 @@ def test_stretch_bounds_and_spline(imviz_helper): np.random.seed(42) image_1 = NDData(make_4gaussians_image(), unit=u.nJy) - imviz_helper.load_data(image_1) + imviz_helper.load(image_1) po = imviz_helper.plugins["Plot Options"] with po.as_active(): @@ -111,7 +111,7 @@ def test_stretch_bounds_and_spline(imviz_helper): def test_stretch_bounds_click_outside_threshold(imviz_helper): image_1 = NDData(make_4gaussians_image(), unit=u.nJy) - imviz_helper.load_data(image_1) + imviz_helper.load(image_1) po = imviz_helper.plugins["Plot Options"] po = imviz_helper.plugins["Plot Options"] @@ -137,7 +137,7 @@ def test_stretch_bounds_click_outside_threshold(imviz_helper): def test_unit_conversion_limits_update(specviz2d_helper, mos_spectrum2d): - specviz2d_helper.load_data(mos_spectrum2d) + specviz2d_helper.load(mos_spectrum2d) uc = specviz2d_helper.plugins['Unit Conversion'] spec_viewer = specviz2d_helper.app.get_viewer( @@ -168,7 +168,7 @@ def test_unit_conversion_limits_update(specviz2d_helper, mos_spectrum2d): def test_match_limits_without_wave_component(specviz2d_helper): data = np.zeros((5, 10)) spec2d = Spectrum(flux=data*u.MJy, spectral_axis_index=1) - specviz2d_helper.load_data(spec2d) + specviz2d_helper.load(spec2d) spec_viewer = specviz2d_helper.app.get_viewer( specviz2d_helper.app._jdaviz_helper._default_spectrum_viewer_reference_name) diff --git a/jdaviz/tests/test_app.py b/jdaviz/tests/test_app.py index 985f1dea2f..266740bf0c 100644 --- a/jdaviz/tests/test_app.py +++ b/jdaviz/tests/test_app.py @@ -17,7 +17,7 @@ # This applies to all viz but testing with Imviz should be enough. def test_viewer_calling_app(imviz_helper): - viewer = imviz_helper.default_viewer._obj.glue_viewer + viewer = imviz_helper.viewers['Image']._obj.glue_viewer assert viewer.session.jdaviz_app is imviz_helper.app @@ -71,20 +71,20 @@ class Customviz(Specviz): def test_duplicate_data_labels(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d, data_label="test") - specviz_helper.load_data(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test") dc = specviz_helper.app.data_collection assert dc[0].label == "test" assert dc[1].label == "test (1)" - specviz_helper.load_data(spectrum1d, data_label="test_1") - specviz_helper.load_data(spectrum1d, data_label="test") + specviz_helper.load(spectrum1d, data_label="test_1") + specviz_helper.load(spectrum1d, data_label="test") assert dc[2].label == "test_1" assert dc[3].label == "test (2)" def test_duplicate_data_labels_with_brackets(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d, data_label="test[test]") - specviz_helper.load_data(spectrum1d, data_label="test[test]") + specviz_helper.load(spectrum1d, data_label="test[test]") + specviz_helper.load(spectrum1d, data_label="test[test]") dc = specviz_helper.app.data_collection assert len(dc) == 2 assert dc[0].label == "test[test]" @@ -118,7 +118,7 @@ def test_unique_name_variations(specviz_helper, spectrum1d): data_label = specviz_helper.app.return_unique_name(None) assert data_label == "Unknown" - specviz_helper.load_data(spectrum1d, data_label="test[flux]") + specviz_helper.load(spectrum1d, data_label="test[flux]") data_label = specviz_helper.app.return_data_label("test[flux]", ext="flux") assert data_label == "test[flux][flux]" @@ -127,8 +127,8 @@ def test_unique_name_variations(specviz_helper, spectrum1d): def test_substring_in_label(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d, data_label="M31") - specviz_helper.load_data(spectrum1d, data_label="M32") + specviz_helper.load(spectrum1d, data_label="M31") + specviz_helper.load(spectrum1d, data_label="M32") data_label = specviz_helper.app.return_data_label("M") assert data_label == "M" @@ -139,17 +139,17 @@ def test_substring_in_label(specviz_helper, spectrum1d): def test_edge_cases(specviz_helper, spectrum1d, data_label): dc = specviz_helper.app.data_collection - specviz_helper.load_data(spectrum1d, data_label=data_label) - specviz_helper.load_data(spectrum1d, data_label=data_label) + specviz_helper.load(spectrum1d, data_label=data_label) + specviz_helper.load(spectrum1d, data_label=data_label) assert dc[1].label == f"{data_label} (1)" - specviz_helper.load_data(spectrum1d, data_label=data_label) + specviz_helper.load(spectrum1d, data_label=data_label) assert dc[2].label == f"{data_label} (2)" def test_case_that_used_to_break_return_label(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d, data_label="this used to break (1)") - specviz_helper.load_data(spectrum1d, data_label="this used to break") + specviz_helper.load(spectrum1d, data_label="this used to break (1)") + specviz_helper.load(spectrum1d, data_label="this used to break") dc = specviz_helper.app.data_collection assert dc[0].label == "this used to break (1)" assert dc[1].label == "this used to break (2)" @@ -190,19 +190,19 @@ def test_data_associations(imviz_helper): data_parent = np.ones(shape, dtype=float) data_child = np.zeros(shape, dtype=int) - imviz_helper.load_data(data_parent, data_label='parent_data') - imviz_helper.load_data(data_child, data_label='child_data', parent='parent_data') + imviz_helper.load(data_parent, format='Image', data_label='parent_data') + imviz_helper.load(data_child, format='Image', data_label='child_data', parent='parent_data') assert imviz_helper.app._get_assoc_data_children('parent_data') == ['child_data'] assert imviz_helper.app._get_assoc_data_parent('child_data') == 'parent_data' with pytest.raises(ValueError): # we don't (yet) allow children of children: - imviz_helper.load_data(data_child, data_label='grandchild_data', parent='child_data') + imviz_helper.load(data_child, format='Image', data_label='grandchild_data', parent='child_data') with pytest.raises(ValueError): # ensure the parent actually exists: - imviz_helper.load_data(data_child, data_label='child_data', parent='absent parent') + imviz_helper.load(data_child, format='Image', data_label='child_data', parent='absent parent') def test_to_unit(cubeviz_helper): @@ -215,7 +215,7 @@ def test_to_unit(cubeviz_helper): flux = np.zeros((30, 20, 3001), dtype=np.float32) flux[5:15, 1:11, :] = 1 cube = Spectrum(flux=flux * (u.MJy / u.sr), wcs=w, meta=wcs_dict) - cubeviz_helper.load_data(cube, data_label="test") + cubeviz_helper.load(cube, data_label="test") # this can be removed once spectra pass through cube spectral extraction extract_plg = cubeviz_helper.plugins['3D Spectral Extraction'] diff --git a/jdaviz/tests/test_subsets.py b/jdaviz/tests/test_subsets.py index e5942220c3..dcad53acf9 100644 --- a/jdaviz/tests/test_subsets.py +++ b/jdaviz/tests/test_subsets.py @@ -19,7 +19,7 @@ def test_region_from_subset_2d(cubeviz_helper): - cubeviz_helper.load_data(np.ones((128, 128, 1)), data_label='Test 2D Flux') + cubeviz_helper.load(np.ones((128, 128, 1)), data_label='Test 2D Flux') subset_plugin = cubeviz_helper.plugins['Subset Tools'] @@ -59,7 +59,7 @@ def test_region_from_subset_2d(cubeviz_helper): def test_region_from_subset_3d(cubeviz_helper): - cubeviz_helper.load_data(np.ones((128, 128, 256)), data_label='Test 3D Flux') + cubeviz_helper.load(np.ones((128, 128, 256)), data_label='Test 3D Flux') subset_plugin = cubeviz_helper.plugins['Subset Tools'] assert subset_plugin._obj.subset_selected == "Create New" @@ -161,7 +161,7 @@ def test_region_from_subset_profile(cubeviz_helper, spectral_cube_wcs): data = Spectrum(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj - cubeviz_helper.load_data(data, data_label='Test 1D Flux') + cubeviz_helper.load(data, data_label='Test 1D Flux') spectral_axis_unit = u.Unit(cubeviz_helper.plugins['Unit Conversion'].spectral_unit.selected) subset_plugin.import_region(SpectralRegion(5*spectral_axis_unit, 15.5*spectral_axis_unit)) @@ -209,7 +209,7 @@ def test_region_from_subset_profile(cubeviz_helper, spectral_cube_wcs): def test_disjoint_spectral_subset(cubeviz_helper, spectral_cube_wcs): subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj data = Spectrum(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) - cubeviz_helper.load_data(data, data_label="Test Flux") + cubeviz_helper.load(data, data_label="Test Flux") spectral_axis_unit = u.Unit(cubeviz_helper.plugins['Unit Conversion'].spectral_unit.selected) subset_plugin.import_region(SpectralRegion(5 * spectral_axis_unit, 15.5 * spectral_axis_unit)) @@ -253,7 +253,7 @@ def test_disjoint_spectral_subset(cubeviz_helper, spectral_cube_wcs): def test_composite_region_from_subset_3d(cubeviz_helper): - cubeviz_helper.load_data(np.ones((128, 128, 10)), data_label='Test 3D Flux') + cubeviz_helper.load(np.ones((128, 128, 10)), data_label='Test 3D Flux') subset_plugin = cubeviz_helper.plugins['Subset Tools'] subset_plugin.import_region(CircularROI(xc=25, yc=25, radius=5)) @@ -309,7 +309,7 @@ def test_composite_region_from_subset_3d(cubeviz_helper): def test_composite_region_with_consecutive_and_not_states(cubeviz_helper): - cubeviz_helper.load_data(np.ones((128, 128, 10)), data_label='Test 3D Flux') + cubeviz_helper.load(np.ones((128, 128, 10)), data_label='Test 3D Flux') subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj viewer = cubeviz_helper.app.get_viewer('flux-viewer') @@ -380,7 +380,7 @@ def test_composite_region_with_imviz(imviz_helper, image_2d_wcs): arr = NDData(np.ones((10, 10)), wcs=image_2d_wcs) subset_plugin = imviz_helper.plugins['Subset Tools']._obj data_label = 'image-data' - imviz_helper.load_data(arr, data_label=data_label, show_in_viewer=True) + imviz_helper.load(arr, data_label=data_label) subset_plugin.import_region(CircularROI(xc=5, yc=5, radius=2)) reg = imviz_helper.app.get_subsets("Subset 1", include_sky_region=True) circle1 = CirclePixelRegion(center=PixCoord(x=5, y=5), radius=2) @@ -443,14 +443,14 @@ def test_recenter_linked_by_wcs(imviz_helper): Images are only aligned if linked by WCS. """ # Reference image - imviz_helper.load_data(get_pkg_data_filename( + imviz_helper.load(get_pkg_data_filename( 'data/gauss100_fits_wcs.fits', package='jdaviz.configs.imviz.tests')) # Different pixel scale - imviz_helper.load_data(get_pkg_data_filename( + imviz_helper.load(get_pkg_data_filename( 'data/gauss100_fits_wcs_block_reduced.fits', package='jdaviz.configs.imviz.tests')) # Link them by WCS - imviz_helper.link_data(align_by='wcs') + imviz_helper.plugins['Orientation'].align_by = 'WCS' w = imviz_helper.app.data_collection[0].coords # This rectangle is over a real object in reference image but @@ -500,7 +500,7 @@ def test_with_invalid_subset_name(cubeviz_helper): def test_composite_region_from_subset_2d(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) viewer = specviz_helper.app.get_viewer(specviz_helper._default_spectrum_viewer_reference_name) subset_plugin = specviz_helper.plugins['Subset Tools']._obj @@ -555,7 +555,7 @@ def test_composite_region_from_subset_2d(specviz_helper, spectrum1d): def test_edit_composite_spectral_subset(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) subset_plugin = specviz_helper.plugins['Subset Tools']._obj unit = spectrum1d.spectral_axis.unit @@ -604,7 +604,7 @@ def test_edit_composite_spectral_subset(specviz_helper, spectrum1d): def test_composite_spectral_with_xor(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) subset_plugin = specviz_helper.plugins['Subset Tools'] @@ -659,7 +659,7 @@ def test_composite_spectral_with_xor(specviz_helper, spectrum1d): def test_composite_spectral_with_xor_complicated(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) subset_plugin = specviz_helper.plugins['Subset Tools'] @@ -690,7 +690,7 @@ def test_composite_spectral_with_xor_complicated(specviz_helper, spectrum1d): def test_overlapping_spectral_regions(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) subset_plugin = specviz_helper.plugins['Subset Tools']._obj unit = spectrum1d.spectral_axis.unit subset = [SpectralRegion(6400 * unit, 7400 * unit), @@ -708,7 +708,7 @@ def test_overlapping_spectral_regions(specviz_helper, spectrum1d): def test_only_overlapping_spectral_regions(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) subset_plugin = specviz_helper.plugins['Subset Tools']._obj unit = spectrum1d.spectral_axis.unit subset_plugin.import_region(SpectralRegion(6400 * unit, 6600 * unit)) @@ -729,7 +729,7 @@ def test_only_overlapping_spectral_regions(specviz_helper, spectrum1d): def test_overlapping_in_specviz2d(specviz2d_helper, mos_spectrum2d): - specviz2d_helper.load_data(spectrum_2d=mos_spectrum2d) + specviz2d_helper.load(spectrum_2d=mos_spectrum2d) subset_plugin = specviz2d_helper.plugins['Subset Tools']._obj unit = mos_spectrum2d.spectral_axis.unit @@ -749,7 +749,7 @@ def test_overlapping_in_specviz2d(specviz2d_helper, mos_spectrum2d): def test_only_overlapping_in_specviz2d(specviz2d_helper, mos_spectrum2d): - specviz2d_helper.load_data(spectrum_2d=mos_spectrum2d) + specviz2d_helper.load(spectrum_2d=mos_spectrum2d) subset_plugin = specviz2d_helper.plugins['Subset Tools']._obj unit = mos_spectrum2d.spectral_axis.unit @@ -776,7 +776,7 @@ def test_draw2d_linking_specviz2d(specviz2d_helper): with warnings.catch_warnings(): warnings.filterwarnings("ignore") fn = download_file('https://stsci.box.com/shared/static/exnkul627fcuhy5akf2gswytud5tazmw.fits', cache=True) # noqa - specviz2d_helper.load_data(fn, cache=True) + specviz2d_helper.load(fn, cache=True) viewer_1d = specviz2d_helper.app.get_viewer( specviz2d_helper._default_spectrum_viewer_reference_name) @@ -810,7 +810,7 @@ def test_draw2d_linking_specviz2d(specviz2d_helper): def test_multi_mask_subset(specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d) + specviz_helper.load(spectrum1d) subset_plugin = specviz_helper.plugins['Subset Tools']._obj unit = spectrum1d.spectral_axis.unit subset_plugin.import_region(SpectralRegion(6200 * unit, 6800 * unit)) @@ -862,7 +862,7 @@ def test_delete_subsets_toolbar_selection(cubeviz_helper, spectral_cube_wcs): Test that the toolbar selections get reset when the subset being actively edited gets deleted. """ data = Spectrum(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) - cubeviz_helper.load_data(data, data_label="Test Flux") + cubeviz_helper.load(data, data_label="Test Flux") dc = cubeviz_helper.app.data_collection spectrum_viewer = cubeviz_helper.app.get_viewer("spectrum-viewer") @@ -888,7 +888,7 @@ def test_delete_subsets_app_api(cubeviz_helper, spectral_cube_wcs): """Test app.delete_subsets.""" data = Spectrum(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) - cubeviz_helper.load_data(data, data_label="Test Flux") + cubeviz_helper.load(data, data_label="Test Flux") dc = cubeviz_helper.app.data_collection subset_plugin = cubeviz_helper.plugins['Subset Tools'] unit = u.Unit(cubeviz_helper.plugins['Unit Conversion'].spectral_unit.selected) @@ -937,7 +937,7 @@ def test_get_regions_from_subsets_cubeviz(self, cubeviz_helper, spectral_cube_wc """ Basic tests for retrieving Sky Regions from spatial subsets in Cubeviz. """ data = Spectrum(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) - cubeviz_helper.load_data(data) + cubeviz_helper.load(data) # basic test, a single circular region subset_plugin = cubeviz_helper.plugins['Subset Tools'] @@ -982,7 +982,7 @@ def test_get_regions_from_subsets_imviz(self, imviz_helper, spectral_cube_wcs): wcs = spectral_cube_wcs.celestial data = NDData(np.ones((128, 128)) * u.nJy, wcs=wcs) - imviz_helper.load_data(data) + imviz_helper.load(data) # basic test, a single circular region subset_plugin = imviz_helper.plugins['Subset Tools'] @@ -1015,7 +1015,7 @@ def test_no_wcs_sky_regions(self, imviz_helper): """ data = NDData(np.ones((40, 40)) * u.nJy) - imviz_helper.load_data(data) + imviz_helper.load(data) subset_plugin = imviz_helper.plugins['Subset Tools'] subset_plugin.import_region(CircularROI(25, 25, 10)) @@ -1023,7 +1023,7 @@ def test_no_wcs_sky_regions(self, imviz_helper): assert subsets['Subset 1'][0]['sky_region'] is None def test_subset_renaming(self, specviz_helper, spectrum1d): - specviz_helper.load_data(spectrum1d, 'myfile') + specviz_helper.load(spectrum1d, 'myfile') subset_plugin = specviz_helper.plugins['Subset Tools'] subset_plugin.import_region(SpectralRegion(6200 * spectrum1d.spectral_axis.unit, diff --git a/jdaviz/tests/test_user_api.py b/jdaviz/tests/test_user_api.py index c2bf31832f..4079c6cb9b 100644 --- a/jdaviz/tests/test_user_api.py +++ b/jdaviz/tests/test_user_api.py @@ -34,7 +34,7 @@ def test_specviz_zoom_level(specviz_helper): def test_specviz_data_labels(specviz_helper, spectrum1d): label = "Test 1D Spectrum" - specviz_helper.load_data(spectrum1d, data_label=label) + specviz_helper.load(spectrum1d, data_label=label) assert specviz_helper.data_labels == [label] assert specviz_helper.viewers['spectrum-viewer'].data_menu.data_labels_loaded == [label] diff --git a/jdaviz/tests/test_utils.py b/jdaviz/tests/test_utils.py index c4f37422d3..83c3e1a7b0 100644 --- a/jdaviz/tests/test_utils.py +++ b/jdaviz/tests/test_utils.py @@ -31,7 +31,7 @@ def test_alpha_index_exceptions(): def test_uri_to_download_bad_scheme(imviz_helper): uri = "file://path/to/file.fits" with pytest.raises(ValueError, match="no valid loaders found for input"): - imviz_helper.load_data(uri) + imviz_helper.load(uri) @pytest.mark.remote_data @@ -41,7 +41,7 @@ def test_uri_to_download_nonexistent_mast_file(imviz_helper): with pytest.raises(ValueError, match='Failed query for URI'): # NOTE: this test will attempt to reach out to MAST via astroquery # even if cache is available. - imviz_helper.load_data(uri, cache=False) + imviz_helper.load(uri, cache=False) @pytest.mark.remote_data @@ -50,7 +50,7 @@ def test_url_to_download_imviz_local_path_warning(imviz_helper): with warnings.catch_warnings(): warnings.simplefilter("ignore") - imviz_helper.load_data(url, cache=True, local_path='horsehead.fits') + imviz_helper.load(url, cache=True, local_path='horsehead.fits') def test_uri_to_download_specviz_local_path_check(): @@ -66,20 +66,20 @@ def test_uri_to_download_specviz_local_path_check(): @pytest.mark.remote_data def test_uri_to_download_specviz(specviz_helper): uri = cached_uri("mast:JWST/product/jw02732-c1001_t004_miri_ch1-short_x1d.fits") - specviz_helper.load_data(uri, cache=True) + specviz_helper.load(uri, cache=True) @pytest.mark.remote_data def test_uri_to_download_specviz2d(specviz2d_helper): uri = cached_uri("mast:jwst/product/jw01538-o161_t002-s000000001_nirspec_f290lp-g395h-s1600a1_s2d.fits") # noqa: E501 - specviz2d_helper.load_data(uri, cache=True) + specviz2d_helper.load(uri, cache=True) @pytest.mark.remote_data def test_load_s3_fits(imviz_helper): """Test loading a JWST FITS file from an S3 URI into Imviz.""" s3_uri = "s3://stpubdata/jwst/public/jw02727/L3/t/o002/jw02727-o002_t062_nircam_clear-f277w_i2d.fits" # noqa: E501 - imviz_helper.load_data(s3_uri) + imviz_helper.load(s3_uri) assert len(imviz_helper.app.data_collection) > 0