-
-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bring in Ergast drivers in races only #699
base: master
Are you sure you want to change the base?
Conversation
One example I found for a missing driver being pulled in from Ergast is Mick Schumacher at the 2022 Saudi Arabian Grand Prix. He did not start due to a heavy crash in Quali, I think. But he also isn't even listed in the official classification, contrary to Tsunoda who is listed as DNS after a mechanical issue before the race. Ergast lists Schumacher as "Withdrew". |
In that case, how do you want the code to behave? I can see arguments both for including and excluding Mick. Excluding him to stay consistent with official F1 classification, and including him to be more informative |
1873392
to
6a60f11
Compare
Added tests, moved some code around a little bit, and improved (personal opinion) variable name. Ready for review now |
fastf1/core.py
Outdated
if missing_drivers: | ||
self._results.loc[missing_drivers, info_cols] \ | ||
= driver_info_ergast.loc[missing_drivers, info_cols] | ||
if self.name == "Race": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I was right about this after all. I was confused😅 We can and should use self.name in self._RACE_LIKE_SESSIONS
. Further up, self._driver_results_from_ergast
returns race, quali and sprint results for the corresponding sessions. It returns None for Sprint Qualifiying and the race results for a practice session. To be fair, a comment or docstring would have been appropriate there, when I implemented this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the support for all race-like sessions new in Jolpica? I thought Ergast only had the GPs.
I will add some explanatory comments for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be tough to test for. A driver has to be in qualifying to participate in GP and I cannot remember a driver change between sprint and race off the top of my head. I will look into that more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ergast supports sprint races. It's missing sprint qualifying. For example: https://ergast.com/api/f1/2024/5/sprint/
We might be covering against a case that has never happened before. The logic is exactly the same as for the case where MSC is added, no? I'd be absolutely happy with just having the test for that. Mocking all the necessary data to make a mock test for the other case will be a lot of work for a feature that'll maybe never be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that mocking is too much work to be worth it. There is only two scenarios for the missing driver handling depending on whether Ergast gives us reliable driver lists or not. The test I added cover both of those so we should be good.
Based on your description, we really should be using self.name in self._RACE_LIKE_SESSIONS or self.name == "Qualifying"
instead of just self.name in self._RACE_LIKE_SESSIONS
no?
6a60f11
to
b768388
Compare
Fixes #680