James McCool commited on
Commit
dc53b72
·
1 Parent(s): f4f6da8

Refactor player comparison logic in 'exposure_spread' function to streamline conditions based on 'type_var', ensuring accurate filtering for Showdown scenarios while maintaining existing functionality.

Browse files
Files changed (1) hide show
  1. global_func/exposure_spread.py +18 -11
global_func/exposure_spread.py CHANGED
@@ -301,18 +301,23 @@ def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stac
301
  comparable_players = projections_df[(projections_df['player_names'].isin(specific_replacements))
302
  ]
303
  else:
304
- comparable_players = projections_df[
305
- (projections_df['salary'] >= comp_salary_low) &
306
- (projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row])) &
307
- (projections_df['position'].apply(lambda x: has_position_overlap(x, comp_player_position)))
308
- ]
 
 
 
 
 
 
309
  if sport_var in stacking_sports:
310
- if sport_var in stacking_sports:
311
- if working_frame.iloc[row]['Size'] == 5 and comp_team != working_frame.iloc[row]['Stack']:
312
- remove_mask = comparable_players.apply(
313
- lambda player_row: not any(team in list(player_row) for team in [working_frame.iloc[row]['Stack']]), axis=1
314
- )
315
- comparable_players = comparable_players[remove_mask]
316
 
317
  if remove_teams is not None:
318
  remove_mask = comparable_players.apply(
@@ -324,6 +329,8 @@ def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stac
324
 
325
  # Create a list of comparable players
326
  comparable_player_list = comparable_players['player_names'].tolist()
 
 
327
  print(comparable_player_list)
328
  print("^^^^ comparable player list")
329
  if comparable_player_list:
 
301
  comparable_players = projections_df[(projections_df['player_names'].isin(specific_replacements))
302
  ]
303
  else:
304
+ if type_var == 'Showdown':
305
+ comparable_players = projections_df[
306
+ (projections_df['salary'] >= comp_salary_low) &
307
+ (projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row]))
308
+ ]
309
+ else:
310
+ comparable_players = projections_df[
311
+ (projections_df['salary'] >= comp_salary_low) &
312
+ (projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row])) &
313
+ (projections_df['position'].apply(lambda x: has_position_overlap(x, comp_player_position)))
314
+ ]
315
  if sport_var in stacking_sports:
316
+ if working_frame.iloc[row]['Size'] == 5 and comp_team != working_frame.iloc[row]['Stack']:
317
+ remove_mask = comparable_players.apply(
318
+ lambda player_row: not any(team in list(player_row) for team in [working_frame.iloc[row]['Stack']]), axis=1
319
+ )
320
+ comparable_players = comparable_players[remove_mask]
 
321
 
322
  if remove_teams is not None:
323
  remove_mask = comparable_players.apply(
 
329
 
330
  # Create a list of comparable players
331
  comparable_player_list = comparable_players['player_names'].tolist()
332
+ print(comp_salary_low)
333
+ print(comp_salary_high)
334
  print(comparable_player_list)
335
  print("^^^^ comparable player list")
336
  if comparable_player_list: