Beispiel #1
0
def test_defending_points_2_conceded():
    """
    for 2 conceded, defenders and keepers should get lose 1 point
    """
    concede_probs = {0: 0.0, 1: 0.0, 2: 1.0}
    # set chance of conceding n goals as {2: 1.0} .
    assert get_defending_points("FWD", 90, concede_probs) == 0
    assert get_defending_points("MID", 90, concede_probs) == 0
    assert get_defending_points("DEF", 90, concede_probs) == -1
    assert get_defending_points("GK", 90, concede_probs) == -1
    for pos in ["DEF", "GK"]:
        assert get_defending_points(pos, 60, concede_probs) == -2 / 3
Beispiel #2
0
def test_defending_points_4_conceded():
    """
    for 4 conceded, defenders and keepers should get lose 2 points
    """
    # set chance of conceding n goals as {4: 1.0} .
    concede_probs = {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 1.0}
    assert get_defending_points("FWD", 90, concede_probs) == 0
    assert get_defending_points("MID", 90, concede_probs) == 0
    assert get_defending_points("DEF", 90, concede_probs) == -2
    assert get_defending_points("GK", 90, concede_probs) == -2
    for pos in ["DEF", "GK"]:
        assert get_defending_points(pos, 60, concede_probs) == -4 / 3
Beispiel #3
0
def test_defending_points_0_conceded():
    """
    for 0-0 draw, defenders and keepers should get clean sheet bonus
    if they were on the pitch for >= 60 mins.
    """
    # set chance of conceding n goals as {0: 1.0} .
    assert get_defending_points("FWD", 90, {0: 1.0}) == 0
    assert get_defending_points("MID", 90, {0: 1.0}) == 1
    assert get_defending_points("DEF", 90, {0: 1.0}) == 4
    assert get_defending_points("GK", 90, {0: 1.0}) == 4
    for pos in ["FWD", "MID", "DEF", "GK"]:
        assert get_defending_points(pos, 59, {0: 1.0}) == 0
def test_defending_points_4_4():
    """
    defenders and keepers lose 1 point per 2 goals conceded.
    """
    tm = DummyTeamModel({(4, 4): 1.0})
    assert get_defending_points("FWD", "dummy", "dummy", True, 90, tm) == 0
    assert get_defending_points("MID", "dummy", "dummy", True, 90, tm) == 0
    assert get_defending_points("DEF", "dummy", "dummy", True, 90, tm) == -2
    assert get_defending_points("GK", "dummy", "dummy", True, 90, tm) == -2
    for pos in ["DEF", "GK"]:
        assert get_defending_points(pos, "dummy", "dummy", True, 60,
                                    tm) == (-4 / 3)
def test_defending_points_0_0():
    """
    for 0-0 draw, defenders and keepers should get clean sheet bonus
    if they were on the pitch for >= 60 mins.
    """
    tm = DummyTeamModel({(0, 0): 1.0})
    # home or away doesn't matter
    assert get_defending_points("FWD", "dummy", "dummy", True, 90, tm) == 0
    assert get_defending_points("MID", "dummy", "dummy", True, 90, tm) == 1
    assert get_defending_points("DEF", "dummy", "dummy", True, 90, tm) == 4
    assert get_defending_points("GK", "dummy", "dummy", True, 90, tm) == 4
    for pos in ["FWD", "MID", "DEF", "GK"]:
        assert get_defending_points(pos, "dummy", "dummy", True, 59, tm) == 0
def test_defending_points_concede_0_to_4():
    """
    (Slightly) more realistic probalities - team concedes between 0 and 4
    goals with equal prob.
    """
    tm = DummyTeamModel({
        (0, 0): 0.2,
        (0, 1): 0.2,
        (0, 2): 0.2,
        (0, 3): 0.2,
        (0, 4): 0.2
    })
    assert get_defending_points("FWD", "dummy", "dummy", True, 90, tm) == 0
    assert get_defending_points("MID", "dummy", "dummy", True, 90, tm) == 0.2
    assert round(get_defending_points("DEF", "dummy", "dummy", True, 90, tm),
                 2) == 0.0
    assert round(get_defending_points("GK", "dummy", "dummy", True, 90, tm),
                 2) == 0.0
def test_defending_points_1_0():
    """
    test that out home/away logic works.
    """
    tm = DummyTeamModel({(1, 0): 1.0})
    # home
    assert get_defending_points("FWD", "dummy", "dummy", True, 90, tm) == 0
    assert get_defending_points("MID", "dummy", "dummy", True, 90, tm) == 1
    assert get_defending_points("DEF", "dummy", "dummy", True, 90, tm) == 4
    assert get_defending_points("GK", "dummy", "dummy", True, 90, tm) == 4
    for pos in ["FWD", "MID", "DEF", "GK"]:
        assert get_defending_points(pos, "dummy", "dummy", True, 59, tm) == 0
    # away
    assert get_defending_points("FWD", "dummy", "dummy", False, 90, tm) == 0
    assert get_defending_points("MID", "dummy", "dummy", False, 90, tm) == 0
    assert get_defending_points("DEF", "dummy", "dummy", False, 90, tm) == 0
    assert get_defending_points("GK", "dummy", "dummy", False, 90, tm) == 0
    for pos in ["FWD", "MID", "DEF", "GK"]:
        assert get_defending_points(pos, "dummy", "dummy", False, 59, tm) == 0