gr-analytics 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/PKG-INFO +1 -1
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/gr_analytics/__init__.py +14 -0
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/gr_analytics/data/driver_data.csv +34 -1
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/gr_analytics.egg-info/PKG-INFO +1 -1
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/pyproject.toml +1 -1
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/tests/test_scoring.py +17 -9
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/README.md +0 -0
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/gr_analytics.egg-info/SOURCES.txt +0 -0
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/gr_analytics.egg-info/dependency_links.txt +0 -0
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/gr_analytics.egg-info/requires.txt +0 -0
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/gr_analytics.egg-info/top_level.txt +0 -0
- {gr_analytics-0.3.0 → gr_analytics-0.3.1}/setup.cfg +0 -0
|
@@ -722,4 +722,18 @@ def optimal_lineup(
|
|
|
722
722
|
best_total = total
|
|
723
723
|
best_full = full
|
|
724
724
|
|
|
725
|
+
# When balance == 0 the star bonus is zero so the loop picks
|
|
726
|
+
# arbitrarily. Override to star the highest-points eligible driver.
|
|
727
|
+
if balance == 0.0:
|
|
728
|
+
best_full["star"] = 0
|
|
729
|
+
eligible = best_full[best_full["type"] == "driver"]
|
|
730
|
+
if star_salary_cap is not None:
|
|
731
|
+
eligible = eligible[eligible["starting_salary"] <= star_salary_cap]
|
|
732
|
+
if not eligible.empty:
|
|
733
|
+
best_full.loc[eligible["points_earned"].idxmax(), "star"] = 1
|
|
734
|
+
|
|
735
|
+
# Double points_earned for the starred driver so the returned
|
|
736
|
+
# DataFrame reflects actual fantasy points with star doubling.
|
|
737
|
+
best_full.loc[best_full["star"] == 1, "points_earned"] *= 2
|
|
738
|
+
|
|
725
739
|
return best_full.drop(columns=["_locked"])
|
|
@@ -130,4 +130,37 @@ team,AMR,AMR,,3,12.8,,69
|
|
|
130
130
|
team,WIL,WIL,,3,12.7,,80
|
|
131
131
|
team,HAS,HAS,,3,11.2,,114
|
|
132
132
|
team,AUD,AUD,,3,10.8,,92
|
|
133
|
-
team,CAD,CAD,,3,8.4,,80
|
|
133
|
+
team,CAD,CAD,,3,8.4,,80
|
|
134
|
+
driver,ANT,K. Antonelli,MER,4,28.8,4,176
|
|
135
|
+
driver,RUS,G. Russell,MER,4,28.7,3,165
|
|
136
|
+
driver,NOR,L. Norris,MCL,4,26.7,6,136
|
|
137
|
+
driver,LEC,C. Leclerc,FER,4,25.9,6,161
|
|
138
|
+
driver,PIA,O. Piastri,MCL,4,25.7,8,114
|
|
139
|
+
driver,VER,M. Verstappen,RBR,4,25.3,5,144
|
|
140
|
+
driver,HAM,L. Hamilton,FER,4,23.3,7,157
|
|
141
|
+
driver,GAS,P. Gasly,ALP,4,19.7,11,130
|
|
142
|
+
driver,SAI,C. Sainz Jr,WIL,4,16.4,12,122
|
|
143
|
+
driver,LAW,L. Lawson,RBS,4,16,13,126
|
|
144
|
+
driver,HAD,I. Hadjar,RBR,4,15.7,13,100
|
|
145
|
+
driver,ALO,F. Alonso,AMR,4,15.1,12,85
|
|
146
|
+
driver,OCO,E. Ocon,HAS,4,13.2,15,127
|
|
147
|
+
driver,BEA,O. Bearman,HAS,4,12.9,15,140
|
|
148
|
+
driver,BOR,G. Bortoleto,AUD,4,12.7,15,105
|
|
149
|
+
driver,ALB,A. Albon,WIL,4,11.9,15,87
|
|
150
|
+
driver,HUL,N. Hulkenberg,AUD,4,11.3,16,91
|
|
151
|
+
driver,COL,F. Colapinto,ALP,4,11,16,135
|
|
152
|
+
driver,LIN,A. Lindblad,RBS,4,10.5,16,125
|
|
153
|
+
driver,STR,L. Stroll,AMR,4,10.4,15,74
|
|
154
|
+
driver,PER,S. Perez,CAD,4,8.1,18,98
|
|
155
|
+
driver,BOT,V. Bottas,CAD,4,6,19,85
|
|
156
|
+
team,MER,MER,,4,29.4,,174
|
|
157
|
+
team,MCL,MCL,,4,24.7,,120
|
|
158
|
+
team,FER,FER,,4,24.6,,158
|
|
159
|
+
team,RBR,RBR,,4,20,,111
|
|
160
|
+
team,ALP,ALP,,4,18,,118
|
|
161
|
+
team,RBS,RBS,,4,15.3,,113
|
|
162
|
+
team,WIL,WIL,,4,15,,90
|
|
163
|
+
team,HAS,HAS,,4,12.6,,113
|
|
164
|
+
team,AMR,AMR,,4,11.3,,74
|
|
165
|
+
team,AUD,AUD,,4,11,,92
|
|
166
|
+
team,CAD,CAD,,4,7.3,,80
|
|
@@ -647,17 +647,25 @@ class TestOptimizeForBalance:
|
|
|
647
647
|
assert bal_abbrs == sal_abbrs
|
|
648
648
|
|
|
649
649
|
def test_balance_star_assigned_when_balance_positive(self, balance_pool):
|
|
650
|
-
"""When optimize_for is a positive float, a star driver should be assigned
|
|
650
|
+
"""When optimize_for is a positive float, a star driver should be assigned
|
|
651
|
+
and their points_earned should be doubled."""
|
|
651
652
|
result = optimal_lineup(balance_pool, optimize_for=0.5)
|
|
652
653
|
assert (result["star"] == 1).sum() == 1
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
654
|
+
star_row = result[result["star"] == 1].iloc[0]
|
|
655
|
+
orig_pts = balance_pool.loc[
|
|
656
|
+
balance_pool["driver_abbr"] == star_row["driver_abbr"], "points_earned"
|
|
657
|
+
].iloc[0]
|
|
658
|
+
assert star_row["points_earned"] == orig_pts * 2
|
|
659
|
+
|
|
660
|
+
def test_balance_0_star_assigned_to_highest_pts(self, balance_pool):
|
|
661
|
+
"""When balance=0, the highest-points eligible driver is still starred
|
|
662
|
+
and their points_earned is doubled."""
|
|
663
|
+
result = optimal_lineup(balance_pool, optimize_for=0.0)
|
|
664
|
+
assert (result["star"] == 1).sum() == 1
|
|
665
|
+
star_row = result[result["star"] == 1].iloc[0]
|
|
666
|
+
# D1 has the highest points (200) in the pool
|
|
667
|
+
assert star_row["driver_abbr"] == "D1"
|
|
668
|
+
assert star_row["points_earned"] == 400.0
|
|
661
669
|
|
|
662
670
|
def test_balance_out_of_range_raises(self, balance_pool):
|
|
663
671
|
"""optimize_for outside [0, 1] should raise ValueError."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|