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

Implement enforcement of session type

parent e1be6ba8
No related branches found
No related tags found
No related merge requests found
......@@ -22,8 +22,7 @@ class DataAnalyser(DataHandler):
return overtakesInRaces
def getOvertakesPerLapForRace(self, race: Session):
if not race.session_info["Type"] == "Race":
raise ValueError(f"Session must be a race session, not a {race.session_info["Type"]} session")
self.enforceSessionType(race, "Race")
overtakesInLaps: list[int] = self.countOvertakesPerLap(race)
return overtakesInLaps
......@@ -140,6 +139,9 @@ class DataAnalyser(DataHandler):
return rainSessions
def raceHasWeatherChange(self, race: Session):
if self.getEarliestTireChange(race) == -1: return True
return False
# ===== Tire Changes =====
......@@ -251,3 +253,11 @@ class DataAnalyser(DataHandler):
def analyseRacesForSafetyCars(self, races):
x = 0
# ===== Other
def enforceSessionType(self, session: Session, sessionType: str):
if sessionType not in self.validSessionTypes:
raise ValueError(f"Invalid session type \"{sessionType}\"; only {self.validSessionTypes} are allowed")
if not session.session_info["Type"] == sessionType:
raise ValueError(f"Session must be a {sessionType} session, not a {session.session_info["Type"]} session")
\ No newline at end of file
......@@ -7,6 +7,7 @@ class DataHandler(ABC):
self.invalidDriverId = "NO_DRIVER"
self.activateDebugOvertakeAnalysis = False
self.slickCompounds = ('SOFT', 'MEDIUM', 'HARD')
self.validSessionTypes = ("Practice", "Qualifying", "Race") # TODO: Check if it's called Qualify or Qualifying in the Pandas dataframes
self.countOutPitstops = True
self.firstFastF1Year: int = 2018
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment