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

Add documentation

parent c3e25ad1
No related branches found
No related tags found
No related merge requests found
......@@ -140,21 +140,26 @@ class DataAnalyser(DataHandler):
return rainSessions
def raceHasWeatherChange(self, race: Session):
if self.getEarliestTireChange(race) == -1: return True
if self.getFirstTireChange(race) == -1: return True
return False
# ===== Tire Changes =====
def getEarliestTireChanges(self, races: list[Session]):
def getFirstTireChanges(self, races: list[Session]):
earliestTireChanges: list[int] = [[]] # isRaining per lap per race
for race in races:
earliestTireChange = self.getEarliestTireChange(race)
earliestTireChange = self.getFirstTireChange(race)
earliestTireChanges.append(earliestTireChange)
return earliestTireChanges
# Returns -1 if no tire change occurred
def getEarliestTireChange(self, race: Session):
def getFirstTireChange(self, race: Session):
"""
Determines the first lap in which a tire change to a different weather compound was done.
:param race: Race session in which to look for a tire change.
:return: Lap number in which the first tire change to a different weather compound took place. Returns -1 if no
such tire change took place.
"""
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])
......@@ -162,15 +167,20 @@ class DataAnalyser(DataHandler):
return earliestTireChangeLap
def getLatestTireChanges(self, races: list[Session]):
def getLastTireChanges(self, races: list[Session]):
latestTireChanges: list[int] = [[]] # isRaining per lap per race
for race in races:
latestTireChange = self.getLatestTireChange(race)
latestTireChange = self.getLastTireChange(race)
latestTireChanges.append(latestTireChange)
return latestTireChanges
# Returns -1 if no tire change occurred
def getLatestTireChange(self, race: Session):
def getLastTireChange(self, race: Session):
"""
Determines the last lap in which a tire change to a different weather compound was done.
:param race: Race session in which to look for a tire change.
:return: Lap number in which the last tire change to a different weather compound took place. Returns -1 if no
such tire change took place.
"""
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])
......
......@@ -57,9 +57,9 @@ class Main:
overtakesInRaces: list[int] = dataHandler.analyser.getOvertakesPerLapForRace(raceSession)
print("Overtake analysis done")
# weatherInRaces = analyser.analyseRaceForWeather(raceSession)
earliestTireChange: int = dataHandler.analyser.getEarliestTireChange(raceSession) # first lap where someone switched from slicks to non slicks or vice versa, denoted by lap number
earliestTireChange: int = dataHandler.analyser.getFirstTireChange(raceSession) # first lap where someone switched from slicks to non slicks or vice versa, denoted by lap number
print("First tire change done")
latestTireChange: int = dataHandler.analyser.getLatestTireChange(raceSession)
latestTireChange: int = dataHandler.analyser.getLastTireChange(raceSession)
print("Last tire change done")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment