diff --git a/DataAnalyser.py b/DataAnalyser.py index 1e5ba4be9cbb3630842c9e025bab20cba57d847c..1ae3051e50f96ba13a691fc7738f0966233cb4be 100644 --- a/DataAnalyser.py +++ b/DataAnalyser.py @@ -1,7 +1,7 @@ import pandas as pandas from fastf1.core import Session, Lap, Laps, DataNotLoadedError -from DataHandler import DataHandler, SessionIdentifier +from DataHandler import DataHandler class DataAnalyser(DataHandler): @@ -155,7 +155,6 @@ class DataAnalyser(DataHandler): # Returns -1 if no tire change occurred def getEarliestTireChange(self, race: Session): - earliestTireChangeLap: int = -1 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 startingCompound: str = self.getPredominantCompound(compoundsPerLap[0]) @@ -172,7 +171,6 @@ class DataAnalyser(DataHandler): # Returns -1 if no tire change occurred def getLatestTireChange(self, race: Session): - latestTireChangeLap: int = -1 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 startingCompound: str = self.getPredominantCompound(compoundsPerLap[0]) @@ -182,11 +180,11 @@ class DataAnalyser(DataHandler): def getFirstLapWithoutCompound(self, compoundsPerLap: list[list[str]], startingCompound: str): currentLap = 0 - filter = self.setFilter(startingCompound) + compoundFilter = self.setFilter(startingCompound) for compoundsThisLap in compoundsPerLap: noStartingCompoundsLeft = True for compound in compoundsThisLap: - if compound in filter: + if compound in compoundFilter: noStartingCompoundsLeft = False if noStartingCompoundsLeft: return currentLap currentLap += 1 @@ -205,8 +203,8 @@ class DataAnalyser(DataHandler): try: compound = raceLap['Compound'].iloc[0] compoundsThisLap.append(compound) - except: # triggered when not all drivers that took part reached lap, probably by crashing or being behind - x = 0 # do nothing + except Exception: # triggered when not all drivers that took part reached lap, probably by crashing or being behind + pass compoundsPerLap.append(compoundsThisLap) return compoundsPerLap @@ -226,11 +224,11 @@ class DataAnalyser(DataHandler): return 'error' def getFirstLapWithOppositeCompound(self, compoundsPerLap: list[list[str]], startingCompound: str): - filter = self.setFilter(startingCompound) + compoundFilter = self.setFilter(startingCompound) currentLap = 0 for compoundsThisLap in compoundsPerLap: for compound in compoundsThisLap: - if compound not in filter: + if compound not in compoundFilter: return currentLap currentLap += 1 return -1 # no lap with opposite compound found; all laps use same compound type @@ -243,15 +241,14 @@ class DataAnalyser(DataHandler): # ===== Crashes ===== - def analyseRacesForCrashes(self, races): - x = 0 +# def analyseRacesForCrashes(self, races): # ===== Events ===== - def analyseRacesForSafetyCars(self, races): - x = 0 +# def analyseRacesForSafetyCars(self, races): + # ===== Other