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

Fix typos

parent a3b274a7
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,12 @@ from DataHandler import DataHandler, SessionIdentifier ...@@ -5,12 +5,12 @@ from DataHandler import DataHandler, SessionIdentifier
class DataAnalyser(DataHandler): class DataAnalyser(DataHandler):
''' """
Analyses sessions by extrapolating existing or new data from them. Analyses sessions by extrapolating existing or new data from them.
Any method of this class must be given a Session object or a list thereof. If the method does not require such an Any method of this class must be given a Session object or a list thereof. If the method does not require such an
object, it should not be part of this class. object, it should not be part of this class.
''' """
# ===== Overtakes ===== # ===== Overtakes =====
...@@ -57,15 +57,15 @@ class DataAnalyser(DataHandler): ...@@ -57,15 +57,15 @@ class DataAnalyser(DataHandler):
return overtakes return overtakes
def prepareWeightedOrderFromLap(self, lapNumber: int, race: Session): def prepareWeightedOrderFromLap(self, lapNumber: int, race: Session):
'''Prepare a list from specific lap & race, that can be sorted via bubble sort to determine the number of """Prepare a list from specific lap & race, that can be sorted via bubble sort to determine the number of
overtakes that occured in that lap. overtakes that occurred in that lap.
:param lapNumber: Which lap to prepare from the given race. Note that value of 1 will return a list ordered by :param lapNumber: Which lap to prepare from the given race. Note that value of 1 will return a list ordered by
starting grid, as there is no previous lap. starting grid, as there is no previous lap.
:param race: Race from which to pull the given lap from. :param race: Race from which to pull the given lap from.
:return: list[(Lap, int)]: A list with pairs of every driver's lap and their position at the end of the lap. Entries are :return: list[(Lap, int)]: A list with pairs of every driver's lap and their position at the end of the lap. Entries are
sorted by the driver's positions at the start of the lap. If an invalid lap number (below 1 or above the number sorted by the driver's positions at the start of the lap. If an invalid lap number (below 1 or above the number
of laps the race had), all laps in the list will be either None objects or empty Panda Dataframes. of laps the race had), all laps in the list will be either None objects or empty Panda Dataframes.
''' """
previousLaps: Laps = race.laps.pick_laps(lapNumber - 1) previousLaps: Laps = race.laps.pick_laps(lapNumber - 1)
currentLaps: Laps = race.laps.pick_laps(lapNumber) currentLaps: Laps = race.laps.pick_laps(lapNumber)
...@@ -117,15 +117,15 @@ class DataAnalyser(DataHandler): ...@@ -117,15 +117,15 @@ class DataAnalyser(DataHandler):
# ===== Weather ===== # ===== Weather =====
def filterForRainSessions(self, sessions: list[Session]): def filterForRainSessions(self, sessions: list[Session]):
''' """
Filter out & return only those sessions from input list that had rain falling at any point during the session. Filter out & return only those sessions from input list that had rain falling at any point during the session.
Note: The sessions returned are not necessarily sessions that had wet conditions for any meaningful amount of Note: The sessions returned are not necessarily sessions that had wet conditions for any meaningful amount of
time. Also, sessions that had wet conditions only from leftover rainwater on track are not included in the time. Also, sessions that had wet conditions only from leftover rainwater on track are not included in the
returned sessions, as no rain occured during the session. This is due to technical limitations. returned sessions, as no rain occurred during the session. This is due to technical limitations.
:param sessions: List of sessions from which to pick out sessions with rain. :param sessions: List of sessions from which to pick out sessions with rain.
:return: List of sessions which had rain falling during the session for any amount of time. :return: List of sessions which had rain falling during the session for any amount of time.
''' """
rainSessions: list[Session] = [] rainSessions: list[Session] = []
for session in sessions: for session in sessions:
...@@ -153,11 +153,11 @@ class DataAnalyser(DataHandler): ...@@ -153,11 +153,11 @@ class DataAnalyser(DataHandler):
earliestTireChanges.append(earliestTireChange) earliestTireChanges.append(earliestTireChange)
return earliestTireChanges return earliestTireChanges
# Returns -1 if no tire change occured # Returns -1 if no tire change occurred
def getEarliestTireChange(self, race: Session): def getEarliestTireChange(self, race: Session):
earliestTireChangeLap: int = -1 earliestTireChangeLap: int = -1
compoundsPerLap: list[list[str]] = self.getCompoundsForRace(race) 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 anyways, so its ok 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]) startingCompound: str = self.getPredominantCompound(compoundsPerLap[0])
earliestTireChangeLap = self.getFirstLapWithOppositeCompound(compoundsPerLap, startingCompound) earliestTireChangeLap = self.getFirstLapWithOppositeCompound(compoundsPerLap, startingCompound)
...@@ -170,11 +170,11 @@ class DataAnalyser(DataHandler): ...@@ -170,11 +170,11 @@ class DataAnalyser(DataHandler):
latestTireChanges.append(latestTireChange) latestTireChanges.append(latestTireChange)
return latestTireChanges return latestTireChanges
# Returns -1 if no tire change occured # Returns -1 if no tire change occurred
def getLatestTireChange(self, race: Session): def getLatestTireChange(self, race: Session):
latestTireChangeLap: int = -1 latestTireChangeLap: int = -1
compoundsPerLap: list[list[str]] = self.getCompoundsForRace(race) 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 anyways, so its ok 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]) startingCompound: str = self.getPredominantCompound(compoundsPerLap[0])
latestTireChangeLap = self.getFirstLapWithoutCompound(compoundsPerLap, startingCompound) latestTireChangeLap = self.getFirstLapWithoutCompound(compoundsPerLap, startingCompound)
......
from abc import ABC from abc import ABC
class DataHandler(ABC): class DataHandler(ABC):
'''Defines variables that are needed for any type of interaction with FastF1's data. Any class utilizing FastF1 """Defines variables that are needed for any type of interaction with FastF1's data. Any class utilizing FastF1
data in any way should be a subclass of the DataHandler class to inherit these variables.''' data in any way should be a subclass of the DataHandler class to inherit these variables."""
def __init__(self): def __init__(self):
self.numberOfDrivers = 20 self.numberOfDrivers = 20
...@@ -14,10 +14,10 @@ class DataHandler(ABC): ...@@ -14,10 +14,10 @@ class DataHandler(ABC):
self.firstFastF1Year: int = 2018 self.firstFastF1Year: int = 2018
class SessionIdentifier: class SessionIdentifier:
'''Uniquely identifies a single session without having to load or create the Session object''' """Uniquely identifies a single Formula 1 session without having to load or create a Session object"""
year: int year: int
event: int | str event: int | str # Either the event name or the round number of the event during that year/season
sessionType: str sessionType: str
def __init__(self, year: int, event: int | str, sessionType: str = "R"): def __init__(self, year: int, event: int | str, sessionType: str = "R"):
...@@ -27,9 +27,9 @@ class SessionIdentifier: ...@@ -27,9 +27,9 @@ class SessionIdentifier:
class WeatherChangeWindow: class WeatherChangeWindow:
'''Identifies a window of laps, during which a weather change took place. A WeatherChangeWindow is itself not """Identifies a window of laps during which a weather change took place. A WeatherChangeWindow is not
associated with a SessionObject or a SessionIdentifier. This association must be made and maintained by whatever associated with a SessionObject or a SessionIdentifier by itself. This association must be made and maintained by whatever
object or function is using an object of this class.''' object or function is using an object of this class."""
firstLap: int firstLap: int
lastLap: int lastLap: int
......
...@@ -9,12 +9,12 @@ from DataHandler import DataHandler, SessionIdentifier ...@@ -9,12 +9,12 @@ from DataHandler import DataHandler, SessionIdentifier
class DataImporter(DataHandler, ABC): class DataImporter(DataHandler, ABC):
''' """
Imports/loads sessions as specified by SessionIdentifiers and/or certain criteria such as rain. Imports/loads sessions as specified by SessionIdentifiers and/or certain criteria such as rain.
Any method of this class must be given a SessionIdentifier, a time or a time period by which to select Any method of this class must be given a SessionIdentifier, a time or a time period by which to select
sessions. If the method does not require one of these, it should not be part of this class. sessions. If the method does not require one of these, it should not be part of this class.
''' """
def importAllEventsFromYear(self, year: int): def importAllEventsFromYear(self, year: int):
...@@ -25,12 +25,12 @@ class DataImporter(DataHandler, ABC): ...@@ -25,12 +25,12 @@ class DataImporter(DataHandler, ABC):
return races return races
def importSessionWeather(self, sessionIdentifier: SessionIdentifier): def importSessionWeather(self, sessionIdentifier: SessionIdentifier):
''' """
Import a session containing only weather data. Import a session containing only weather data.
:param sessionIdentifier: Session to import. Note that only races after 2017 can import weather, as session data :param sessionIdentifier: Session to import. Note that only races after 2017 can import weather, as session data
before 2018 is provided by the Ergast/Jolpica API, which does not contain weather data. before 2018 is provided by the Ergast/Jolpica API, which does not contain weather data.
:return: Session object containing only weather data and basic session information. :return: Session object containing only weather data and basic session information.
''' """
return self.importSession(sessionIdentifier, laps = False, telemetry = False, weather = True, messages = False) return self.importSession(sessionIdentifier, laps = False, telemetry = False, weather = True, messages = False)
def importSessions(self, sessionIdentifiers: list[SessionIdentifier], laps = True, telemetry = False, weather = False, messages = False): def importSessions(self, sessionIdentifiers: list[SessionIdentifier], laps = True, telemetry = False, weather = False, messages = False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment