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] ScatterPlot Crashes on Data With Infinity Values #2709

Merged
merged 2 commits into from
Oct 27, 2017
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
21 changes: 19 additions & 2 deletions Orange/widgets/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,10 +792,10 @@ def missing_data_3(cls):
return Table(cls.path("missing_data_3.tab"))

@classmethod
def data_one_column_nans(cls):
def data_one_column_vals(cls, value=np.nan):
"""
Data set with two continuous features and one discrete. One continuous
columns has missing values (NaN).
columns has custom set values (default nan).

Returns
-------
Expand All @@ -812,4 +812,21 @@ def data_one_column_nans(cls):
["", "", "", ""],
"ynyn"
)))
table[:, 1] = value
return table

@classmethod
def data_one_column_nans(cls):
"""
Data set with two continuous features and one discrete. One continuous
columns has missing values (NaN).

Returns
-------
data : Orange.data.Table
"""
return cls.data_one_column_vals(value=np.nan)

@classmethod
def data_one_column_infs(cls):
return cls.data_one_column_vals(value=np.inf)
2 changes: 1 addition & 1 deletion Orange/widgets/utils/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _compute_scaled_data(self):
Y = data.Y if data.Y.ndim == 2 else np.atleast_2d(data.Y).T
self.original_data = np.hstack((data.X, Y)).T
self.scaled_data = no_jit = self.original_data.copy()
self.valid_data_array = ~np.isnan(no_jit)
self.valid_data_array = np.isfinite(no_jit)
for index in range(len(data.domain)):
attr = data.domain[index]
if attr.is_discrete:
Expand Down
11 changes: 11 additions & 0 deletions Orange/widgets/visualize/tests/test_owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ def test_data_column_nans(self):

self.widget.update_graph()

def test_data_column_infs(self):
"""
Scatter Plot should not crash on data with infinity values
GH-2707
GH-2684
"""
table = datasets.data_one_column_infs()
self.send_signal(self.widget.Inputs.data, table)
attr_x = self.widget.controls.attr_x
simulate.combobox_activate_item(attr_x, "b")

def test_regression_line(self):
"""It is possible to draw the line only for pair of continuous attrs"""
self.send_signal(self.widget.Inputs.data, self.data)
Expand Down