Example #1
0
def test_putback_no_prev_event_false():
    event = {
        "EVENTNUM": 21,
        "PCTIMESTRING": "09:31",
        "VISITORDESCRIPTION": "Bogdanovic 2' Driving Layup (2 PTS)",
        "EVENTMSGACTIONTYPE": 42,
        "EVENTMSGTYPE": 1,
        "PLAYER1_ID": 202711,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    fg_event.previous_event = None
    assert fg_event.is_putback is False
Example #2
0
def test_shot_type_arc3():
    event = {
        "EVENTNUM": 20,
        "PCTIMESTRING": "09:57",
        "HOMEDESCRIPTION": "Rose  3PT Jump Shot (5 PTS) (Anthony 1 AST)",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 1,
        "PLAYER1_ID": 201565,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": "2546",
        "PLAYER2_TEAM_ID": 1610612752,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    fg_event.locX = -230
    fg_event.locY = 100
    assert fg_event.shot_type == pbpstats.ARC_3_STRING
Example #3
0
def test_corner3_false():
    event = {
        "EVENTNUM": 20,
        "PCTIMESTRING": "09:57",
        "HOMEDESCRIPTION": "Rose  3PT Jump Shot (5 PTS) (Anthony 1 AST)",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 1,
        "PLAYER1_ID": 201565,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": "2546",
        "PLAYER2_TEAM_ID": 1610612752,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    fg_event.locX = -230
    fg_event.locY = 100
    assert fg_event.is_corner_3 is False
Example #4
0
def test_distance_with_coords():
    event = {
        "EVENTNUM": 115,
        "PCTIMESTRING": "00:46",
        "HOMEDESCRIPTION": "MISS Anthony Jump Shot",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 2546,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    fg_event.locX = -100
    fg_event.locY = 150
    assert fg_event.distance == 18
Example #5
0
def test_is_make_that_does_not_end_possession_with_lane_violation_true():
    make = {
        "EVENTMSGTYPE": 1,
        "EVENTMSGACTIONTYPE": 10,
        "PLAYER1_ID": 15,
        "PLAYER1_TEAM_ID": 1,
        "HOMEDESCRIPTION": "Made Shot",
        "PCTIMESTRING": "0:45",
        "EVENTNUM": 1,
    }
    order = 1
    make_event = StatsFieldGoal(make, order)
    foul = {
        "EVENTMSGTYPE": 6,
        "EVENTMSGACTIONTYPE": 2,
        "VISITORDESCRIPTION": "Shooting Foul",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 2,
        "PLAYER1_ID": 12,
        "PLAYER2_ID": 15,
        "EVENTNUM": 2,
    }
    order = 1
    foul_event = StatsFoul(foul, order)
    lane_violation = {
        "EVENTMSGTYPE": 5,
        "EVENTMSGACTIONTYPE": 17,
        "HOMEDESCRIPTION": "Lane Violation Turnover",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 1,
        "PLAYER1_ID": 15,
        "PLAYER2_ID": None,
        "EVENTNUM": 3,
    }
    order = 1
    lane_violation_event = StatsTurnover(lane_violation, order)
    make_event.previous_event = None
    make_event.next_event = foul_event
    foul_event.previous_event = make_event
    foul_event.next_event = lane_violation_event
    lane_violation_event.previous_event = foul_event
    lane_violation_event.next_event = None
    assert make_event.is_make_that_does_not_end_possession is True
Example #6
0
def test_is_make_that_does_not_end_possession_with_foul_out_of_order_true():
    make = {
        "EVENTMSGTYPE": 1,
        "EVENTMSGACTIONTYPE": 10,
        "PLAYER1_ID": 15,
        "PLAYER1_TEAM_ID": 1,
        "HOMEDESCRIPTION": "Made Shot",
        "PCTIMESTRING": "0:45",
        "EVENTNUM": 1,
    }
    order = 1
    make_event = StatsFieldGoal(make, order)
    ft = {
        "EVENTMSGTYPE": 3,
        "EVENTMSGACTIONTYPE": 10,
        "HOMEDESCRIPTION": "Free Throw 1 of 1",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 1,
        "PLAYER1_ID": 15,
        "EVENTNUM": 2,
    }
    order = 1
    ft_event = StatsFreeThrow(ft, order)
    foul = {
        "EVENTMSGTYPE": 6,
        "EVENTMSGACTIONTYPE": 2,
        "VISITORDESCRIPTION": "Shooting Foul",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 2,
        "PLAYER1_ID": 12,
        "PLAYER2_ID": 15,
        "EVENTNUM": 3,
    }
    order = 1
    foul_event = StatsFoul(foul, order)
    make_event.previous_event = None
    make_event.next_event = ft_event
    ft_event.previous_event = make_event
    ft_event.next_event = foul_event
    foul_event.previous_event = ft_event
    foul_event.next_event = None
    assert make_event.is_make_that_does_not_end_possession is True
Example #7
0
def test_foul_on_made_shot_by_team_that_didnt_get_fouled_is_away_from_play_ft(
):
    ft = {
        "EVENTMSGTYPE": 3,
        "EVENTMSGACTIONTYPE": 10,
        "HOMEDESCRIPTION": "Free Throw 1 of 1",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 1,
        "PLAYER1_ID": 1,
    }
    order = 1
    ft_event = StatsFreeThrow(ft, order)
    foul = {
        "EVENTMSGTYPE": 6,
        "EVENTMSGACTIONTYPE": 6,
        "VISITORDESCRIPTION": "Away From Play Foul",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 2,
        "PLAYER1_ID": 2,
        "PLAYER2_ID": 1,
    }
    order = 1
    foul_event = StatsFoul(foul, order)
    make = {
        "EVENTMSGTYPE": 1,
        "EVENTMSGACTIONTYPE": 10,
        "HOMEDESCRIPTION": "Made Shot by team that got fouled",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 2,
        "PLAYER1_ID": 3,
    }
    order = 1
    make_event = StatsFieldGoal(make, order)
    ft_event.previous_event = None
    ft_event.next_event = foul_event
    foul_event.previous_event = ft_event
    foul_event.next_event = make_event
    make_event.previous_event = foul_event
    make_event.next_event = None
    assert ft_event.is_away_from_play_ft is True
Example #8
0
def test_away_from_play_free_throw_type():
    foul = {
        "EVENTMSGTYPE": 6,
        "EVENTMSGACTIONTYPE": 6,
        "VISITORDESCRIPTION": "Away From Play Foul",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 2,
        "PLAYER1_ID": 2,
        "PLAYER2_ID": 1,
    }
    order = 1
    foul_event = StatsFoul(foul, order)
    ft = {
        "EVENTMSGTYPE": 3,
        "EVENTMSGACTIONTYPE": 10,
        "HOMEDESCRIPTION": "Free Throw 1 of 1",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 1,
        "PLAYER1_ID": 1,
    }
    order = 1
    ft_event = StatsFreeThrow(ft, order)
    make = {
        "EVENTMSGTYPE": 1,
        "EVENTMSGACTIONTYPE": 10,
        "VISITORDESCRIPTION": "Made Shot by team that got fouled",
        "PCTIMESTRING": "0:35",
        "PLAYER1_TEAM_ID": 1,
        "PLAYER1_ID": 21,
    }
    order = 1
    make_event = StatsFieldGoal(make, order)
    foul_event.previous_event = None
    foul_event.next_event = ft_event
    ft_event.previous_event = foul_event
    ft_event.next_event = make_event
    make_event.previous_event = ft_event
    make_event.next_event = None
    assert ft_event.free_throw_type == "1 Shot Away From Play"
Example #9
0
def test_placeholder_rebound_event_on_miss_returns_none():
    event = {
        "EVENTNUM": 61,
        "PCTIMESTRING": "05:21",
        "VISITORDESCRIPTION": "MISS Hollis-Jefferson 1' Layup",
        "EVENTMSGACTIONTYPE": 5,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 1626178,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)

    rebound = {
        "EVENTNUM": 62,
        "PCTIMESTRING": "05:20",
        "HOMEDESCRIPTION": "Knicks Rebound",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 4,
        "PLAYER1_ID": 0,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 2
    rebound_event = StatsRebound(rebound, order)

    fg_event.next_event = rebound_event
    rebound_event.previous_event = fg_event
    rebound_event.next_event = None
    assert fg_event.rebound is None
Example #10
0
def test_putback_reb_by_different_player_false():
    miss = {
        "EVENTMSGTYPE": 2,
        "PCTIMESTRING": "1:06",
        "PLAYER1_ID": 12,
        "PLAYER1_TEAM_ID": 1,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    miss_event = StatsFieldGoal(miss, order)
    rebound = {
        "EVENTMSGTYPE": 4,
        "EVENTMSGACTIONTYPE": 0,
        "PCTIMESTRING": "1:03",
        "PLAYER1_ID": 13,
        "PLAYER1_TEAM_ID": 1,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    rebound_event = StatsRebound(rebound, order)
    make = {
        "EVENTMSGTYPE": 1,
        "PCTIMESTRING": "1:02",
        "PLAYER1_ID": 12,
        "PLAYER1_TEAM_ID": 1,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    make_event = StatsFieldGoal(make, order)
    miss_event.previous_event = None
    miss_event.next_event = rebound_event
    rebound_event.previous_event = miss_event
    rebound_event.next_event = make_event
    make_event.previous_event = rebound_event
    make_event.next_event = None
    assert make_event.is_putback is False
Example #11
0
def test_shot_type_at_rim():
    event = {
        "EVENTNUM": 61,
        "PCTIMESTRING": "05:21",
        "VISITORDESCRIPTION": "MISS Hollis-Jefferson 1' Layup",
        "EVENTMSGACTIONTYPE": 5,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 1626178,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.shot_type == pbpstats.AT_RIM_STRING
Example #12
0
def test_putback_3pt_false():
    event = {
        "EVENTNUM": 20,
        "PCTIMESTRING": "09:57",
        "HOMEDESCRIPTION": "Rose  3PT Jump Shot (5 PTS) (Anthony 1 AST)",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 1,
        "PLAYER1_ID": 201565,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": 2546,
        "PLAYER2_TEAM_ID": 1610612752,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.is_putback is False
Example #13
0
def test_stats_field_goal_2_shot_value_is_2():
    item = {
        "EVENTNUM": 14,
        "PCTIMESTRING": "10:34",
        "VISITORDESCRIPTION": "MISS Bogdanovic 2' Layup",
        "EVENTMSGACTIONTYPE": 5,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 202711,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg = StatsFieldGoal(item, order)
    assert fg.shot_value == 2
Example #14
0
def test_made_false():
    event = {
        "EVENTNUM": 14,
        "PCTIMESTRING": "10:34",
        "VISITORDESCRIPTION": "MISS Bogdanovic 2' Layup",
        "EVENTMSGACTIONTYPE": 5,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 202711,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.is_made is False
Example #15
0
def test_stats_field_goal_3_shot_value_is_3():
    item = {
        "EVENTNUM": 20,
        "PCTIMESTRING": "09:57",
        "HOMEDESCRIPTION": "Rose  3PT Jump Shot (5 PTS) (Anthony 1 AST)",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 1,
        "PLAYER1_ID": 201565,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": "2546",
        "PLAYER2_TEAM_ID": 1610612752,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg = StatsFieldGoal(item, order)
    assert fg.shot_value == 3
Example #16
0
def test_shot_type_long_mid_range():
    event = {
        "EVENTNUM": 61,
        "PCTIMESTRING": "05:21",
        "VISITORDESCRIPTION": "MISS Hollis-Jefferson 19' Jump Shot",
        "EVENTMSGACTIONTYPE": 5,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 1626178,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.shot_type == pbpstats.LONG_MID_RANGE_STRING
Example #17
0
def test_blocked_false():
    event = {
        "EVENTNUM": 61,
        "PCTIMESTRING": "05:21",
        "VISITORDESCRIPTION": "MISS Hollis-Jefferson 1' Layup",
        "EVENTMSGACTIONTYPE": 5,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 1626178,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.is_blocked is False
Example #18
0
def test_heave_true():
    event = {
        "EVENTNUM": 20,
        "PCTIMESTRING": "00:01",
        "HOMEDESCRIPTION": "Rose 45' 3PT Jump Shot (5 PTS) (Anthony 1 AST)",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 1,
        "PLAYER1_ID": 201565,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": 2546,
        "PLAYER2_TEAM_ID": 1610612752,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.is_heave is True
Example #19
0
def test_distance_no_coords_or_description_returns_none():
    event = {
        "EVENTNUM": 115,
        "PCTIMESTRING": "00:46",
        "HOMEDESCRIPTION": "MISS Anthony Jump Shot",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 2546,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.distance is None
Example #20
0
def test_shot_type_unknown():
    event = {
        "EVENTNUM": 61,
        "PCTIMESTRING": "05:21",
        "VISITORDESCRIPTION": "MISS Hollis-Jefferson Jump Shot",
        "EVENTMSGACTIONTYPE": 5,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 1626178,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.shot_type == pbpstats.UNKNOWN_SHOT_DISTANCE_STRING
Example #21
0
def test_made_true():
    event = {
        "EVENTNUM": 21,
        "PCTIMESTRING": "09:31",
        "VISITORDESCRIPTION": "Bogdanovic 2' Driving Layup (2 PTS)",
        "EVENTMSGACTIONTYPE": 42,
        "EVENTMSGTYPE": 1,
        "PLAYER1_ID": 202711,
        "PLAYER1_TEAM_ID": 1610612751,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.is_made is True
Example #22
0
def test_blocked_true():
    event = {
        "EVENTNUM": 59,
        "PCTIMESTRING": "05:27",
        "HOMEDESCRIPTION": "MISS Porzingis 3' Layup",
        "VISITORDESCRIPTION": "Lopez BLOCK (1 BLK)",
        "EVENTMSGACTIONTYPE": 5,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 204001,
        "PLAYER1_TEAM_ID": 1610612752,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": 201572,
        "PLAYER3_TEAM_ID": 1610612751,
    }
    order = 1
    fg_event = StatsFieldGoal(event, order)
    assert fg_event.is_blocked is True
Example #23
0
def test_jump_ball_turnover_next_event_not_possession_change():
    shot = {
        "GAME_ID": "0021900510",
        "EVENTNUM": 225,
        "PCTIMESTRING": "6:40",
        "VISITORDESCRIPTION": "MISS Lowry  3PT Jump Shot",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 200768,
        "PLAYER1_TEAM_ID": 1610612761,
    }
    order = 1
    shot_event = StatsFieldGoal(shot, order)
    rebound = {
        "GAME_ID": "0021900510",
        "EVENTNUM": 226,
        "PCTIMESTRING": "6:38",
        "HOMEDESCRIPTION": "Silva REBOUND (Off:0 Def:1)",
        "EVENTMSGACTIONTYPE": 0,
        "EVENTMSGTYPE": 4,
        "PLAYER1_ID": 1629735,
        "PLAYER1_TEAM_ID": 1610612748,
    }
    order = 1
    rebound_event = StatsRebound(rebound, order)
    jump_ball = {
        "GAME_ID": "0021900510",
        "EVENTNUM": 228,
        "PCTIMESTRING": "6:29",
        "HOMEDESCRIPTION": "Jump Ball Silva vs. Boucher: Tip to Johnson",
        "EVENTMSGACTIONTYPE": 0,
        "EVENTMSGTYPE": 10,
        "PLAYER1_ID": 1629735,
        "PLAYER1_TEAM_ID": 1610612748,
        "PLAYER2_ID": 1628449,
        "PLAYER2_TEAM_ID": 1610612761,
        "PLAYER3_ID": 1626169,
        "PLAYER3_TEAM_ID": 1610612761,
    }
    order = 1
    jump_ball_event = StatsJumpBall(jump_ball, order)
    turnover = {
        "GAME_ID": "0021900510",
        "EVENTNUM": 233,
        "PCTIMESTRING": "6:29",
        "VISITORDESCRIPTION": "Boucher STEAL (1 STL)",
        "HOMEDESCRIPTION": "Silva Lost Ball Turnover (P1.T5)",
        "EVENTMSGACTIONTYPE": 2,
        "EVENTMSGTYPE": 5,
        "PLAYER1_ID": 1629735,
        "PLAYER1_TEAM_ID": 1610612748,
        "PLAYER2_ID": 1628449,
        "PLAYER2_TEAM_ID": 1610612761,
    }
    order = 1
    turnover_event = StatsTurnover(turnover, order)

    shot_event.previous_event = None
    shot_event.next_event = rebound_event
    rebound_event.previous_event = shot_event
    rebound_event.next_event = jump_ball_event
    jump_ball_event.previous_event = rebound_event
    jump_ball_event.next_event = turnover_event
    turnover_event.previous_event = jump_ball_event
    turnover_event.next_event = None

    jump_ball_event.possession_changing_override = False
    jump_ball_event.non_possession_changing_override = False

    assert jump_ball_event.is_possession_ending_event is False
Example #24
0
def test_foul_on_made_ft_by_team_that_didnt_get_fouled_is_away_from_play_ft():
    ft_2_of_2 = {
        "EVENTNUM": 607,
        "PCTIMESTRING": "0:25",
        "VISITORDESCRIPTION": "Jackson Free Throw 2 of 2 (16 PTS)",
        "EVENTMSGACTIONTYPE": 12,
        "EVENTMSGTYPE": 3,
        "PLAYER1_ID": 202704,
        "PLAYER1_TEAM_ID": 1610612765,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    ft_2_of_2_event = StatsFreeThrow(ft_2_of_2, order)
    foul = {
        "EVENTNUM": 609,
        "PCTIMESTRING": "0:25",
        "VISITORDESCRIPTION": "Griffin AWAY.FROM.PLAY.FOUL (P5.PN) (M.Davis)",
        "EVENTMSGACTIONTYPE": 6,
        "EVENTMSGTYPE": 6,
        "PLAYER1_ID": 201933,
        "PLAYER1_TEAM_ID": 1610612765,
        "PLAYER2_ID": 201145,
        "PLAYER2_TEAM_ID": 1610612764,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    foul_event = StatsFoul(foul, order)
    ft_1_of_1 = {
        "EVENTNUM": 611,
        "PCTIMESTRING": "0:25",
        "HOMEDESCRIPTION": "Beal Free Throw 1 of 1 (32 PTS)",
        "EVENTMSGACTIONTYPE": 10,
        "EVENTMSGTYPE": 3,
        "PLAYER1_ID": 203078,
        "PLAYER1_TEAM_ID": 1610612764,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    ft_1_of_1_event = StatsFreeThrow(ft_1_of_1, order)
    fg = {
        "EVENTNUM": 612,
        "PCTIMESTRING": "0:24",
        "VISITORDESCRIPTION": "MISS Green 27' 3PT Jump Shot",
        "EVENTMSGACTIONTYPE": 1,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 201145,
        "PLAYER1_TEAM_ID": 1610612764,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    fg_event = StatsFieldGoal(fg, order)
    ft_2_of_2_event.previous_event = None
    ft_2_of_2_event.next_event = foul_event
    foul_event.previous_event = ft_2_of_2_event
    foul_event.next_event = ft_1_of_1_event
    ft_1_of_1_event.previous_event = foul_event
    ft_1_of_1_event.next_event = fg_event
    fg_event.previous_event = ft_1_of_1_event
    fg_event.next_event = None
    assert ft_1_of_1_event.is_away_from_play_ft is True
Example #25
0
def test_putback_goaltend_true():
    miss = {
        "EVENTNUM": 781,
        "PCTIMESTRING": "01:14",
        "VISITORDESCRIPTION": "MISS Shamet 7' Driving Floating Jump Shot",
        "EVENTMSGACTIONTYPE": 101,
        "EVENTMSGTYPE": 2,
        "PLAYER1_ID": 1629013,
        "PLAYER1_TEAM_ID": 1610612755,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    miss_event = StatsFieldGoal(miss, order)
    rebound = {
        "EVENTNUM": 783,
        "PCTIMESTRING": "01:13",
        "VISITORDESCRIPTION": "Muscala REBOUND (Off:1 Def:3)",
        "EVENTMSGACTIONTYPE": 0,
        "EVENTMSGTYPE": 4,
        "PLAYER1_ID": 203488,
        "PLAYER1_TEAM_ID": 1610612755,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    rebound_event = StatsRebound(rebound, order)
    goaltend = {
        "EVENTNUM": 785,
        "PCTIMESTRING": "01:12",
        "HOMEDESCRIPTION":
        "DiVincenzo Violation:Defensive Goaltending (N.Buchert)",
        "EVENTMSGACTIONTYPE": 2,
        "EVENTMSGTYPE": 7,
        "PLAYER1_ID": 1628978,
        "PLAYER1_TEAM_ID": 1610612749,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    goaltend_event = StatsViolation(goaltend, order)
    make = {
        "EVENTNUM": 784,
        "PCTIMESTRING": "01:12",
        "VISITORDESCRIPTION": "Muscala 1' Tip Layup Shot (8 PTS)",
        "EVENTMSGACTIONTYPE": 97,
        "EVENTMSGTYPE": 1,
        "PLAYER1_ID": 203488,
        "PLAYER1_TEAM_ID": 1610612755,
        "PLAYER2_ID": None,
        "PLAYER2_TEAM_ID": None,
        "PLAYER3_ID": None,
        "PLAYER3_TEAM_ID": None,
    }
    order = 1
    make_event = StatsFieldGoal(make, order)
    miss_event.previous_event = None
    miss_event.next_event = rebound_event
    rebound_event.previous_event = miss_event
    rebound_event.next_event = goaltend_event
    goaltend_event.previous_event = rebound_event
    goaltend_event.next_event = make_event
    make_event.previous_event = goaltend_event
    make_event.next_event = None
    assert make_event.is_putback is True
Example #26
0
def test_is_make_that_does_not_end_possession_shot_at_time_of_and1_ft_is_false(
):
    make = {
        "EVENTMSGTYPE": 1,
        "EVENTMSGACTIONTYPE": 10,
        "PLAYER1_ID": 15,
        "PLAYER1_TEAM_ID": 1,
        "HOMEDESCRIPTION": "Made Shot",
        "PCTIMESTRING": "0:45",
        "EVENTNUM": 1,
    }
    order = 1
    make_event = StatsFieldGoal(make, order)
    foul = {
        "EVENTMSGTYPE": 6,
        "EVENTMSGACTIONTYPE": 2,
        "VISITORDESCRIPTION": "Shooting Foul",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 2,
        "PLAYER1_ID": 12,
        "PLAYER2_ID": 15,
        "EVENTNUM": 2,
    }
    order = 1
    foul_event = StatsFoul(foul, order)
    ft = {
        "EVENTMSGTYPE": 3,
        "EVENTMSGACTIONTYPE": 10,
        "HOMEDESCRIPTION": "Free Throw 1 of 1",
        "PCTIMESTRING": "0:45",
        "PLAYER1_TEAM_ID": 1,
        "PLAYER1_ID": 15,
        "EVENTNUM": 3,
    }
    order = 1
    ft_event = StatsFreeThrow(ft, order)
    rebound = {
        "EVENTMSGTYPE": 4,
        "EVENTMSGACTIONTYPE": 0,
        "PLAYER1_ID": 17,
        "PLAYER1_TEAM_ID": 1,
        "HOMEDESCRIPTION": "Rebound",
        "PCTIMESTRING": "0:45",
        "EVENTNUM": 4,
    }
    order = 2
    rebound_event = StatsRebound(rebound, order)
    tip = {
        "EVENTMSGTYPE": 1,
        "EVENTMSGACTIONTYPE": 10,
        "PLAYER1_ID": 17,
        "PLAYER1_TEAM_ID": 1,
        "HOMEDESCRIPTION": "Made Shot",
        "PCTIMESTRING": "0:45",
        "EVENTNUM": 5,
    }
    order = 1
    tip_event = StatsFieldGoal(tip, order)
    make_event.previous_event = None
    make_event.next_event = foul_event
    foul_event.previous_event = make_event
    foul_event.next_event = ft_event
    ft_event.previous_event = foul_event
    ft_event.next_event = rebound_event
    rebound_event.previous_event = ft_event
    rebound_event.next_event = tip_event
    tip_event.previous_event = rebound_event
    tip_event.next_event = None
    assert make_event.is_make_that_does_not_end_possession is True
    assert tip_event.is_make_that_does_not_end_possession is False