Skip to content

Commit

Permalink
OWTable: Sort Continuous metas as floats; not strings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikicc committed Oct 21, 2016
1 parent c1f3794 commit 4f9931e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Orange/widgets/utils/itemmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f9931e

Please sign in to comment.