Skip to content

Commit

Permalink
Merge pull request #6537 from ales-erjavec/fixes/owpredictions-no-tar…
Browse files Browse the repository at this point in the history
…get-report

[FIX] owpredictions: Fix a type error in report when using NoopDelegate
  • Loading branch information
janezd committed Aug 17, 2023
2 parents f531854 + cd67c66 commit c54cfcb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Orange/widgets/evaluate/owpredictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy
from AnyQt.QtWidgets import (
QTableView, QSplitter, QToolTip, QStyle, QApplication, QSizePolicy,
QPushButton, QAbstractItemDelegate)
QPushButton, QStyledItemDelegate)
from AnyQt.QtGui import QPainter, QStandardItem, QPen, QColor, QBrush
from AnyQt.QtCore import (
Qt, QSize, QRect, QRectF, QPoint, QPointF, QLocale,
Expand Down Expand Up @@ -1117,14 +1117,16 @@ def sizeHint(cls, option, index):
return cls.__size_hint


class NoopItemDelegate(QAbstractItemDelegate):
class NoopItemDelegate(QStyledItemDelegate):
def paint(self, *_):
pass

@staticmethod
def sizeHint(*_):
def sizeHint(self, *_):
return QSize(0, 0)

def displayText(self, *_):
return ""


class ClassificationErrorDelegate(ErrorDelegate):
def displayText(self, value, _):
Expand Down
8 changes: 8 additions & 0 deletions Orange/widgets/evaluate/tests/test_owpredictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ def test_no_class_on_test(self):
predmodel.data(predmodel.index(0, 0), Qt.UserRole)))
self.assertIn(predmodel.data(predmodel.index(0, 0))[0],
titanic.domain.class_var.values)
self.widget.send_report()

housing = self.housing[::5]
mean_housing = ConstantLearner()(housing)
no_target = housing.transform(Domain(housing.domain.attributes, None))
self.send_signal(self.widget.Inputs.data, no_target)
self.send_signal(self.widget.Inputs.predictors, mean_housing, 1)
self.widget.send_report()

def test_invalid_regression_target(self):
widget = self.widget
Expand Down

0 comments on commit c54cfcb

Please sign in to comment.