Skip to content

Commit

Permalink
Calibration plot: Fix crash for Results without folds
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Feb 25, 2022
1 parent 5c5c3be commit 0cefc17
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Orange/widgets/evaluate/owcalibrationplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def commit(self):
if results is not None:
problems = [
msg for condition, msg in (
(len(results.folds) > 1,
(results.folds is not None and len(results.folds) > 1,
"each training data sample produces a different model"),
(results.models is None,
"test results do not contain stored models - try testing "
Expand Down
17 changes: 17 additions & 0 deletions Orange/widgets/evaluate/tests/test_owcalibrationplot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
import warnings
import unittest
from unittest.mock import Mock, patch

import numpy as np
Expand Down Expand Up @@ -637,3 +638,19 @@ def test_warn_nan_probabilities(self, *_):
self.assertTrue(widget.Warning.omitted_nan_prob_points.is_shown())
self._set_list_selection(widget.controls.selected_classifiers, [0, 2])
self.assertFalse(widget.Warning.omitted_folds.is_shown())

@patch("Orange.widgets.evaluate.owcalibrationplot.ThresholdClassifier")
@patch("Orange.widgets.evaluate.owcalibrationplot.CalibratedLearner")
def test_no_folds(self, *_):
"""Warn about omitted points with nan probabiities"""
widget = self.widget

self.results.folds = None
self.send_signal(widget.Inputs.evaluation_results, self.results)
widget.selected_classifiers = [0]
widget.commit.now()
self.assertIsNotNone(self.get_output(widget.Outputs.calibrated_model))


if __name__ == "__main__":
unittest.main()

0 comments on commit 0cefc17

Please sign in to comment.