Skip to content
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

Eliminate type cohersion from #676 #682

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions fastf1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,9 +1550,7 @@ def _load_laps_data(self, livedata=None):
# started can only be made for the race
laps_start_time.insert(0, self.session_start_time)
else:
laps_start_time.insert(0, pd.NaT)
laps_start_time = pd.Series(laps_start_time,
dtype="timedelta64[ns]")
laps_start_time.insert(0, np.timedelta64("NaT"))

# don't set lap start times after red flag restart to the time
# at which the previous lap was set
Expand Down
10 changes: 10 additions & 0 deletions fastf1/tests/test_input_data_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ def test_first_lap_time_added_from_ergast_in_race():

assert not pd.isna(session.laps.pick_laps(1)['LapTime']).any()

@pytest.mark.f1telapi
def test_lap_start_time_dtype_single_lap():
# When a driver only completes one lap, the LapStartTime column only
# contains a NaT value. Ensure that this column still has the correct
# timedelta64 dtype as pandas defaults to datetime64[ns] when all values
# are NaT (see GH#674)
session = fastf1.get_session(2022, 10, 1)
session.load(telemetry=False, weather=False)

assert session.laps['LapStartTime'].dtype == 'timedelta64[ns]'

@pytest.mark.f1telapi
def test_consecutive_equal_lap_times():
Expand Down