James McCool commited on
Commit
3a9fcee
·
1 Parent(s): 587326c

Limit player removal iterations in distribute_preset.py to a maximum of 10 to prevent infinite loops during portfolio distribution. This change enhances the stability of the player filtering process while maintaining the accuracy of lineup generation.

Browse files
Files changed (1) hide show
  1. global_func/distribute_preset.py +4 -1
global_func/distribute_preset.py CHANGED
@@ -6,8 +6,9 @@ def distribute_preset(portfolio: pd.DataFrame, lineup_target: int, exclude_cols:
6
  excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Size', 'Win%', 'Lineup Edge', 'Weighted Own', 'Geomean', 'Similarity Score']
7
  player_columns = [col for col in portfolio.columns if col not in excluded_cols]
8
  player_remove_list = []
 
9
 
10
- while True: # Continue until no more players need to be removed
11
  for slack_var in range(1, 20):
12
  concat_portfolio = pd.DataFrame(columns=portfolio.columns)
13
 
@@ -81,5 +82,7 @@ def distribute_preset(portfolio: pd.DataFrame, lineup_target: int, exclude_cols:
81
  # If no new players to remove and we have enough lineups, we're done
82
  if len(high_exposure_players) == 0 and len(concat_portfolio) >= lineup_target:
83
  break
 
 
84
 
85
  return concat_portfolio.sort_values(by='median', ascending=False)
 
6
  excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Size', 'Win%', 'Lineup Edge', 'Weighted Own', 'Geomean', 'Similarity Score']
7
  player_columns = [col for col in portfolio.columns if col not in excluded_cols]
8
  player_remove_list = []
9
+ x = 0
10
 
11
+ while x < 10: # Continue until no more players need to be removed
12
  for slack_var in range(1, 20):
13
  concat_portfolio = pd.DataFrame(columns=portfolio.columns)
14
 
 
82
  # If no new players to remove and we have enough lineups, we're done
83
  if len(high_exposure_players) == 0 and len(concat_portfolio) >= lineup_target:
84
  break
85
+
86
+ x += 1
87
 
88
  return concat_portfolio.sort_values(by='median', ascending=False)