Spaces:
Sleeping
Sleeping
Hide tracked-only games from HR game explorer
Browse files
analytics/props_view_model.py
CHANGED
|
@@ -307,6 +307,8 @@ def build_games_summary_df(mapped_df: pd.DataFrame) -> pd.DataFrame:
|
|
| 307 |
_modeled_hr_primary_with_probability_series(game_df)
|
| 308 |
].copy()
|
| 309 |
primary_modeled = _sort_props_df(select_best_lines_per_prop(primary_modeled))
|
|
|
|
|
|
|
| 310 |
|
| 311 |
top_row = primary_modeled.iloc[0].to_dict() if not primary_modeled.empty else {}
|
| 312 |
first_row = game_df.iloc[0]
|
|
@@ -504,6 +506,8 @@ def build_game_player_props_map(mapped_df: pd.DataFrame) -> dict[str, dict[str,
|
|
| 504 |
_modeled_hr_primary_with_probability_series(game_df)
|
| 505 |
].copy()
|
| 506 |
primary_modeled = _sort_props_df(select_best_lines_per_prop(primary_modeled))
|
|
|
|
|
|
|
| 507 |
top_row = primary_modeled.iloc[0].to_dict() if not primary_modeled.empty else {}
|
| 508 |
|
| 509 |
game_map[game_key] = {
|
|
@@ -624,6 +628,8 @@ def build_hr_props_view_model(mapped_df: pd.DataFrame, featured_limit: int = 8)
|
|
| 624 |
for game_key, game_df in working.groupby("_game_key", dropna=False):
|
| 625 |
primary_modeled = game_df[_modeled_hr_primary_with_probability_series(game_df)].copy()
|
| 626 |
primary_modeled = _sort_props_df(select_best_lines_per_prop(primary_modeled))
|
|
|
|
|
|
|
| 627 |
top_row = primary_modeled.iloc[0].to_dict() if not primary_modeled.empty else {}
|
| 628 |
first_row = game_df.iloc[0]
|
| 629 |
|
|
|
|
| 307 |
_modeled_hr_primary_with_probability_series(game_df)
|
| 308 |
].copy()
|
| 309 |
primary_modeled = _sort_props_df(select_best_lines_per_prop(primary_modeled))
|
| 310 |
+
if primary_modeled.empty:
|
| 311 |
+
continue
|
| 312 |
|
| 313 |
top_row = primary_modeled.iloc[0].to_dict() if not primary_modeled.empty else {}
|
| 314 |
first_row = game_df.iloc[0]
|
|
|
|
| 506 |
_modeled_hr_primary_with_probability_series(game_df)
|
| 507 |
].copy()
|
| 508 |
primary_modeled = _sort_props_df(select_best_lines_per_prop(primary_modeled))
|
| 509 |
+
if primary_modeled.empty:
|
| 510 |
+
continue
|
| 511 |
top_row = primary_modeled.iloc[0].to_dict() if not primary_modeled.empty else {}
|
| 512 |
|
| 513 |
game_map[game_key] = {
|
|
|
|
| 628 |
for game_key, game_df in working.groupby("_game_key", dropna=False):
|
| 629 |
primary_modeled = game_df[_modeled_hr_primary_with_probability_series(game_df)].copy()
|
| 630 |
primary_modeled = _sort_props_df(select_best_lines_per_prop(primary_modeled))
|
| 631 |
+
if primary_modeled.empty:
|
| 632 |
+
continue
|
| 633 |
top_row = primary_modeled.iloc[0].to_dict() if not primary_modeled.empty else {}
|
| 634 |
first_row = game_df.iloc[0]
|
| 635 |
|
tests/test_props_view_model.py
CHANGED
|
@@ -226,9 +226,7 @@ class TestPropsViewModel(unittest.TestCase):
|
|
| 226 |
def test_games_summary_excludes_primary_rows_without_probability(self) -> None:
|
| 227 |
summary = build_games_summary_df(self._sample_mapped_df_with_missing_primary_prob())
|
| 228 |
|
| 229 |
-
|
| 230 |
-
self.assertEqual(int(mets_cubs["modeled_props_count"]), 0)
|
| 231 |
-
self.assertTrue(pd.isna(mets_cubs["best_edge"]))
|
| 232 |
|
| 233 |
def test_player_detail_map_separates_primary_and_alt_rows(self) -> None:
|
| 234 |
detail_map = build_player_prop_detail_map(self._sample_mapped_df())
|
|
@@ -302,6 +300,11 @@ class TestPropsViewModel(unittest.TestCase):
|
|
| 302 |
self.assertEqual(int(vm["best_on_slate_summary"]["modeled_props_count"]), 4)
|
| 303 |
self.assertEqual(int(vm["best_on_slate_summary"]["markets_count"]), 2)
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
| 306 |
if __name__ == "__main__":
|
| 307 |
unittest.main()
|
|
|
|
| 226 |
def test_games_summary_excludes_primary_rows_without_probability(self) -> None:
|
| 227 |
summary = build_games_summary_df(self._sample_mapped_df_with_missing_primary_prob())
|
| 228 |
|
| 229 |
+
self.assertNotIn("evt-2", summary["event_id"].tolist())
|
|
|
|
|
|
|
| 230 |
|
| 231 |
def test_player_detail_map_separates_primary_and_alt_rows(self) -> None:
|
| 232 |
detail_map = build_player_prop_detail_map(self._sample_mapped_df())
|
|
|
|
| 300 |
self.assertEqual(int(vm["best_on_slate_summary"]["modeled_props_count"]), 4)
|
| 301 |
self.assertEqual(int(vm["best_on_slate_summary"]["markets_count"]), 2)
|
| 302 |
|
| 303 |
+
def test_game_player_map_excludes_games_with_zero_modeled_primary_props(self) -> None:
|
| 304 |
+
game_map = build_game_player_props_map(self._sample_mapped_df_with_missing_primary_prob())
|
| 305 |
+
|
| 306 |
+
self.assertNotIn("evt-2", game_map)
|
| 307 |
+
|
| 308 |
|
| 309 |
if __name__ == "__main__":
|
| 310 |
unittest.main()
|