From 4f9931e3e0945cc617c0197b92d8ad5a5307d180 Mon Sep 17 00:00:00 2001 From: nikicc Date: Thu, 20 Oct 2016 21:38:50 +0200 Subject: [PATCH] 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. --- Orange/widgets/utils/itemmodels.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Orange/widgets/utils/itemmodels.py b/Orange/widgets/utils/itemmodels.py index f412acad140..c8fdc2ccf4d 100644 --- a/Orange/widgets/utils/itemmodels.py +++ b/Orange/widgets/utils/itemmodels.py @@ -1015,6 +1015,9 @@ def columnSortKeyData(self, column, role): and role == TableModel.ValueRole: col_view, _ = self.source.get_column_view(coldesc.var) col_data = numpy.asarray(col_view) + if coldesc.var.is_continuous: + # continuous from metas have dtype object; cast it to float + col_data = col_data.astype(float) if self.__sortInd is not None: col_data = col_data[self.__sortInd] return col_data