Skip to content

Commit

Permalink
MNT: numpy 2.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
theOehrly committed Jul 12, 2024
1 parent 7d7a248 commit 7c7b184
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
10 changes: 5 additions & 5 deletions fastf1/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ def make_path(wname, wdate, sname, sdate):

# define all empty columns for timing data
EMPTY_LAPS = {'Time': pd.NaT, 'Driver': str(), 'LapTime': pd.NaT,
'NumberOfLaps': np.NaN, 'NumberOfPitStops': np.NaN,
'NumberOfLaps': np.nan, 'NumberOfPitStops': np.nan,
'PitOutTime': pd.NaT, 'PitInTime': pd.NaT,
'Sector1Time': pd.NaT, 'Sector2Time': pd.NaT,
'Sector3Time': pd.NaT, 'Sector1SessionTime': pd.NaT,
'Sector2SessionTime': pd.NaT, 'Sector3SessionTime': pd.NaT,
'SpeedI1': np.NaN, 'SpeedI2': np.NaN, 'SpeedFL': np.NaN,
'SpeedST': np.NaN, 'IsPersonalBest': False}
'SpeedI1': np.nan, 'SpeedI2': np.nan, 'SpeedFL': np.nan,
'SpeedST': np.nan, 'IsPersonalBest': False}

EMPTY_STREAM = {'Time': pd.NaT, 'Driver': str(), 'Position': np.NaN,
'GapToLeader': np.NaN, 'IntervalToPositionAhead': np.NaN}
EMPTY_STREAM = {'Time': pd.NaT, 'Driver': str(), 'Position': np.nan,
'GapToLeader': np.nan, 'IntervalToPositionAhead': np.nan}


def timing_data(path: str,
Expand Down
8 changes: 4 additions & 4 deletions fastf1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,7 @@ def _load_laps_data(self, livedata=None):
laps['Driver'] = laps['DriverNumber'].map(d_map)

# add Position based on lap timing
laps['Position'] = np.NaN # create empty column
laps['Position'] = np.nan # create empty column
if self.name in self._RACE_LIKE_SESSIONS:
for lap_n in laps['LapNumber'].unique():
# get each drivers lap for the current lap number, sorted by
Expand All @@ -1633,7 +1633,7 @@ def _load_laps_data(self, livedata=None):
drivers_with_one_lap = lap_counts[lap_counts == 1].index
dnf_and_generated = (laps['FastF1Generated'] &
laps['Driver'].isin(drivers_with_one_lap))
laps.loc[dnf_and_generated, 'Position'] = np.NaN
laps.loc[dnf_and_generated, 'Position'] = np.nan

self._add_track_status_to_laps(laps)

Expand Down Expand Up @@ -1745,7 +1745,7 @@ def _fix_missing_laps_retired_on_track(self):
'Compound': [drv_laps['Compound'].iloc[-1]],
'TyreLife': [drv_laps['TyreLife'].iloc[-1] + 1],
'FreshTyre': [drv_laps['FreshTyre'].iloc[-1]],
'Position': [np.NaN],
'Position': [np.nan],
'FastF1Generated': [True],
'IsAccurate': [False]
})
Expand Down Expand Up @@ -2229,7 +2229,7 @@ def _load_drivers_results(self, *, livedata=None):
# set (Grid)Position to NaN instead of default last or zero to
# make the DNS more obvious
self._results.loc[missing_drivers,
('Position', 'GridPosition')] = np.NaN
('Position', 'GridPosition')] = np.nan

if (dupl_mask := self._results.index.duplicated()).any():
dupl_drv = list(self._results.index[dupl_mask])
Expand Down
19 changes: 11 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ requires-python = ">=3.8"
# minimum package versions additionally need to be changed in requirements/minver.txt
dependencies = [
"matplotlib>=3.5.1,<4.0.0",
"numpy>=1.21.5,<2.0.0",
"numpy>=1.21.5,<3.0.0",
"pandas>=1.4.1,<3.0.0",
"python-dateutil",
"requests>=2.28.1",
Expand Down Expand Up @@ -71,12 +71,6 @@ fallback_version = "0.0+UNKNOWN"

[tool.ruff]
line-length = 79
select = [
# "D", TODO: select and fix docstrings
"E",
"F",
"W",
]
exclude = [
"scripts",
"fastf1/tests",
Expand All @@ -85,7 +79,16 @@ exclude = [
"fastf1/legacy.py",
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint]
select = [
# "D", TODO: select and fix docstrings
"E",
"F",
"W",
"NPY201"
]

[tool.ruff.lint.per-file-ignores]
"fastf1/_api.py" = ["E501"]

[tool.isort]
Expand Down

0 comments on commit 7c7b184

Please sign in to comment.