<commit_before>import numpy as np
import pytest
import timeout_decorator
from gameanalysis import gamegen
from gameanalysis import paygame
from gameanalysis import rsgame

from egta import gamesched
from egta import innerloop
from egta import savesched
from egta import schedgame
from egta import trace
from test import utils


games = [
    ([1], [2]),
    ([2], [2]),
    ([2, 1], [1, 2]),
    ([1, 2], [2, 1]),
    ([2, 2], [2, 2]),
    ([3, 2], [2, 3]),
    ([1, 1, 1], [2, 2, 2]),
]


def verify_complete_traces(traces):
    """Verify that traces are in order and complete"""
    t = 0.0
    for (first, *_, last), _ in traces:
        assert first <= t
        t = max(t, last)
    assert t == 1.0


# These sometimes take a really long time because of at_least_one and many
# innerloops. If it takes more than a minute, just give up.
@utils.warnings_filter(RuntimeWarning)
@timeout_decorator.timeout(60)
@pytest.mark.xfail(raises=timeout_decorator.timeout_decorator.TimeoutError)
@pytest.mark.parametrize('players,strats', games)
@pytest.mark.parametrize('_', range(5))
def test_random_trace_game(players, strats, _):
    game1 = gamegen.game(players, strats)
    game2 = gamegen.game(players, strats)
    traces = trace.trace_equilibria(game1, game2, at_least_one=True)
    verify_complete_traces(traces)


# These sometimes take a really long time because of at_least_one and many
# innerloops. If it takes more than a minute, just give up.
@utils.warnings_filter(RuntimeWarning)
@timeout_decorator.timeout(60)
@pytest.mark.xfail(raises=timeout_decorator.timeout_decorator.TimeoutError)
@pytest.mark.parametrize('players,strats', games)<commit_msg>Decrease timeout<commit_after>import numpy as np
import pytest
import timeout_decorator
from gameanalysis import gamegen
from gameanalysis import paygame
from gameanalysis import rsgame

from egta import gamesched
from egta import innerloop
from egta import savesched
from egta import schedgame
from egta import trace
from test import utils


games = [
    ([1], [2]),
    ([2], [2]),
    ([2, 1], [1, 2]),
    ([1, 2], [2, 1]),
    ([2, 2], [2, 2]),
    ([3, 2], [2, 3]),
    ([1, 1, 1], [2, 2, 2]),
]


def verify_complete_traces(traces):
    """Verify that traces are in order and complete"""
    t = 0.0
    for (first, *_, last), _ in traces:
        assert first <= t
        t = max(t, last)
    assert t == 1.0


# These sometimes take a really long time because of at_least_one and many
# innerloops. If it takes more than a minute, just give up.
@utils.warnings_filter(RuntimeWarning)
@timeout_decorator.timeout(20)
@pytest.mark.xfail(raises=timeout_decorator.timeout_decorator.TimeoutError)
@pytest.mark.parametrize('players,strats', games)
@pytest.mark.parametrize('_', range(5))
def test_random_trace_game(players, strats, _):
    game1 = gamegen.game(players, strats)
    game2 = gamegen.game(players, strats)
    traces = trace.trace_equilibria(game1, game2, at_least_one=True)
    verify_complete_traces(traces)


# These sometimes take a really long time because of at_least_one and many
# innerloops. If it takes more than a minute, just give up.
@utils.warnings_filter(RuntimeWarning)
@timeout_decorator.timeout(20)
@pytest.mark.xfail(raises=timeout_decorator.timeout_decorator.TimeoutError)
@pytest.mark.parametrize('players,strats', games)
{'fraction_non_alphanumeric': 0.11757612300271329, 'fraction_numerical': 0.02351522460054266, 'mean_word_length': 4.567114093959732, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2597229', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1138, 'n_words': 338}