Skip to content

Commit

Permalink
lap_integrity_ok and line length fix
Browse files Browse the repository at this point in the history
  • Loading branch information
d-tomasino committed Oct 14, 2023
1 parent d83875c commit ae49fee
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions fastf1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,7 @@ def _check_lap_accuracy(self):
prev_lap = None
integrity_errors = 0
for _, lap in self.laps[self.laps['DriverNumber'] == drv].iterrows():
lap_integrity_ok = True
# require existence, non-existence and specific values for some variables
check_1 = (pd.isnull(lap['PitInTime'])
& pd.isnull(lap['PitOutTime'])
Expand All @@ -1883,7 +1884,7 @@ def _check_lap_accuracy(self):
lap['LapTime'].total_seconds(),
atol=0.003, rtol=0, equal_nan=False)
if not check_2:
integrity_errors += 1
lap_integrity_ok = False
else:
check_2 = False # data not available means fail

Expand All @@ -1899,21 +1900,24 @@ def _check_lap_accuracy(self):
and (not pd.isnull(prev_lap['Time'])))

if pre_check_4: # needed condition for check_4
time_diff = np.sum((lap['Time'], -1 * prev_lap['Time'])).total_seconds()
time_diff = np.sum((lap['Time'],
-1 * prev_lap['Time'])).total_seconds()
lap_time = lap['LapTime'].total_seconds()
# If the difference between the two times is within a
# certain tolerance, the lap time data is considered to be valid.
check_4 = np.allclose(time_diff, lap_time, atol=0.003, rtol=0, equal_nan=False)
# certain tolerance, the lap time data is considered
# to be valid.
check_4 = np.allclose(time_diff, lap_time,
atol=0.003, rtol=0, equal_nan=False)

# first condition is added to avoid to add two integrity_errors for the same lap
if not check_4 and check_1 and check_2:
integrity_errors += 1
elif not check_4:
integrity_errors += 1
if not check_4:
lap_integrity_ok = False

else:
check_4 = True

if not lap_integrity_ok:
integrity_errors += 1

result = check_1 and check_2 and check_3 and check_4
is_accurate.append(result)
prev_lap = lap
Expand Down

0 comments on commit ae49fee

Please sign in to comment.