Skip to content

Commit

Permalink
OWAnchorProjectionWidget: Retain valid_data when reloading dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Apr 4, 2019
1 parent 31a9c08 commit ae1eb5b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
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

0 comments on commit ae1eb5b

Please sign in to comment.