Skip to content

Commit 76a3d28

Browse files
committed
Barplot: Fix annotation by enumeration
1 parent e75f21c commit 76a3d28

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Orange/widgets/visualize/owbarplot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,10 @@ def get_labels(self) -> Optional[Union[List, np.ndarray]]:
572572
elif not self.annot_var:
573573
return []
574574
elif self.annot_var == self.enumeration:
575-
return np.arange(1, len(self.data) + 1)[self.grouped_indices]
575+
return [
576+
str(x)
577+
for x in np.arange(1, len(self.data) + 1)[self.grouped_indices]
578+
]
576579
else:
577580
return [self.annot_var.str_val(row[self.annot_var])
578581
for row in self.grouped_data]

Orange/widgets/visualize/tests/test_owbarplot.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,21 @@ def test_group_axis(self):
137137
self.assertFalse(group_axis.isVisible())
138138
self.assertFalse(annot_axis.isVisible())
139139

140+
def test_annotate_by_enumeration(self):
141+
widget = self.widget
142+
143+
self.send_signal(widget.Inputs.data, self.data)
144+
combo = widget.controls.annot_var
145+
for i in range(combo.count()):
146+
try:
147+
simulate.combobox_activate_index(combo, i)
148+
except AssertionError: # skip disabled items
149+
pass
150+
else:
151+
labels = widget.get_labels()
152+
self.assertTrue(not labels
153+
or all(isinstance(x, str) for x in labels))
154+
140155
def test_datasets(self):
141156
controls = self.widget.controls
142157
for ds in datasets.datasets():

0 commit comments

Comments
 (0)