Fix NaT lap times after red flag restarts (issue #473)#925
Open
TumCucTom wants to merge 1 commit into
Open
Conversation
During standing restarts after red flags (formation laps), some drivers have their LapTime set to NaT in the API data. The lap synchronization logic in _laps_data_driver was attempting to use these NaT LapTime values when adjusting lap start times, which corrupted the Time values for subsequent laps. The fix adds checks to skip the lap time sync adjustment when LapTime is NaT, since these special laps (formation laps, etc.) don't have valid lap times to use for synchronization. Co-Authored-By: Zippy AI <tomkinsbale@icloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix lap times being set to NaT for drivers during standing restarts after red flags (formation laps).
During the Mexican GP 2023, a Red Flag was displayed on lap 34. Lap 35 began when VER crossed the line and entered the pit lane (formation lap behind SC). Lap 36 began when VER crossed the line and waited on the grid for the race to restart. In lap 36, the LapTime was recorded as NaT for the first 5 drivers (VER, HAM, LEC, SAI, RIC), while other drivers had LapTimes around 2 minutes 20 seconds.
The issue was that the lap synchronization logic in
_laps_data_driverwas attempting to use NaT LapTime values when adjusting lap start times, which corrupted the Time values for subsequent laps.Changes
_laps_data_driverto skip the backward lap time sync adjustment whenLapTimeis NaTLapTime(of lap i) is NaTTesting
Load Mexico 2023 race session and verify lap times are correct for drivers VER, HAM, LEC, SAI, RIC on lap 36.
Checklist
AI Disclosure
AI was used as a coding assistant. The human author reviewed all AI-generated code and changes.