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] OWAnchorProjectionWidget: Retain valid_data when reloading dataset #3718

Merged
merged 1 commit into from
Apr 5, 2019
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/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,8 @@ def test_embedding_missing_values(self):
output = self.get_output(ANNOTATED_DATA_SIGNAL_NAME)
embedding_mask = np.all(np.isnan(output.metas[:, :2]), axis=1)
np.testing.assert_array_equal(~embedding_mask, self.widget.valid_data)
# reload
self.send_signal(self.widget.Inputs.data, table)

def test_sparse_data(self):
table = Table("iris")
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owfreeviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def error(err):
error(self.Error.features_exceeds_instances)
elif not np.sum(np.std(self.data.X, axis=0)):
error(self.Error.constant_data)
elif np.sum(self.valid_data) > self.MAX_INSTANCES:
elif np.sum(np.all(np.isfinite(self.data.X), axis=1)) > self.MAX_INSTANCES:
error(self.Error.too_many_data_instances)
else:
if len(self.effective_variables) < len(domain.attributes):
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owlinearprojection.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def _init_vizrank(self):
elif len([v for v in self.continuous_variables
if v is not self.attr_color]) < 3:
msg = "Not enough available continuous variables"
elif len(self.data[self.valid_data]) < 2:
elif np.sum(np.all(np.isfinite(self.data.X), axis=1)) < 2:
msg = "Not enough valid data instances"
else:
is_enabled = not np.isnan(self.data.get_column_view(
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owradviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def _init_vizrank(self):
self.attr_color is not None and \
not np.isnan(self.data.get_column_view(
self.attr_color)[0].astype(float)).all() and \
len(self.data[self.valid_data]) > 1 and \
np.sum(np.all(np.isfinite(self.data.X), axis=1)) > 1 and \
np.all(np.nan_to_num(np.nanstd(self.data.X, 0)) != 0)
self.btn_vizrank.setEnabled(is_enabled)
if is_enabled:
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def findvar(name, iterable):
self.attr_size = findvar(self.attr_size, self.gui.size_model)

def check_data(self):
self.clear_messages()
super().check_data()
self.__timer.stop()
self.sampling.setVisible(False)
self.sql_data = None
Expand Down
5 changes: 2 additions & 3 deletions Orange/widgets/visualize/utils/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ def set_data(self, data):
self.enable_controls()

def check_data(self):
self.valid_data = None
self.clear_messages()

def use_context(self):
Expand Down Expand Up @@ -649,8 +648,7 @@ def error(err):
elif len(self.data) < 2:
error(self.Error.no_instances)
else:
self.valid_data = np.all(np.isfinite(self.data.X), axis=1)
if not np.sum(self.valid_data):
if not np.sum(np.all(np.isfinite(self.data.X), axis=1)):
error(self.Error.no_valid_data)

def init_projection(self):
Expand All @@ -663,6 +661,7 @@ def init_projection(self):
self.Error.proj_error(ex)

def get_embedding(self):
self.valid_data = None
if self.data is None or self.projection is None:
return None
embedding = self.projection(self.data).X
Expand Down