Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] heatmap: Do not crash on all zero column #2916

Merged
merged 1 commit into from
Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Orange/widgets/visualize/owheatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,8 @@ def cluster_columns(self, data, parts):
if need_dist:
data = Orange.distance._preprocess(data)
matrix = Orange.distance.PearsonR(data, axis=0)
# nan values break clustering below
matrix = np.nan_to_num(matrix)

if cluster is None:
cluster = hierarchical.dist_matrix_clustering(matrix)
Expand Down
11 changes: 10 additions & 1 deletion Orange/widgets/visualize/tests/test_owheatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUpClass(cls):
cls.signal_data = cls.data

def setUp(self):
self.widget = self.create_widget(OWHeatMap)
self.widget = self.create_widget(OWHeatMap) # type: OWHeatMap

def test_input_data(self):
"""Check widget's data with data on the input"""
Expand Down Expand Up @@ -117,3 +117,12 @@ def test_data_column_nans(self):
table = datasets.data_one_column_nans()
self.widget.controls.merge_kmeans.setChecked(True)
self.send_signal(self.widget.Inputs.data, table)

def test_cluster_column_on_all_zero_column(self):
# Pearson distance used for clustering of columns does not
# handle all zero columns well
iris = Table("iris")
iris[:, 0] = 0

self.widget.col_clustering = True
self.widget.set_dataset(iris)