Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dustalov committed Jun 27, 2024
1 parent caeafd1 commit bfe6c85
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions python/evalica/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def test_counting(self, m: npt.NDArray[np.int64]) -> None:

@given(arrays(dtype=np.int64, shape=(5, 5), elements=st.integers(0, 256)))
def test_bradley_terry(self, m: npt.NDArray[np.int64]) -> None:
p, iterations = evalica.bradley_terry(self.M, 1e-6, 100)
p, iterations = evalica.bradley_terry(self.M, 1e-4, 100)

self.assertTrue(np.isfinite(p).all())
self.assertGreater(iterations, 0)

@given(arrays(dtype=np.int64, shape=(5, 5), elements=st.integers(0, 256)))
def test_newman(self, m: npt.NDArray[np.int64]) -> None:
p, iterations = evalica.newman(m, 0, 1e-6, 100)
p, iterations = evalica.newman(m, 0, 1e-4, 100)

self.assertTrue(np.isfinite(p).all())
self.assertGreater(iterations, 0)
Expand Down
2 changes: 1 addition & 1 deletion src/bradley_terry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod tests {
[2, 0, 1, 3, 0]
];

let tolerance = 1e-6;
let tolerance = 1e-8;
let limit = 100;

let (p, iterations) = bradley_terry(&m, tolerance, limit);
Expand Down
2 changes: 1 addition & 1 deletion src/newman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mod tests {
];

let seed = 0;
let tolerance = 1e-6;
let tolerance = 1e-8;
let limit = 100;

let (pi, iterations) = newman(&m, seed, tolerance, limit);
Expand Down
16 changes: 14 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,24 @@ mod tests {

assert_eq!(
wins,
array![[0, 1, 0, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0],]
array![
[0, 1, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
]
);

assert_eq!(
ties,
array![[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0],]
array![
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 0, 0],
]
);
}
}

0 comments on commit bfe6c85

Please sign in to comment.