Пример #1
0
def test_wavelength_slider(cubeviz_layout, slice_index, cube_bounds):
    set_slider_index(cubeviz_layout, slice_index)
    assert_all_viewer_indices(cubeviz_layout, slice_index)

    # Make sure that wavelength text matches slice value
    wavelength_format = format_minimal(cube_bounds['wavelengths'])[0]
    wavelength_text = wavelength_format.format(cube_bounds['wavelengths'][slice_index])

    assert_wavelength_text(cubeviz_layout, wavelength_text)
Пример #2
0
def test_nearest_slice_index(qtbot, cubeviz_layout, wavelength, cube_bounds):
    # While this test mostly just duplicates the code in
    # _on_text_wavelength_change, it is useful to make sure that the effects
    # carry through in the viewer slices and text boxes
    wavelengths = cube_bounds['wavelengths']

    enter_wavelength_text(qtbot, cubeviz_layout, str(wavelength))
    slice_index = find_nearest_slice(wavelengths, wavelength)
    assert_all_viewer_indices(cubeviz_layout, slice_index)
    assert_slice_text(cubeviz_layout, slice_index)
    wavelength_format = format_minimal(cube_bounds['wavelengths'])[0]
    wavelength_text = wavelength_format.format(cube_bounds['wavelengths'][slice_index])
    assert_wavelength_text(cubeviz_layout, wavelength_text)
Пример #3
0
def test_wavelength_slider(cubeviz_layout, slice_index, cube_bounds):
    set_slider_index(cubeviz_layout, slice_index)
    assert_all_viewer_indices(cubeviz_layout, slice_index)

    # Make sure that wavelength text matches slice value
    wavelength = cube_bounds['wavelengths'][slice_index]
    wavelength_format = format_minimal(cube_bounds['wavelengths'])[0]
    wavelength_text = wavelength_format.format(wavelength)

    assert_wavelength_text(cubeviz_layout, wavelength_text)

    # Make sure specviz slider is updated appropriately
    specviz = cubeviz_layout.specviz._widget
    assert specviz._slice_indicator.getPos()[0] == wavelength
Пример #4
0
    def _handle_wavelength_update(self, message):

        # Grab the wavelengths so they can be displayed in the text box
        self._wavelengths = message.wavelengths
        self._wavelength_format = format_minimal(self._wavelengths)[0]
        self._slice_slider.setMaximum(len(self._wavelengths) - 1)

        if self.synced_index is None:
            # Set the initial display to the middle of the cube
            middle_index = len(self._wavelengths) // 2
            self._slice_slider.setValue(middle_index)
            self.synced_index = middle_index

        index = self._cv_layout._active_cube._widget.slice_index
        self._wavelength_textbox.setText(
            self.format_wavelength(self._wavelengths[index]))