From 7c7b1846347c8acbc94bd6cb17206c0be71b95a8 Mon Sep 17 00:00:00 2001 From: theOehrly <23384863+theOehrly@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:35:03 +0200 Subject: [PATCH] MNT: numpy 2.0 support --- fastf1/_api.py | 10 +++++----- fastf1/core.py | 8 ++++---- pyproject.toml | 19 +++++++++++-------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/fastf1/_api.py b/fastf1/_api.py index 7374614c6..e5e3aa5ba 100644 --- a/fastf1/_api.py +++ b/fastf1/_api.py @@ -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, diff --git a/fastf1/core.py b/fastf1/core.py index 455dde68d..e01eab58c 100644 --- a/fastf1/core.py +++ b/fastf1/core.py @@ -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 @@ -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) @@ -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] }) @@ -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]) diff --git a/pyproject.toml b/pyproject.toml index 03c44ce3c..13b9d4c24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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", @@ -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]