diff --git a/setup.py b/setup.py index 500d057..babcd80 100755 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version="0.0.36.2.7", + version="0.0.36.2.8", description="Retrieve Sports data in Python", long_description=long_description, long_description_content_type="text/markdown", diff --git a/sportsdataverse/cfb/cfb_pbp.py b/sportsdataverse/cfb/cfb_pbp.py index 0ca93c2..1126b1f 100755 --- a/sportsdataverse/cfb/cfb_pbp.py +++ b/sportsdataverse/cfb/cfb_pbp.py @@ -4887,6 +4887,7 @@ def __process_wpa(self, play_df): & (play_df.change_of_pos_team == 1), (play_df["kickoff_onside"] == True) & ((play_df["change_of_pos_team"] == True) | (play_df["change_of_poss"] == True)), # onside recovery + (play_df["penalty_flag"] == True & (play_df["start.pos_team.id"] != play_df["end.pos_team.id"])), (play_df["start.pos_team.id"] != play_df["end.pos_team.id"]), ], [ @@ -4899,7 +4900,8 @@ def __process_wpa(self, play_df): play_df.lead_wp_before, (1 - play_df.lead_wp_before), (1 - play_df.lead_wp_before), - play_df.wp_after + play_df.wp_after, + (1 - play_df.wp_after), ], default=play_df.wp_after, ) @@ -4934,6 +4936,7 @@ def __process_wpa(self, play_df): & (play_df.change_of_pos_team == 1), (play_df["kickoff_onside"] == True) & ((play_df["change_of_pos_team"] == True) | (play_df["change_of_poss"] == True)), # onside recovery + (play_df["penalty_flag"] == True & (play_df["start.pos_team.id"] != play_df["end.pos_team.id"])), (play_df["start.pos_team.id"] != play_df["end.pos_team.id"]), ], [ @@ -4947,6 +4950,7 @@ def __process_wpa(self, play_df): 7, 8, 9, + 10, ], default=None, ) diff --git a/tests/cfb/test_pbp.py b/tests/cfb/test_pbp.py index cbff8dc..516e116 100755 --- a/tests/cfb/test_pbp.py +++ b/tests/cfb/test_pbp.py @@ -322,8 +322,8 @@ def test_ou_tul_bad_spread(): assert test.plays_json.loc[0, "homeTeamId"] == 201 -def test_osu_mich_bad_wp(): - test = CFBPlayProcess(gameId = 401520434) +def test_bad_wp_after_situations(): + test = CFBPlayProcess(gameId = 401551750) # Ohio St/Mich: 401520434 vs BC/SMU: 401551750 test.espn_cfb_pbp() json_dict_stuff = test.run_processing_pipeline() @@ -334,13 +334,17 @@ def test_osu_mich_bad_wp(): bad_wpa_play = plays[ plays["text"].isin([ "Michigan Penalty, Unsportsmanlike Conduct (Jaylen Harrell) to the MICH 11 for a 1ST down", - "[NHSG] Kneel down by MCCARTHY, J.J. at MIC9 (team loss of 2), clock 00:00." + "[NHSG] Kneel down by MCCARTHY, J.J. at MIC9 (team loss of 2), clock 00:00.", + "Jesse Mirco punt for 43 yds, downed at the MICH 36", + "Tommy Doman punt for 49 yds, downed at the OSU 2", + "Ryan Bujcevski punt blocked by TEAM blocked by TEAM Bujcevski, Ryan punt 29 yards to the SMU44, recovered by BOSTONCOLL # at SMU44 (blocked by TEAM).", + "Kevin Jennings pass incomplete, broken up by #" ]) ] bad_wpa_play["proper_time_set"] = bad_wpa_play["start.adj_TimeSecsRem"] >= bad_wpa_play["end.adj_TimeSecsRem"] - search_cols = sorted(list(set(wp_start_columns + wp_end_columns))) + search_cols = sorted(list(set(wp_start_columns + wp_end_columns + ["end.ExpScoreDiff", "start.ExpScoreDiff"]))) LOGGER.info(bad_wpa_play[["id", "text", "lead_play_text", "change_of_poss", "change_of_pos_team", "wp_after_case", "wp_before", "wp_after", "proper_time_set"] + search_cols].to_json(orient = "records", indent = 2)) assert bad_wpa_play.proper_time_set.all() \ No newline at end of file