Skip to content

Commit

Permalink
Merge pull request #4551 from aturanjanin/paintdata
Browse files Browse the repository at this point in the history
[FIX] Paint Data: Send correct output after clicking Reset to Input
  • Loading branch information
janezd authored Mar 20, 2020
2 parents 349d7d8 + e6d5c71 commit 0ff63fa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Orange/widgets/data/owpaintdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,8 @@ def reset_to_input(self):
else: # set_dimensions already calls _replot, no need to call it again
self._replot()

self.commit()

def add_new_class_label(self, undoable=True):

newlabel = next(label for label in namegen('C', 1)
Expand Down
31 changes: 30 additions & 1 deletion Orange/widgets/data/tests/test_owpaintdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import numpy as np
import scipy.sparse as sp

from AnyQt.QtCore import QRectF, QPointF
from AnyQt.QtCore import QRectF, QPointF, QEvent, Qt
from AnyQt.QtGui import QMouseEvent

from Orange.data import Table, DiscreteVariable, ContinuousVariable, Domain
from Orange.widgets.data import owpaintdata
Expand Down Expand Up @@ -79,3 +80,31 @@ def test_load_empty_data(self):
GH-2399
"""
self.create_widget(OWPaintData, stored_settings={"data": []})

def test_reset_to_input(self):
"""Checks if the data resets to input when Reset to Input is pressed"""
data = Table("iris")
self.send_signal(self.widget.Inputs.data, data)
output = self.get_output(self.widget.Outputs.data)
self.assertEqual(len(output), len(data))
self.widget.set_current_tool(self.widget.TOOLS[1][2]) # PutInstanceTool
tool = self.widget.current_tool
event = QMouseEvent(QEvent.MouseButtonPress, QPointF(0.17, 0.17),
Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
tool.mousePressEvent(event)
output = self.get_output(self.widget.Outputs.data)
self.assertNotEqual(len(output), len(data))
self.assertEqual(len(output), 151)
self.widget.reset_to_input()
output = self.get_output(self.widget.Outputs.data)
self.assertEqual(len(output), len(data))

self.send_signal(self.widget.Inputs.data, data)
output = self.get_output(self.widget.Outputs.data)
self.assertEqual(len(output), len(data))
self.widget.set_current_tool(self.widget.TOOLS[5][2]) # ClearTool
output = self.get_output(self.widget.Outputs.data)
self.assertIsNone(output)
self.widget.reset_to_input()
output = self.get_output(self.widget.Outputs.data)
self.assertEqual(len(output), len(data))

0 comments on commit 0ff63fa

Please sign in to comment.