Skip to content

Commit

Permalink
Merge pull request #2399 from jerneju/load-empty-data-paintdata
Browse files Browse the repository at this point in the history
[FIX] Paint Data: Fix crash on empty data
  • Loading branch information
lanzagar authored Jun 16, 2017
2 parents 625ff36 + 86ff3d6 commit 6cd35ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Orange/widgets/data/owpaintdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def __init__(self):
self.class_model.rowsInserted.connect(self._class_count_changed)
self.class_model.rowsRemoved.connect(self._class_count_changed)

if self.data is None:
if not self.data:
self.data = []
self.__buffer = np.zeros((0, 3))
elif isinstance(self.data, np.ndarray):
Expand Down
7 changes: 7 additions & 0 deletions Orange/widgets/data/tests/test_owpaintdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,10 @@ def test_sparse_data(self):
self.assertTrue(self.widget.Warning.sparse_not_supported.is_shown())
self.send_signal("Data", None)
self.assertFalse(self.widget.Warning.sparse_not_supported.is_shown())

def test_load_empty_data(self):
"""
It should not crash when old workflow with no data is loaded.
GH-2399
"""
self.create_widget(OWPaintData, stored_settings={"data": []})

0 comments on commit 6cd35ad

Please sign in to comment.