Skip to content

Commit

Permalink
The test case pass for vary ordering due to identical scores
Browse files Browse the repository at this point in the history
  • Loading branch information
lthoang committed May 21, 2024
1 parent 55e7f2e commit 63d2e10
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/cornac/models/test_recommender.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

import sys; sys.path.append('./')
import unittest

from cornac.data import BasketDataset, Dataset, SequentialDataset, Reader
Expand Down Expand Up @@ -85,7 +85,10 @@ def test_fit(self):
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((result[0][3:5] == [0, 1]).any()) # identical scores, sorting may affect the ordering
self.assertTrue((result[0][5:6] == [5]).all())
self.assertTrue((result[0][6:9] == [8, 7, 6]).any()) # identical scores, sorting may affect the ordering


if __name__ == "__main__":
Expand Down

0 comments on commit 63d2e10

Please sign in to comment.