Skip to content

Commit 0ff63fa

Browse files
authored
Merge pull request #4551 from aturanjanin/paintdata
[FIX] Paint Data: Send correct output after clicking Reset to Input
2 parents 349d7d8 + e6d5c71 commit 0ff63fa

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Orange/widgets/data/owpaintdata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,8 @@ def reset_to_input(self):
10591059
else: # set_dimensions already calls _replot, no need to call it again
10601060
self._replot()
10611061

1062+
self.commit()
1063+
10621064
def add_new_class_label(self, undoable=True):
10631065

10641066
newlabel = next(label for label in namegen('C', 1)

Orange/widgets/data/tests/test_owpaintdata.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import numpy as np
55
import scipy.sparse as sp
66

7-
from AnyQt.QtCore import QRectF, QPointF
7+
from AnyQt.QtCore import QRectF, QPointF, QEvent, Qt
8+
from AnyQt.QtGui import QMouseEvent
89

910
from Orange.data import Table, DiscreteVariable, ContinuousVariable, Domain
1011
from Orange.widgets.data import owpaintdata
@@ -79,3 +80,31 @@ def test_load_empty_data(self):
7980
GH-2399
8081
"""
8182
self.create_widget(OWPaintData, stored_settings={"data": []})
83+
84+
def test_reset_to_input(self):
85+
"""Checks if the data resets to input when Reset to Input is pressed"""
86+
data = Table("iris")
87+
self.send_signal(self.widget.Inputs.data, data)
88+
output = self.get_output(self.widget.Outputs.data)
89+
self.assertEqual(len(output), len(data))
90+
self.widget.set_current_tool(self.widget.TOOLS[1][2]) # PutInstanceTool
91+
tool = self.widget.current_tool
92+
event = QMouseEvent(QEvent.MouseButtonPress, QPointF(0.17, 0.17),
93+
Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
94+
tool.mousePressEvent(event)
95+
output = self.get_output(self.widget.Outputs.data)
96+
self.assertNotEqual(len(output), len(data))
97+
self.assertEqual(len(output), 151)
98+
self.widget.reset_to_input()
99+
output = self.get_output(self.widget.Outputs.data)
100+
self.assertEqual(len(output), len(data))
101+
102+
self.send_signal(self.widget.Inputs.data, data)
103+
output = self.get_output(self.widget.Outputs.data)
104+
self.assertEqual(len(output), len(data))
105+
self.widget.set_current_tool(self.widget.TOOLS[5][2]) # ClearTool
106+
output = self.get_output(self.widget.Outputs.data)
107+
self.assertIsNone(output)
108+
self.widget.reset_to_input()
109+
output = self.get_output(self.widget.Outputs.data)
110+
self.assertEqual(len(output), len(data))

0 commit comments

Comments
 (0)