-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] Test and Score: Sort numerically, not alphabetically #3951
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3951 +/- ##
==========================================
- Coverage 85.22% 85.13% -0.09%
==========================================
Files 382 378 -4
Lines 67595 67159 -436
==========================================
- Hits 57606 57176 -430
+ Misses 9989 9983 -6 |
e6d30cc
to
53bf9af
Compare
53bf9af
to
bb87440
Compare
Or maybe just undo b419679 and go on from there. diff --git a/Orange/widgets/evaluate/owtestlearners.py b/Orange/widgets/evaluate/owtestlearners.py
index 139f2cb9c..9a2d77de9 100644
--- a/Orange/widgets/evaluate/owtestlearners.py
+++ b/Orange/widgets/evaluate/owtestlearners.py
@@ -533,7 +533,7 @@ class OWTestLearners(OWWidget):
for stat, scorer in zip(stats, self.scorers):
item = QStandardItem()
if stat.success:
- item.setText("{:.3f}".format(stat.value[0]))
+ item.setData(float(stat.value[0]), Qt.DisplayRole)
else:
item.setToolTip(str(stat.exception))
if scorer.name in self.score_table.shown_scores:
diff --git a/Orange/widgets/evaluate/utils.py b/Orange/widgets/evaluate/utils.py
index ebe060327..6caa6811b 100644
--- a/Orange/widgets/evaluate/utils.py
+++ b/Orange/widgets/evaluate/utils.py
@@ -109,6 +109,12 @@ class ScoreTable(OWComponent, QObject):
size = super().sizeHint(*args)
return QSize(size.width(), size.height() + 6)
+ def displayText(self, value, locale):
+ if isinstance(value, float):
+ return "{:.3f}".format(value)
+ else:
+ return super().displayText(value, locale)
+
def __init__(self, master):
QObject.__init__(self)
OWComponent.__init__(self, master) |
bb87440
to
2644ffc
Compare
Thanks @ales-erjavec. I reverted the changes in b419679, as you proposed. I still kept a (now simpler) proxy because I like putting the failed tests at the bottom. |
Sorting has a problem with A stable sort would be nice for sorting by multiple criteria (e.g. if the first criteria reaches the max value). Sorting by name and then by some constant column does not retain the alphabetical order. I don't know why this doesn't work out of the box. This would also solve the problem with a changing order of failed tests. If you have several, they change positions when going from ascending to descending (but stay in place from descending to ascending). |
There should be no nans in this table. If there are (but I haven't seen them yet), this is a different bug; they have to be replaced by errors by the widget.
Sorting is done by
It would be nice to keep the order, but it's not such a problem. :) |
True, but as it is a part of the utils, it would be nice if it handled this additional case (besides "" and None) that might come up somewhere else. Actually, anything that is not a float could fall into the same bottom category.
I've just checked that |
2644ffc
to
0887a2a
Compare
|
Fixes #3947 by using a QSortFilterProxy that sorts numerically, if column values can be converted to numbers, or case-insensitive, if they can't.
Includes