Skip to content

Commit

Permalink
owfeaturestatistics: Do not crash on empty domain
Browse files Browse the repository at this point in the history
  • Loading branch information
lanzagar authored and janezd committed Dec 5, 2019
1 parent ad0004c commit 27d5ef3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Orange/widgets/data/owfeaturestatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ def __restore_selection(self):
def __restore_sorting(self):
"""Restore the sort column and order from saved settings."""
sort_column, sort_order = self.sorting
if self.data is not None and sort_column < self.model.columnCount():
if self.model.n_attributes and sort_column < self.model.columnCount():
self.model.sort(sort_column, sort_order)
self.table_view.horizontalHeader().setSortIndicator(sort_column, sort_order)

Expand Down
4 changes: 4 additions & 0 deletions Orange/widgets/data/tests/test_owfeaturestatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ def test_does_not_crash_on_data_removal(self):
self.send_signal(self.widget.Inputs.data, make_table(discrete))
self.send_signal(self.widget.Inputs.data, None)

def test_does_not_crash_on_empty_domain(self):
empty_data = Table('iris').transform(Domain([]))
self.send_signal(self.widget.Inputs.data, empty_data)

# No missing values
@table_dense_sparse
def test_on_data_with_no_missing_values(self, prepare_table):
Expand Down

0 comments on commit 27d5ef3

Please sign in to comment.