Skip to content

Commit fabacdf

Browse files
authored
Merge pull request #6000 from ajdapretnar/heat-map-hide
OWHeatMap: don't show hidden attributes
2 parents 7d6c7d7 + bf75c8c commit fabacdf

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

Orange/widgets/visualize/owheatmap.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ def __init__(self):
229229
#: The original data with all features (retained to
230230
#: preserve the domain on the output)
231231
self.input_data = None
232-
#: The effective data striped of discrete features, and often
233-
#: merged using k-means
232+
#: The effective data stripped of discrete features and hidden
233+
#: attributes, and often merged using k-means
234234
self.data = None
235235
self.effective_data = None
236236
#: Source of column annotations (derived from self.data)
@@ -602,13 +602,16 @@ def set_dataset(self, data=None):
602602
self.Error.no_continuous()
603603
input_data = data = None
604604

605-
# Data contains some discrete attributes which must be filtered
605+
# Data contains some discrete or hidden attributes which must be
606+
# filtered
606607
if data is not None and \
607-
any(var.is_discrete for var in data.domain.attributes):
608+
any(var.is_discrete or var.attributes.get('hidden', False)
609+
for var in data.domain.attributes):
608610
ndisc = sum(var.is_discrete for var in data.domain.attributes)
609611
data = data.transform(
610612
Domain([var for var in data.domain.attributes
611-
if var.is_continuous],
613+
if var.is_continuous and
614+
not var.attributes.get('hidden', False)],
612615
data.domain.class_vars,
613616
data.domain.metas))
614617
if not data.domain.attributes:
@@ -689,7 +692,11 @@ def set_column_split_var(self, var: Optional[Variable]):
689692
def update_heatmaps(self):
690693
if self.data is not None:
691694
self.clear_scene()
692-
self.clear_messages()
695+
self.Error.clear()
696+
self.Warning.clear()
697+
self.Information.row_clust.clear()
698+
self.Information.col_clust.clear()
699+
self.Information.sampled.clear()
693700
if self.col_clustering != Clustering.None_ and \
694701
len(self.data.domain.attributes) < 2:
695702
self.Error.not_enough_features()

Orange/widgets/visualize/tests/test_owheatmap.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ def setUpClass(cls):
2929
super().setUpClass()
3030
WidgetOutputsTestMixin.init(cls)
3131

32-
cls.housing = Table("housing")
33-
cls.titanic = Table("titanic")
34-
cls.brown_selected = Table("brown-selected")
35-
3632
cls.signal_name = "Data"
3733
cls.signal_data = cls.data
3834

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

38+
self.housing = Table("housing")
39+
self.titanic = Table("titanic")
40+
self.brown_selected = Table("brown-selected")
41+
4242
def test_input_data(self):
4343
"""Check widget's data with data on the input"""
4444
for data in (self.data, self.housing):
@@ -72,6 +72,9 @@ def test_information_message(self):
7272
self.assertFalse(self.widget.Information.active)
7373
self.send_signal(self.widget.Inputs.data, data[:21])
7474
self.assertTrue(self.widget.Information.active)
75+
data = Table("heart_disease.tab")[:10]
76+
self.send_signal(self.widget.Inputs.data, data)
77+
self.assertTrue(self.widget.Information.discrete_ignored.is_shown())
7578

7679
def test_settings_changed(self):
7780
self.send_signal(self.widget.Inputs.data, self.data)
@@ -396,6 +399,14 @@ def test_col_color_annotations_with_na(self):
396399
widget.set_column_annotation_color_var(None)
397400
self.assertFalse(widget.scene.widget.top_side_colors[0].isVisible())
398401

402+
def test_data_with_hidden(self):
403+
w = self.widget
404+
housing = self.housing.copy()
405+
housing.domain.attributes[0].attributes["hidden"] = True
406+
self.send_signal(self.widget.Inputs.data, housing)
407+
self.assertEqual(len(w.effective_data.domain.attributes),
408+
len(housing.domain.attributes) - 1)
409+
399410

400411
if __name__ == "__main__":
401412
unittest.main()

0 commit comments

Comments
 (0)