Skip to content

Commit

Permalink
Merge pull request biolab#1876 from ales-erjavec/fixes/silhouette-plo…
Browse files Browse the repository at this point in the history
…t-type-error

[FIX] owsilhouetteplot: Fix TypeError when cluster column is an object array
(cherry picked from commit 163eb9f)
  • Loading branch information
astaric committed Jan 18, 2017
1 parent 6b0241f commit 2970400
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Orange/widgets/visualize/owsilhouetteplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def _update(self):

labelvar = self.cluster_var_model[self.cluster_var_idx]
labels, _ = self.data.get_column_view(labelvar)
labels = numpy.asarray(labels, dtype=float)
mask = numpy.isnan(labels)
labels = labels.astype(int)
labels = labels[~mask]
Expand Down
12 changes: 12 additions & 0 deletions Orange/widgets/visualize/tests/test_owsilhouetteplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np

import Orange.data
from Orange.widgets.utils.annotated_data import ANNOTATED_DATA_SIGNAL_NAME
from Orange.widgets.visualize.owsilhouetteplot import OWSilhouettePlot
from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin
Expand Down Expand Up @@ -72,3 +73,14 @@ def test_unknowns_in_labels(self):
self.assertTrue(np.all(np.isfinite(scores_1)))
# the scores must match
np.testing.assert_almost_equal(scores_1, scores[valid], decimal=12)

def test_meta_object_dtype(self):
# gh-1875: Test on mixed string/discrete metas
data = self.data[::5]
domain = Orange.data.Domain(
data.domain.attributes, [],
[data.domain["iris"],
Orange.data.StringVariable("S")]
)
data = data.from_table(domain, data)
self.send_signal("Data", data)

0 comments on commit 2970400

Please sign in to comment.