Skip to content

Commit

Permalink
[FIX] Scatter Plot Graph: crash on metas column with all 0 values
Browse files Browse the repository at this point in the history
  • Loading branch information
jerneju committed Nov 15, 2017
1 parent 45bc5f8 commit 33219bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 1 addition & 5 deletions Orange/widgets/utils/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ def _compute_scaled_data(self):
return

Y = data.Y if data.Y.ndim == 2 else np.atleast_2d(data.Y).T
if np.any(data.metas):
all_data = (data.X, Y, data.metas)
else:
all_data = (data.X, Y)
all_data = np.hstack(all_data).T
all_data = np.hstack((data.X, Y, data.metas)).T
self.scaled_data = self.data.copy()
self.valid_data_array = np.isfinite(all_data)
domain = self.domain
Expand Down
14 changes: 14 additions & 0 deletions Orange/widgets/visualize/tests/test_owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,20 @@ def test_sparse_subset_data(self):
self.send_signal(w.Inputs.data_subset, data[::30])
self.assertEqual(len(w.graph.subset_indices), 5)

def test_metas_zero_column(self):
"""
Prevent crash when metas column is zero.
GH-2775
"""
data = Table("iris")
domain = data.domain
domain = Domain(domain.attributes[:3], domain.class_vars, domain.attributes[3:])
data = data.transform(domain)
data.metas[:, 0] = 0
w = self.widget
self.send_signal(w.Inputs.data, data)
simulate.combobox_activate_item(w.controls.attr_x, domain.metas[0].name)


if __name__ == "__main__":
import unittest
Expand Down

0 comments on commit 33219bf

Please sign in to comment.