Skip to content

Commit

Permalink
Merge pull request #67 from sportsdataverse/0.36.2.1
Browse files Browse the repository at this point in the history
fix spreads
  • Loading branch information
akeaswaran authored Oct 15, 2023
2 parents 6328f18 + 696c427 commit bf6f2cf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 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",
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

0 comments on commit bf6f2cf

Please sign in to comment.