Skip to content

Commit c54cfcb

Browse files
authored
Merge pull request #6537 from ales-erjavec/fixes/owpredictions-no-target-report
[FIX] owpredictions: Fix a type error in report when using NoopDelegate
2 parents f531854 + cd67c66 commit c54cfcb

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Orange/widgets/evaluate/owpredictions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy
1010
from AnyQt.QtWidgets import (
1111
QTableView, QSplitter, QToolTip, QStyle, QApplication, QSizePolicy,
12-
QPushButton, QAbstractItemDelegate)
12+
QPushButton, QStyledItemDelegate)
1313
from AnyQt.QtGui import QPainter, QStandardItem, QPen, QColor, QBrush
1414
from AnyQt.QtCore import (
1515
Qt, QSize, QRect, QRectF, QPoint, QPointF, QLocale,
@@ -1117,14 +1117,16 @@ def sizeHint(cls, option, index):
11171117
return cls.__size_hint
11181118

11191119

1120-
class NoopItemDelegate(QAbstractItemDelegate):
1120+
class NoopItemDelegate(QStyledItemDelegate):
11211121
def paint(self, *_):
11221122
pass
11231123

1124-
@staticmethod
1125-
def sizeHint(*_):
1124+
def sizeHint(self, *_):
11261125
return QSize(0, 0)
11271126

1127+
def displayText(self, *_):
1128+
return ""
1129+
11281130

11291131
class ClassificationErrorDelegate(ErrorDelegate):
11301132
def displayText(self, value, _):

Orange/widgets/evaluate/tests/test_owpredictions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ def test_no_class_on_test(self):
152152
predmodel.data(predmodel.index(0, 0), Qt.UserRole)))
153153
self.assertIn(predmodel.data(predmodel.index(0, 0))[0],
154154
titanic.domain.class_var.values)
155+
self.widget.send_report()
156+
157+
housing = self.housing[::5]
158+
mean_housing = ConstantLearner()(housing)
159+
no_target = housing.transform(Domain(housing.domain.attributes, None))
160+
self.send_signal(self.widget.Inputs.data, no_target)
161+
self.send_signal(self.widget.Inputs.predictors, mean_housing, 1)
162+
self.widget.send_report()
155163

156164
def test_invalid_regression_target(self):
157165
widget = self.widget

0 commit comments

Comments
 (0)