Skip to content

Commit

Permalink
Merge pull request #73 from CompML/features/#41/unit_test_for_recall
Browse files Browse the repository at this point in the history
add unit tests for update_recall
  • Loading branch information
nocotan authored Mar 3, 2021
2 parents a8adb79 + 102d7e2 commit d1de23a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ def test_RecallClass_score(self):
with self.assertRaises(Exception):
score = obj.score(real, pred)

def test_RecallClass_update_recall(self):
"""Test of _update_recall function.
"""

# test of the normal case
real = np.array([0, 1, 0, 0, 0])
pred = np.array([1, 1, 0, 0, 0])

obj = TimeSeriesRecall()
real_anomalies, predicted_anomalies = obj._prepare_data(real, pred)

score = obj._update_recall(real_anomalies, predicted_anomalies)
self.assertEqual(score, 1.0)

# test of the empty case
empty_real = np.array([])
empty_pred = np.array([])

score = obj._update_recall(empty_real, empty_pred)
self.assertEqual(score, 0.0)

def test_recall_function(self):
"""Test of ts_recall function.
"""
Expand Down

0 comments on commit d1de23a

Please sign in to comment.