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

Whoopsie I deleted the changes, here they are back again

parent e77919cd
No related branches found
No related tags found
No related merge requests found
......@@ -19,8 +19,6 @@ class DataAnalyser(DataHandler):
return overtakesInRaces
def analyseRaceForOvertakes(self, race: Session):
# Collect grid positions
allLapPositions: List[dict[str, int]] = []
......@@ -46,10 +44,11 @@ class DataAnalyser(DataHandler):
if self.activateDebugOvertakeAnalysis:
print(f"\nLap: 0")
for position in range(len(gridPositions)):
for i in range(len(gridPositions)):
position: int = i + 1
gridPositions.values()
driverAtPosition = list(gridPositions.keys())[list(gridPositions.values()).index(position + 1)] # get dictionary keys (driverIds) by values (current race position)
print(f"P{position + 1}: {driverAtPosition}")
driverAtPosition = self.getDriverByPositionFromMap(gridPositions, position)
print(f"P{position}: {driverAtPosition}")
return gridPositions
......@@ -75,10 +74,11 @@ class DataAnalyser(DataHandler):
for raceLapIndex in range(race.total_laps):
print(f"\nLap: {raceLapIndex + 1}")
runningLapPositions = runningLapsPositions[raceLapIndex]
for position in range(len(runningLapPositions)):
for i in range(len(runningLapPositions)):
runningLapPositions.values()
driverAtPosition = list(runningLapPositions.keys())[list(runningLapPositions.values()).index(position + 1)]
print(f"P{position + 1}: {driverAtPosition}")
position: int = i + 1
driverAtPosition = self.getDriverByPositionFromMap(runningLapPositions, position)
print(f"P{position}: {driverAtPosition}")
return runningLapsPositions
......@@ -110,20 +110,30 @@ class DataAnalyser(DataHandler):
#print(orderToSort[i])
overtakes: int = 0
index: int = 0
while index < len(orderToSort) - 1:
if orderToSort[index] > orderToSort[index + 1]:
temp: int = orderToSort[index]
orderToSort[index] = orderToSort[index + 1]
orderToSort[index + 1] = temp
i: int = 0
while i < len(orderToSort) - 1:
if self.countOutPitstops:
driverPittedThisLap: bool = False
currentDriversEndPosition = orderToSort[i]
driver = self.getDriverByPositionFromMap(endOrder, currentDriversEndPosition)
if orderToSort[i] > orderToSort[i + 1]:
temp: int = orderToSort[i]
orderToSort[i] = orderToSort[i + 1]
orderToSort[i + 1] = temp
overtakes += 1
index = -1
index += 1
i = -1
i += 1
return overtakes
def getDriverByPositionFromMap(self, positions: dict[str, int], position: int):
driver = list(positions.keys())[list(positions.values()).index(position)]
return driver
# ===== Weather =====
def analyseRacesForWeather(self, races: List[Session]):
......@@ -183,6 +193,8 @@ class DataAnalyser(DataHandler):
if noStartingCompoundsLeft: return currentLap
currentLap += 1
return -1 # no lap without compound found; all laps use same compound type
def getCompoundsForRace(self, race: Session):
compoundsPerLap: List[List[str]] = [[]]
......@@ -225,6 +237,7 @@ class DataAnalyser(DataHandler):
if compound not in filter:
return currentLap
currentLap += 1
return -1 # no lap with opposite compound found; all laps use same compound type
def setFilter(self, startingCompound: str):
if startingCompound == 'SLICK': return self.slickCompounds
......
......@@ -7,4 +7,5 @@ class DataHandler(ABC):
self.invalidDriverId = "NO_DRIVER"
self.enableTestingMode = False # only partially import data to speed up testing, because HTTP 429 limits import speed
self.activateDebugOvertakeAnalysis = False
self.slickCompounds = ('SOFT', 'MEDIUM', 'HARD')
\ No newline at end of file
self.slickCompounds = ('SOFT', 'MEDIUM', 'HARD')
self.countOutPitstops = True
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment