def test_distribution_equivalent_implementation(self, num_items, num_slots): distribution = np.vstack( utils.distribute(num_items, num_slots, normalize=False)) other_implementation = _generate_prob_profiles(num_items, num_slots) np.testing.assert_array_equal( utils.sort_rows_lexicographically(distribution), utils.sort_rows_lexicographically(other_implementation))
def test_from_elo_scores(self): elo_scores = [800, 400, 400] elo_1 = 10**(800 / 400) elo_2 = 10**(400 / 400 ) # This is also the associated value for player 3. expected = np.asarray([ [2, 0, 0, 1 / 2, 0, 0], [0, 2, 0, 0, 1 / 2, 0], [0, 0, 2, 0, 0, 1 / 2], [1, 1, 0, elo_1 / (elo_1 + elo_2), elo_2 / (elo_1 + elo_2), 0], [1, 0, 1, elo_1 / (elo_1 + elo_2), 0, elo_2 / (elo_1 + elo_2)], [0, 1, 1, 0, 1 / 2, 1 / 2], ]) htp = heuristic_payoff_table.from_elo_scores(elo_scores) np.testing.assert_array_almost_equal( utils.sort_rows_lexicographically(expected), utils.sort_rows_lexicographically(htp()), verbose=True)
def test_sort_rows_lexicographically(self): array = np.asarray([ [1, 1, 0], [1, 2, 0], [3, 1, 0], [0, 0, 4], ]) expected = np.asarray([ [0, 0, 4], [1, 1, 0], [1, 2, 0], [3, 1, 0], ]) np.testing.assert_equal(expected, utils.sort_rows_lexicographically(array))