Skip to content
Snippets Groups Projects
Commit c3e25ad1 authored by Lennard Geese's avatar Lennard Geese
Browse files

Fix minor warnings

parent 3d1997b4
No related branches found
No related tags found
No related merge requests found
import pandas as pandas import pandas as pandas
from fastf1.core import Session, Lap, Laps, DataNotLoadedError from fastf1.core import Session, Lap, Laps, DataNotLoadedError
from DataHandler import DataHandler, SessionIdentifier from DataHandler import DataHandler
class DataAnalyser(DataHandler): class DataAnalyser(DataHandler):
...@@ -155,7 +155,6 @@ class DataAnalyser(DataHandler): ...@@ -155,7 +155,6 @@ class DataAnalyser(DataHandler):
# Returns -1 if no tire change occurred # Returns -1 if no tire change occurred
def getEarliestTireChange(self, race: Session): def getEarliestTireChange(self, race: Session):
earliestTireChangeLap: int = -1
compoundsPerLap: list[list[str]] = self.getCompoundsForRace(race) compoundsPerLap: list[list[str]] = self.getCompoundsForRace(race)
compoundsPerLap[0] = compoundsPerLap[1] # presume grid tires same as 1st lap; races are only picked if weather change after first 10 laps anyway, so it's ok compoundsPerLap[0] = compoundsPerLap[1] # presume grid tires same as 1st lap; races are only picked if weather change after first 10 laps anyway, so it's ok
startingCompound: str = self.getPredominantCompound(compoundsPerLap[0]) startingCompound: str = self.getPredominantCompound(compoundsPerLap[0])
...@@ -172,7 +171,6 @@ class DataAnalyser(DataHandler): ...@@ -172,7 +171,6 @@ class DataAnalyser(DataHandler):
# Returns -1 if no tire change occurred # Returns -1 if no tire change occurred
def getLatestTireChange(self, race: Session): def getLatestTireChange(self, race: Session):
latestTireChangeLap: int = -1
compoundsPerLap: list[list[str]] = self.getCompoundsForRace(race) compoundsPerLap: list[list[str]] = self.getCompoundsForRace(race)
compoundsPerLap[0] = compoundsPerLap[1] # presume grid tires same as 1st lap; races are only picked if weather change after first 10 laps anyway, so it's ok compoundsPerLap[0] = compoundsPerLap[1] # presume grid tires same as 1st lap; races are only picked if weather change after first 10 laps anyway, so it's ok
startingCompound: str = self.getPredominantCompound(compoundsPerLap[0]) startingCompound: str = self.getPredominantCompound(compoundsPerLap[0])
...@@ -182,11 +180,11 @@ class DataAnalyser(DataHandler): ...@@ -182,11 +180,11 @@ class DataAnalyser(DataHandler):
def getFirstLapWithoutCompound(self, compoundsPerLap: list[list[str]], startingCompound: str): def getFirstLapWithoutCompound(self, compoundsPerLap: list[list[str]], startingCompound: str):
currentLap = 0 currentLap = 0
filter = self.setFilter(startingCompound) compoundFilter = self.setFilter(startingCompound)
for compoundsThisLap in compoundsPerLap: for compoundsThisLap in compoundsPerLap:
noStartingCompoundsLeft = True noStartingCompoundsLeft = True
for compound in compoundsThisLap: for compound in compoundsThisLap:
if compound in filter: if compound in compoundFilter:
noStartingCompoundsLeft = False noStartingCompoundsLeft = False
if noStartingCompoundsLeft: return currentLap if noStartingCompoundsLeft: return currentLap
currentLap += 1 currentLap += 1
...@@ -205,8 +203,8 @@ class DataAnalyser(DataHandler): ...@@ -205,8 +203,8 @@ class DataAnalyser(DataHandler):
try: try:
compound = raceLap['Compound'].iloc[0] compound = raceLap['Compound'].iloc[0]
compoundsThisLap.append(compound) compoundsThisLap.append(compound)
except: # triggered when not all drivers that took part reached lap, probably by crashing or being behind except Exception: # triggered when not all drivers that took part reached lap, probably by crashing or being behind
x = 0 # do nothing pass
compoundsPerLap.append(compoundsThisLap) compoundsPerLap.append(compoundsThisLap)
return compoundsPerLap return compoundsPerLap
...@@ -226,11 +224,11 @@ class DataAnalyser(DataHandler): ...@@ -226,11 +224,11 @@ class DataAnalyser(DataHandler):
return 'error' return 'error'
def getFirstLapWithOppositeCompound(self, compoundsPerLap: list[list[str]], startingCompound: str): def getFirstLapWithOppositeCompound(self, compoundsPerLap: list[list[str]], startingCompound: str):
filter = self.setFilter(startingCompound) compoundFilter = self.setFilter(startingCompound)
currentLap = 0 currentLap = 0
for compoundsThisLap in compoundsPerLap: for compoundsThisLap in compoundsPerLap:
for compound in compoundsThisLap: for compound in compoundsThisLap:
if compound not in filter: if compound not in compoundFilter:
return currentLap return currentLap
currentLap += 1 currentLap += 1
return -1 # no lap with opposite compound found; all laps use same compound type return -1 # no lap with opposite compound found; all laps use same compound type
...@@ -243,15 +241,14 @@ class DataAnalyser(DataHandler): ...@@ -243,15 +241,14 @@ class DataAnalyser(DataHandler):
# ===== Crashes ===== # ===== Crashes =====
def analyseRacesForCrashes(self, races): # def analyseRacesForCrashes(self, races):
x = 0
# ===== Events ===== # ===== Events =====
def analyseRacesForSafetyCars(self, races): # def analyseRacesForSafetyCars(self, races):
x = 0
# ===== Other # ===== Other
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment