Skip to content

Commit 8bf5710

Browse files
committed
fix: RuntimeError when trying to update deleted matrix element (close #38)
1 parent 25fcaf1 commit 8bf5710

File tree

4 files changed

+61
-80
lines changed

4 files changed

+61
-80
lines changed

CHANGELOG

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
2.0.2
22
- fix: IndexError when removing a plot (#36)
3-
- fix: ValueError wehn filtering all events in Quick View (#37)
3+
- fix: ValueError when filtering all events in Quick View (#37)
4+
- fix: TypeError when removing datasets and opening Quick View (#38)
5+
- fix: RuntimeError when removing datasets and opening Quick View (#38)
46
2.0.1
57
- fix: correctly distinguish prereleases when checking for new versions
68
- enh: allow loading data via drag&drop

shapeout2/gui/matrix/dm_element.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ def update_content(self, quickview=False):
8787
# reset color of old quick view instance
8888
if curinst is not None and self is not curinst:
8989
MatrixElement._quick_view_instance = None
90-
curinst.update_content()
90+
try:
91+
curinst.update_content()
92+
except RuntimeError:
93+
# element has been deleted
94+
pass
9195
MatrixElement._quick_view_instance = self
9296
do_quickview = True
9397
else:

tests/test_gui_quickview.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,59 @@ def test_clear_session_issue_25(qtbot):
5050
mw.on_action_clear(assume_yes=True)
5151

5252

53+
def test_no_events_issue_37(qtbot):
54+
"""https://github.com/ZELLMECHANIK-DRESDEN/ShapeOut2/issues/37
55+
56+
"ValueError: zero-size array to reduction operation minimum
57+
which has no identity" when all events are filtered out.
58+
"""
59+
mw = ShapeOut2()
60+
qtbot.addWidget(mw)
61+
62+
# add a dataslot
63+
path = pathlib.Path(__file__).parent / "data" / "calibration_beads_47.rtdc"
64+
mw.add_dataslot(paths=[path, path])
65+
66+
assert len(mw.pipeline.slot_ids) == 2, "we added those"
67+
assert len(mw.pipeline.filter_ids) == 1, "automatically added"
68+
69+
# activate a dataslot
70+
slot_id = mw.pipeline.slot_ids[0]
71+
filt_id = mw.pipeline.filter_ids[0]
72+
em = mw.block_matrix.get_widget(slot_id, filt_id)
73+
qtbot.mouseClick(em, QtCore.Qt.LeftButton) # activate
74+
# did that work?
75+
assert mw.pipeline.is_element_active(slot_id, filt_id)
76+
77+
# filter away all events
78+
fe = mw.block_matrix.get_widget(filt_plot_id=filt_id)
79+
qtbot.mouseClick(fe.toolButton_modify, QtCore.Qt.LeftButton)
80+
fv = mw.widget_ana_view.widget_filter
81+
qtbot.mouseClick(fv.toolButton_moreless, QtCore.Qt.LeftButton)
82+
rc = fv._box_range_controls["area_um"]
83+
qtbot.mouseClick(rc.checkBox, QtCore.Qt.LeftButton)
84+
# did that work?
85+
assert rc.checkBox.isChecked()
86+
qtbot.mouseClick(fv.toolButton_moreless, QtCore.Qt.LeftButton)
87+
# set range
88+
rc.doubleSpinBox_min.setValue(0)
89+
rc.doubleSpinBox_max.setValue(1)
90+
qtbot.mouseClick(fv.pushButton_apply, QtCore.Qt.LeftButton)
91+
# did that work?
92+
ds = mw.pipeline.get_dataset(slot_index=0, filt_index=0,
93+
apply_filter=True)
94+
assert np.sum(ds.filter.all) == 0
95+
96+
# open QuickView
97+
slot_id = mw.pipeline.slot_ids[0]
98+
filt_id = mw.pipeline.filter_ids[0]
99+
em = mw.block_matrix.get_widget(slot_id, filt_id)
100+
101+
# this raised the error
102+
qtbot.mouseClick(em, QtCore.Qt.LeftButton, QtCore.Qt.ShiftModifier)
103+
mw.close()
104+
105+
53106
def test_update_polygon_filter_issue_26(qtbot):
54107
"""https://github.com/ZELLMECHANIK-DRESDEN/ShapeOut2/issues/26
55108

tests/test_gui_quickview2.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)