Spaces:
Running
Running
James McCool
commited on
Commit
·
430efa4
1
Parent(s):
680a352
Refactor position requirement functions in Streamlit app to simplify calculations for QB, RB, WR, and TE. Updated base position requirements to use fixed values and improved handling of league settings for accurate index calculations.
Browse files- src/streamlit_app.py +21 -20
src/streamlit_app.py
CHANGED
@@ -273,10 +273,10 @@ def designate_custom_position_reqs(league_settings: dict, flex_percentiles: dict
|
|
273 |
wr_base = league_settings['WR'] * league_settings['TEAMS']
|
274 |
te_base = league_settings['TE'] * league_settings['TEAMS']
|
275 |
|
276 |
-
qb_rv_index = math.ceil((qb_base) * flex_multipliers[
|
277 |
-
rb_rv_index = math.ceil((rb_base + ((league_settings['TEAMS'] * league_settings['FLEX']) * flex_percentiles[
|
278 |
-
wr_rv_index = math.ceil((wr_base + ((league_settings['TEAMS'] * league_settings['FLEX']) * flex_percentiles[
|
279 |
-
te_rv_index = math.ceil((te_base + ((league_settings['TEAMS'] * league_settings['FLEX']) * flex_percentiles[
|
280 |
|
281 |
print(f"Need {qb_rv_index} for QB in {league_settings['TEAMS']} teams with type {league_settings['TYPE']}")
|
282 |
print(f"Need {rb_rv_index} for RB in {league_settings['TEAMS']} teams with type {league_settings['TYPE']}")
|
@@ -292,21 +292,21 @@ def designate_custom_position_reqs(league_settings: dict, flex_percentiles: dict
|
|
292 |
|
293 |
return pos_reqs
|
294 |
|
295 |
-
def designate_base_position_reqs(
|
296 |
-
qb_base =
|
297 |
-
rb_base =
|
298 |
-
wr_base =
|
299 |
-
te_base =
|
300 |
|
301 |
-
qb_rv_index = math.ceil(qb_base *
|
302 |
-
rb_rv_index = math.ceil((rb_base + ((
|
303 |
-
wr_rv_index = math.ceil((wr_base + ((
|
304 |
-
te_rv_index = math.ceil((te_base + ((
|
305 |
|
306 |
-
print(f"Need {qb_rv_index} for QB in {
|
307 |
-
print(f"Need {rb_rv_index} for RB in {
|
308 |
-
print(f"Need {wr_rv_index} for WR in {
|
309 |
-
print(f"Need {te_rv_index} for TE in {
|
310 |
|
311 |
pos_reqs = {
|
312 |
'QB': qb_rv_index,
|
@@ -396,11 +396,12 @@ def main():
|
|
396 |
position_df = create_position_frames(projections_df, ranks_dict)
|
397 |
|
398 |
# Calculate position requirements
|
399 |
-
|
|
|
400 |
|
401 |
# Calculate replacement values
|
402 |
-
halfPpr_rv = create_halfPpr_rv(position_df,
|
403 |
-
custom_rv = create_custom_rv(position_df,
|
404 |
|
405 |
# Calculate VORP and rankings
|
406 |
final_df = assign_vorp(position_df, halfPpr_rv, custom_rv, user_league_settings, user_pos_vorp_limiters)
|
|
|
273 |
wr_base = league_settings['WR'] * league_settings['TEAMS']
|
274 |
te_base = league_settings['TE'] * league_settings['TEAMS']
|
275 |
|
276 |
+
qb_rv_index = math.ceil((qb_base) * flex_multipliers['QB'])
|
277 |
+
rb_rv_index = math.ceil((rb_base + ((league_settings['TEAMS'] * league_settings['FLEX']) * flex_percentiles['RB'])) * flex_multipliers['RB'])
|
278 |
+
wr_rv_index = math.ceil((wr_base + ((league_settings['TEAMS'] * league_settings['FLEX']) * flex_percentiles['WR'])) * flex_multipliers['WR'])
|
279 |
+
te_rv_index = math.ceil((te_base + ((league_settings['TEAMS'] * league_settings['FLEX']) * flex_percentiles['TE'])) * flex_multipliers['TE'])
|
280 |
|
281 |
print(f"Need {qb_rv_index} for QB in {league_settings['TEAMS']} teams with type {league_settings['TYPE']}")
|
282 |
print(f"Need {rb_rv_index} for RB in {league_settings['TEAMS']} teams with type {league_settings['TYPE']}")
|
|
|
292 |
|
293 |
return pos_reqs
|
294 |
|
295 |
+
def designate_base_position_reqs() -> dict:
|
296 |
+
qb_base = 1 * 12
|
297 |
+
rb_base = 2 * 12
|
298 |
+
wr_base = 3 * 12
|
299 |
+
te_base = 1 * 12
|
300 |
|
301 |
+
qb_rv_index = math.ceil(qb_base * 2)
|
302 |
+
rb_rv_index = math.ceil((rb_base + ((12 * 1) * .75)) * 2)
|
303 |
+
wr_rv_index = math.ceil((wr_base + ((12 * 1) * .75)) * 2)
|
304 |
+
te_rv_index = math.ceil((te_base + ((12 * 1) * .5)) * 2)
|
305 |
|
306 |
+
print(f"Need {qb_rv_index} for QB in {12} teams with type {league_settings['TYPE']}")
|
307 |
+
print(f"Need {rb_rv_index} for RB in {12} teams with type {league_settings['TYPE']}")
|
308 |
+
print(f"Need {wr_rv_index} for WR in {12} teams with type {league_settings['TYPE']}")
|
309 |
+
print(f"Need {te_rv_index} for TE in {12} teams with type {league_settings['TYPE']}")
|
310 |
|
311 |
pos_reqs = {
|
312 |
'QB': qb_rv_index,
|
|
|
396 |
position_df = create_position_frames(projections_df, ranks_dict)
|
397 |
|
398 |
# Calculate position requirements
|
399 |
+
base_pos_reqs = designate_base_position_reqs(base_settings, user_flex_percentiles, user_flex_multipliers)
|
400 |
+
custom_pos_reqs = designate_custom_position_reqs(user_league_settings, user_flex_percentiles, user_flex_multipliers)
|
401 |
|
402 |
# Calculate replacement values
|
403 |
+
halfPpr_rv = create_halfPpr_rv(position_df, base_pos_reqs)
|
404 |
+
custom_rv = create_custom_rv(position_df, custom_pos_reqs, user_league_settings)
|
405 |
|
406 |
# Calculate VORP and rankings
|
407 |
final_df = assign_vorp(position_df, halfPpr_rv, custom_rv, user_league_settings, user_pos_vorp_limiters)
|