Skip to content

Commit

Permalink
Improved coverage for DiceCoefficient
Browse files Browse the repository at this point in the history
  • Loading branch information
vfdev-5 committed Jan 21, 2020
1 parent f3b6734 commit a32edb9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/ignite/metrics/test_confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,25 @@ def test_cm_with_average():
np.testing.assert_almost_equal(true_pr, res)


def test_dice_coefficient_wrong_input():

with pytest.raises(TypeError, match="Argument cm should be instance of ConfusionMatrix"):
DiceCoefficient(None)

cm = ConfusionMatrix(num_classes=10)
with pytest.raises(ValueError, match="ignore_index should be non-negative integer"):
DiceCoefficient(cm, ignore_index=-1)

with pytest.raises(ValueError, match="ignore_index should be non-negative integer"):
DiceCoefficient(cm, ignore_index="a")

with pytest.raises(ValueError, match="ignore_index should be non-negative integer"):
DiceCoefficient(cm, ignore_index=10)

with pytest.raises(ValueError, match="ignore_index should be non-negative integer"):
DiceCoefficient(cm, ignore_index=11)


def test_dice_coefficient():

y_true, y_pred = get_y_true_y_pred()
Expand Down

0 comments on commit a32edb9

Please sign in to comment.