Skip to content

Commit

Permalink
Merge pull request #6270 from janezd/barplot-annotation-enumerate
Browse files Browse the repository at this point in the history
[FIX] Bar Plot: Fix annotation by enumeration
  • Loading branch information
markotoplak authored Dec 23, 2022
2 parents f1fcd72 + 76a3d28 commit d352fe2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Orange/widgets/visualize/owbarplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,10 @@ def get_labels(self) -> Optional[Union[List, np.ndarray]]:
elif not self.annot_var:
return []
elif self.annot_var == self.enumeration:
return np.arange(1, len(self.data) + 1)[self.grouped_indices]
return [
str(x)
for x in np.arange(1, len(self.data) + 1)[self.grouped_indices]
]
else:
return [self.annot_var.str_val(row[self.annot_var])
for row in self.grouped_data]
Expand Down
15 changes: 15 additions & 0 deletions Orange/widgets/visualize/tests/test_owbarplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ def test_group_axis(self):
self.assertFalse(group_axis.isVisible())
self.assertFalse(annot_axis.isVisible())

def test_annotate_by_enumeration(self):
widget = self.widget

self.send_signal(widget.Inputs.data, self.data)
combo = widget.controls.annot_var
for i in range(combo.count()):
try:
simulate.combobox_activate_index(combo, i)
except AssertionError: # skip disabled items
pass
else:
labels = widget.get_labels()
self.assertTrue(not labels
or all(isinstance(x, str) for x in labels))

def test_datasets(self):
controls = self.widget.controls
for ds in datasets.datasets():
Expand Down

0 comments on commit d352fe2

Please sign in to comment.