Skip to content

Commit 4f9931e

Browse files
committed
OWTable: Sort Continuous metas as floats; not strings
Continuous variables inside meta attributes are currently sorted by their string represenation and not by float values. This happens since dtype for metas is object and we map all object to strings before sorting. This PR checks whether the sorting variable is ContinuousVariable and casts values to floats.
1 parent c1f3794 commit 4f9931e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Orange/widgets/utils/itemmodels.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,9 @@ def columnSortKeyData(self, column, role):
10151015
and role == TableModel.ValueRole:
10161016
col_view, _ = self.source.get_column_view(coldesc.var)
10171017
col_data = numpy.asarray(col_view)
1018+
if coldesc.var.is_continuous:
1019+
# continuous from metas have dtype object; cast it to float
1020+
col_data = col_data.astype(float)
10181021
if self.__sortInd is not None:
10191022
col_data = col_data[self.__sortInd]
10201023
return col_data

0 commit comments

Comments
 (0)