diff --git a/setup.py b/setup.py index 22ea6f6..95f9857 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", + version="0.0.36.2.1", 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 e0beb58..dfa949d 100755 --- a/sportsdataverse/cfb/cfb_pbp.py +++ b/sportsdataverse/cfb/cfb_pbp.py @@ -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 diff --git a/tests/cfb/test_pbp.py b/tests/cfb/test_pbp.py index 9398535..8ebe603 100755 --- a/tests/cfb/test_pbp.py +++ b/tests/cfb/test_pbp.py @@ -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"]) \ No newline at end of file + 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