Skip to content
Snippets Groups Projects
Unverified Commit cd5c63f8 authored by Trung-Hoang Le's avatar Trung-Hoang Le Committed by GitHub
Browse files

Fix failed test case due to different ordering caused by identical scores (#622)

parent 55e7f2e6
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@
import unittest
import numpy as np
from cornac.data import BasketDataset, Dataset, SequentialDataset, Reader
from cornac.models import MF, GPTop, SPop, NextBasketRecommender, NextItemRecommender
......@@ -85,7 +87,10 @@ class TestNextItemRecommender(unittest.TestCase):
model.fit(dataset)
model.score(0, [])
result = model.rank(0, history_items=[])
self.assertTrue((result[0] == [3, 2, 4, 1, 0, 5, 8, 7, 6]).all())
self.assertTrue((result[0][0:3] == [3, 2, 4]).all())
self.assertTrue((np.sort(result[0][3:5]) == [0, 1]).all()) # identical scores, sorting may affect the ordering
self.assertTrue((result[0][5:6] == [5]).all())
self.assertTrue((np.sort(result[0][6:9]) == [6, 7, 8]).all()) # identical scores, sorting may affect the ordering
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment