Skip to content

Commit

Permalink
Merge pull request #5062 from ajdapretnar/distance-annot
Browse files Browse the repository at this point in the history
Distance Matrix: Ignore coloring on string variables
  • Loading branch information
janezd committed Nov 6, 2020
2 parents 81f8364 + 36bb26c commit c81997f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Orange/widgets/unsupervised/owdistancematrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from AnyQt.QtCore import Qt, QAbstractTableModel, QModelIndex, \
QItemSelectionModel, QItemSelection, QSize

from Orange.data import Table, Variable
from Orange.data import Table, Variable, StringVariable
from Orange.misc import DistMatrix
from Orange.widgets import widget, gui
from Orange.widgets.data.owtable import ranges
Expand Down Expand Up @@ -46,7 +46,8 @@ def set_labels(self, labels, variable=None, values=None):
self.labels = labels
self.variable = variable
self.values = values
if self.values is not None:
if self.values is not None and not isinstance(self.variable,
StringVariable):
self.label_colors = variable.palette.values_to_qcolors(values)
else:
self.label_colors = None
Expand Down
10 changes: 10 additions & 0 deletions Orange/widgets/unsupervised/tests/test_owdistancematrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ def test_unconditional_commit_on_new_signal(self):
commit.reset_mock()
self.send_signal(self.widget.Inputs.distances, self.distances)
commit.assert_called()

def test_labels(self):
grades = Table.from_url("https://datasets.biolab.si/core/grades-two.tab")
distances = Euclidean(grades)
self.widget.set_distances(distances)
ac = self.widget.annot_combo
idx = ac.model().indexOf(grades.domain.metas[0])
ac.setCurrentIndex(idx)
ac.activated.emit(idx)
self.assertIsNone(self.widget.tablemodel.label_colors)

0 comments on commit c81997f

Please sign in to comment.