This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test uniqueness of pair objects too!
- Loading branch information
Coos Baakman
committed
Apr 1, 2021
1 parent
8d9cb1b
commit a34cb9e
Showing
1 changed file
with
18 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
from nose.tools import eq_ | ||
from nose.tools import eq_, ok_ | ||
|
||
from deeprank.models.pair import Pair | ||
|
||
|
||
def test_order_independency(): | ||
# test comparing: | ||
# These should be the same: | ||
pair1 = Pair(1, 2) | ||
pair2 = Pair(2, 1) | ||
|
||
# test comparing: | ||
eq_(pair1, pair2) | ||
|
||
# test hashing: | ||
d = {pair1: 1} | ||
d[pair2] = 2 | ||
eq_(d[pair1], 2) | ||
|
||
|
||
def test_uniqueness(): | ||
# These should be different: | ||
pair1 = Pair(1, 2) | ||
pair2 = Pair(1, 3) | ||
|
||
# test comparing: | ||
ok_(pair1 != pair2) | ||
|
||
# test hashing: | ||
d = {pair1: 1} | ||
d[pair2] = 2 | ||
eq_(d[pair1], 1) |