Skip to content

Commit

Permalink
fix: regression TypeError when trying to plot contour data
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Dec 17, 2024
1 parent 562d71a commit 0d51f46
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.20.1
- fix: regression TypeError when trying to plot contour data
2.20.0
- feat: display and handle quantitative phase imaging data
- fix: filter range control not updating limits, displaying value "100" (#183)
Expand Down
2 changes: 1 addition & 1 deletion shapeout2/gui/quick_view/qv_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def display_contour(self, ds, event, state, cellimg, feat):
if state["event"]["image zoom"]:
cellimg = self.image_zoom(cellimg, mask)

return cellimg
return cellimg

@staticmethod
def _convert_to_rgb(cellimg):
Expand Down
49 changes: 49 additions & 0 deletions tests/test_gui_quickview.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Test of Quick View set functionalities"""
import pathlib
import shutil

import h5py
from PyQt6 import QtCore, QtWidgets

import dclab
Expand Down Expand Up @@ -797,6 +799,53 @@ def test_contour_display_qpi_pha(qtbot):
image_without_contour == lowest_cmap_val, axis=-1))


def test_image_without_mask_data(qtbot, tmp_path):
"""Make sure image is plotted when there is no mask data"""
path_in = tmp_path / "test.rtdc"
shutil.copy2(datapath / "calibration_beads_47.rtdc", path_in)
with h5py.File(path_in, "a") as h5:
del h5["events/contour"]
del h5["events/mask"]

# Create main window
mw = ShapeOut2()
qtbot.addWidget(mw)

mw.add_dataslot(paths=[path_in])

assert len(mw.pipeline.slot_ids) == 1, "we added those"
assert len(mw.pipeline.filter_ids) == 1, "automatically added"

# Test if CheckBox is visible for dataset
# and if it is checked by default

# Activate dataslots
slot_id1 = mw.pipeline.slot_ids[0]
filt_id = mw.pipeline.filter_ids[0]
em1 = mw.block_matrix.get_widget(slot_id1, filt_id)

# Activate
qtbot.mouseClick(em1, QtCore.Qt.MouseButton.LeftButton)
# Open QuickView-window
qtbot.mouseClick(em1, QtCore.Qt.MouseButton.LeftButton,
QtCore.Qt.KeyboardModifier.ShiftModifier)

# Check if QuickView-window is open
assert mw.toolButton_quick_view.isChecked(), "Quickview not Open"

# Get QuickView instance
qv = mw.widget_quick_view

# Open event tool of QuickView
event_tool = qv.toolButton_event
qtbot.mouseClick(event_tool, QtCore.Qt.MouseButton.LeftButton)

# Test if data changes when CheckBox is unchecked
image_with_contrast = qv.imageView_image.getImageItem().image

assert np.any(image_with_contrast)


def test_isoelasticity_lines_with_lut_selection(qtbot):
"""Test look-up table selection for isoelasticity lines"""

Expand Down

0 comments on commit 0d51f46

Please sign in to comment.