コード例 #1
0
ファイル: default.py プロジェクト: afcarl/chaseplan
def fow():
    """
        Fall of wickets in range of 5 overs in the chasing innings
    """

    final_json = parse.get_match_json(request.folder)
    final_fow = [0] * 10
    for match_id in final_json:
        overs = final_json[match_id]["overs"]
        wickets = [0] * 51
        for over in overs:
            wickets[int(over)] = overs[over]["wicket2"]
        new_wickets = [0] * 51
        for wicket in xrange(1, len(wickets)):
            if wickets[wicket] is None:
                break
            new_wickets[wicket] = wickets[wicket] - wickets[wicket - 1]
            if new_wickets[wicket] < 0:
                new_wickets[wicket] = 0
        i = 1
        fow = []
        while i <= 46:
            fow.append(sum(new_wickets[i:i + 5]))
            i += 5
        final_fow = map(lambda x, y: x + y, final_fow, fow)

    final_fow = map(lambda x: x * 1.0 / len(final_json), final_fow)
    return dict(fow=final_fow)
コード例 #2
0
ファイル: default.py プロジェクト: afcarl/chaseplan
def get_matches():
    plot_type = request.vars.get("type", 1)
    final_json = parse.get_match_json(request.folder, int(plot_type))
    return dict(matches=final_json)