Skip to content

Commit

Permalink
fixing bad WP_after case
Browse files Browse the repository at this point in the history
  • Loading branch information
akeaswaran committed Feb 4, 2024
1 parent 6ba177c commit 231ecd9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion sportsdataverse/cfb/cfb_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
],
[
Expand All @@ -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,
)
Expand Down Expand Up @@ -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"]),
],
[
Expand All @@ -4947,6 +4950,7 @@ def __process_wpa(self, play_df):
7,
8,
9,
10,
],
default=None,
)
Expand Down
12 changes: 8 additions & 4 deletions tests/cfb/test_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

0 comments on commit 231ecd9

Please sign in to comment.