Exemple #1
0
def test_get_tray_item_from_name():
    app = Application(configuration='default')
    plg = app.get_tray_item_from_name('g-gaussian-smooth')
    assert isinstance(plg, GaussianSmooth)

    with pytest.raises(KeyError, match='not found in app'):
        app.get_tray_item_from_name('imviz-compass')
Exemple #2
0
def test_spatial_convolution(spectrum1d_cube):

    app = Application(configuration="cubeviz")
    dc = app.data_collection
    app.add_data(spectrum1d_cube, 'test')

    gs = GaussianSmooth(app=app)
    gs._on_data_selected({'new': 'test'})
    gs.stddev = '3'
    gs.vue_spatial_convolution()

    assert len(dc) == 2
    assert dc[1].label == "Smoothed test spatial stddev 3.0"
    assert (dc["Smoothed test spatial stddev 3.0"].get_object(
        cls=Spectrum1D, statistic=None).shape == (4, 2, 2))
Exemple #3
0
def test_linking_after_spectral_smooth(spectrum1d_cube):

    app = Application(configuration="cubeviz")
    dc = app.data_collection
    app.add_data(spectrum1d_cube, 'test')

    gs = GaussianSmooth(app=app)

    gs._on_data_selected({'new': 'test'})
    gs.stddev = '3.2'
    gs.add_replace_results = False
    gs.vue_spectral_smooth()

    assert len(dc) == 2
    assert dc[1].label == 'Smoothed test stddev 3.2'
    assert len(dc.external_links) == 1

    assert dc.external_links[0].cids1[0] is dc[0].world_component_ids[0]
    assert dc.external_links[0].cids2[0] is dc[1].world_component_ids[0]
Exemple #4
0
def test_spatial_convolution(spectral_cube_wcs):

    app = Application()
    dc = app.data_collection
    dc.append(
        Data(x=np.ones((3, 4, 5)), label='test', coords=spectral_cube_wcs))

    gs = GaussianSmooth(app=app)
    gs._on_data_selected({'new': 'test'})
    gs.stddev = '3'
    gs.vue_spatial_convolution()

    assert len(dc) == 2
    assert dc[1].label == "Smoothed test"
    assert dc["Smoothed test"].get_object(cls=SpectralCube).shape == (3, 4, 5)
Exemple #5
0
def test_linking_after_collapse(spectral_cube_wcs):

    app = Application()
    dc = app.data_collection
    dc.append(
        Data(x=np.ones((3, 4, 5)), label='test', coords=spectral_cube_wcs))

    coll = Collapse(app=app)

    coll.selected_data_item = 'test'

    coll.selected_axis = 0
    coll.vue_collapse()

    assert len(dc) == 2
    assert dc[1].label == 'Collapsed 1 test'
    assert len(dc.external_links) == 3

    assert dc.external_links[1].cids1[0] is dc[0].pixel_component_ids[1]
    assert dc.external_links[1].cids2[0] is dc[1].pixel_component_ids[0]
    assert dc.external_links[2].cids1[0] is dc[0].pixel_component_ids[2]
    assert dc.external_links[2].cids2[0] is dc[1].pixel_component_ids[1]

    coll.selected_axis = 1
    coll.vue_collapse()

    assert len(dc) == 3
    assert dc[2].label == 'Collapsed 2 test'
    assert len(dc.external_links) == 7

    assert dc.external_links[5].cids1[0] is dc[0].pixel_component_ids[0]
    assert dc.external_links[5].cids2[0] is dc[2].pixel_component_ids[0]
    assert dc.external_links[6].cids1[0] is dc[0].pixel_component_ids[2]
    assert dc.external_links[6].cids2[0] is dc[2].pixel_component_ids[1]

    coll.selected_axis = 2
    coll.vue_collapse()

    assert len(dc) == 4
    assert dc[3].label == 'Collapsed 3 test'
    assert len(dc.external_links) == 12

    assert dc.external_links[10].cids1[0] is dc[0].pixel_component_ids[0]
    assert dc.external_links[10].cids2[0] is dc[3].pixel_component_ids[0]
    assert dc.external_links[11].cids1[0] is dc[0].pixel_component_ids[1]
    assert dc.external_links[11].cids2[0] is dc[3].pixel_component_ids[1]
Exemple #6
0
def test_moment_calculation(spectral_cube_wcs):

    app = Application()
    dc = app.data_collection
    dc.append(
        Data(x=np.ones((3, 4, 5)), label='test', coords=spectral_cube_wcs))

    mm = MomentMap(app=app)

    mm.selected_data = 'test'
    mm.n_moment = 0
    mm.vue_calculate_moment(None)

    print(dc[1].get_object())

    assert mm.moment_available
    assert dc[1].label == 'Moment 0: test'
    assert dc[1].get_object().shape == (4, 5)
Exemple #7
0
def test_linking_after_spectral_smooth(spectral_cube_wcs):

    app = Application(configuration="cubeviz")
    dc = app.data_collection
    dc.append(
        Data(x=np.ones((3, 4, 5)), label='test', coords=spectral_cube_wcs))

    gs = GaussianSmooth(app=app)

    gs._on_data_selected({'new': 'test'})
    gs.stddev = '3.2'
    gs.vue_spectral_smooth()

    assert len(dc) == 2
    assert dc[1].label == 'Smoothed test'
    assert len(dc.external_links) == 1

    assert dc.external_links[0].cids1[0] is dc[0].world_component_ids[0]
    assert dc.external_links[0].cids2[0] is dc[1].world_component_ids[0]
Exemple #8
0
def test_model_ids(spectral_cube_wcs):
    app = Application()
    dc = app.data_collection
    dc.append(
        Data(x=np.ones((3, 4, 5)), label='test', coords=spectral_cube_wcs))

    plugin = ModelFitting(app=app)

    plugin.data_selected = 'test'
    plugin.component_models = [{'id': 'valid_string_already_exists'}]
    plugin.temp_model = 'Linear1D'

    with pytest.raises(
            ValueError,
            match=
            "model component ID valid_string_already_exists already in use"):
        plugin.temp_name = 'valid_string_already_exists'
        plugin.vue_add_model({})

    with pytest.raises(ValueError,
                       match="invalid model component ID invalid-string"):
        plugin.temp_name = 'invalid-string'
        plugin.vue_add_model({})
Exemple #9
0
def test_default_viewer_ids_default():
    app = Application(configuration='default')
    assert app.get_viewer_reference_names() == []
    assert app.get_viewer_ids() == []
Exemple #10
0
def todo_fix_test_slit_overlay(spectral_cube_wcs):

    app = Application()
    dc = app.data_collection
    dc.append(
        Data(x=np.ones((3, 4, 5)), label='test', coords=spectral_cube_wcs))