Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix spreads #67

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
version="0.0.36.2.1",
description="Retrieve Sports data in Python",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
4 changes: 2 additions & 2 deletions sportsdataverse/cfb/cfb_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,9 @@ def __helper_cfb_pbp(self, pbp_txt):

def __helper_cfb_pickcenter(self, pbp_txt):
# Spread definition
if len(pbp_txt.get("pickcenter",[])) > 1:
if len(pbp_txt.get("pickcenter",[])) > 0:
homeFavorite = pbp_txt.get("pickcenter",{})[0].get("homeTeamOdds",{}).get("favorite","")
if "spread" in pbp_txt.get("pickcenter",{})[1].keys():
if len(pbp_txt.get("pickcenter",{})) > 1 and "spread" in pbp_txt.get("pickcenter",{})[1].keys():
gameSpread = pbp_txt.get("pickcenter",{})[1].get("spread","")
overUnder = pbp_txt.get("pickcenter",{})[1].get("overUnder","")
gameSpreadAvailable = True
Expand Down
45 changes: 44 additions & 1 deletion tests/cfb/test_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,47 @@ def test_play_order():
LOGGER.info(pbp_ot[["id", "sequenceNumber", "period", "start.down", "start.distance", "text"]])

assert int(should_be_first.iloc[0]["sequenceNumber"]) + 1 == int(should_be_next.iloc[0]["sequenceNumber"])
assert int(should_be_first.iloc[0]["game_play_number"]) + 1 == int(should_be_next.iloc[0]["game_play_number"])
assert int(should_be_first.iloc[0]["game_play_number"]) + 1 == int(should_be_next.iloc[0]["game_play_number"])

def test_explosive_play_count():
test = CFBPlayProcess(gameId = 401525500)
test.espn_cfb_pbp()
test.run_processing_pipeline()

box = test.create_box_score()

fsu_expl_total = box['team'][0]['EPA_explosive']
LOGGER.info(fsu_expl_total)

fsu_expl_plays = test.plays_json[
(test.plays_json["pos_team"] == 52)
& ((test.plays_json["EPA"] >= 1.8))
]
LOGGER.info(fsu_expl_plays[["id", "text", "statYardage", "pass", "rush", "EPA", "EPA_explosive"]])

fsu_naive_expl_plays = test.plays_json[
(test.plays_json["pos_team"] == 52)
& (test.plays_json["statYardage"] >= 15)
# & (test.plays_json["scrimmage_play"] == True)
]
LOGGER.info(fsu_naive_expl_plays[["id", "text", "statYardage", "pass", "rush", "EPA", "EPA_explosive"]])
LOGGER.info(len(fsu_naive_expl_plays))

bc_naive_expl_plays = test.plays_json[
(test.plays_json["pos_team"] != 52)
& (test.plays_json["statYardage"] >= 15)
# & (test.plays_json["scrimmage_play"] == True)
]
LOGGER.info(bc_naive_expl_plays[["id", "text", "statYardage", "pass", "rush", "EPA", "EPA_explosive"]])
LOGGER.info(len(bc_naive_expl_plays))

# assert fsu_expl_total == len(fsu_expl_plays)

def test_spread_available():
test = CFBPlayProcess(gameId = 401525519)
test.espn_cfb_pbp()
json_dict_stuff = test.run_processing_pipeline()

print(json_dict_stuff["pickcenter"])

assert test.plays_json.loc[0, "gameSpreadAvailable"] == True
Loading