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
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment