Ejemplo n.º 1
0
def tournament_int2str(tournament_int):
    "Convert tournament integer to string name"
    if tournament_int not in nx.tournament_numbers(active_only=True):
        raise ValueError("`tournament_int` not recognized")
    for tourney in TOURNAMENTS:
        if tourney['number'] == tournament_int:
            return tourney['name']
    raise RuntimeError("Did not find tournament name")
Ejemplo n.º 2
0
def tournament_int(tournament_int_or_str):
    "Convert tournament int or str to int"
    if nx.isstring(tournament_int_or_str):
        return tournament_str2int(tournament_int_or_str)
    elif nx.isint(tournament_int_or_str):
        numbers = nx.tournament_numbers(active_only=True)
        if tournament_int_or_str not in numbers:
            raise ValueError("`tournament_int_or_str` not recognized")
        return tournament_int_or_str
    raise ValueError('input must be a str or int')
Ejemplo n.º 3
0
def tournament_int2str(tournament_int):
    """Convert tournament integer to string name"""

    if tournament_int not in nx.tournament_numbers(active_only=False):
        value_err = "tournament_int `{}` not recognized".format(tournament_int)
        raise ValueError(value_err)

    for tourney in TOURNAMENTS:
        if tourney['number'] == tournament_int:
            return tourney['name']
    raise RuntimeError("Did not find tournament name")
Ejemplo n.º 4
0
def tournament_iter(active_only=True):
    "Iterate, in order, through tournaments yielding tuple of (int, str)"
    numbers = nx.tournament_numbers(active_only)
    numbers.sort()
    for t in numbers:
        yield t, tournament_int2str(t)