Skip to content

Commit

Permalink
owheatmap: Fix inconsistent row_color_annotations
Browse files Browse the repository at this point in the history
A combo box for choosing row annotation color is limited to metas and
class vars, and thus, when a selected feature was moved from metas to
attributes, an incompatible context would match.

That did not trigger any crashes because the combo box was updated
through special functions, but it did leave the UI in an inconsistent state:
an element with index of -1 was selected in the combo (""), and, the saved
color was still shown in the map.
  • Loading branch information
markotoplak committed Feb 21, 2024
1 parent 5896dd8 commit ad7a9a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Orange/widgets/visualize/owheatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ class Outputs:
selected_data = Output("Selected Data", Table, default=True)
annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Table)

settings_version = 3
settings_version = 4

settingsHandler = settings.DomainContextHandler()
settingsHandler = settings.DomainContextHandlerPosition()

# Disable clustering for inputs bigger than this
MaxClustering = 25000
Expand All @@ -170,7 +170,7 @@ class Outputs:
#: text row annotation (row names)
annotation_var = settings.ContextSetting(None)
#: color row annotation
annotation_color_var = settings.ContextSetting(None)
annotation_color_var = settings.ContextSetting(None, exclude_attributes=True)
column_annotation_color_key: Optional[Tuple[str, str]] = settings.ContextSetting(None)

# Discrete variable used to split that data/heatmaps (vertically)
Expand Down
14 changes: 14 additions & 0 deletions Orange/widgets/visualize/tests/test_owheatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,20 @@ def test_row_color_annotations_with_na(self):
widget.set_annotation_color_var(None)
self.assertFalse(widget.scene.widget.right_side_colors[0].isVisible())

def test_row_color_annotations_invalid_context(self):
widget = self.widget
data = self.brown_selected[::5]
self.send_signal(widget.Inputs.data, data, widget=widget)
widget.set_annotation_color_var(data.domain["function"])
self.assertTrue(widget.scene.widget.right_side_colors[0].isVisible())
# attributes are ignored in for annotation_color_var, so the following
# data should not match any context
data_attributes = self.brown_selected.transform(
Domain(data.domain.attributes + data.domain.class_vars))
self.send_signal(widget.Inputs.data, data_attributes, widget=widget)
self.assertEqual(widget.row_side_color_cb.currentText(), "(None)")
self.assertFalse(widget.scene.widget.right_side_colors[0].isVisible())

def test_col_color_annotations(self):
widget = self.widget
data = self._brown_selected_10()
Expand Down

0 comments on commit ad7a9a2

Please sign in to comment.