diff --git a/data_tools/lap_tools/lap_query.py b/data_tools/lap_tools/lap_query.py index 27adf19..b8a311c 100644 --- a/data_tools/lap_tools/lap_query.py +++ b/data_tools/lap_tools/lap_query.py @@ -6,34 +6,35 @@ def collect_lap_data(query_func: Callable, client: DBClient, include_day_2=False, verbose=False) -> np.ndarray: """ - Higher order function - computes `query_func` for each lap in FSGP 2024 and returns the resulting array. + Higher order function - computes ``query_func`` for each lap in FSGP 2024 and returns the resulting array. - Set `include_day_2` to True to include the day 2 laps, which were driven slowly & under heavy rain. + Set ``include_day_2`` to True to include the day 2 laps, which were driven slowly & under heavy rain. Example usage: - ```python - from data_tools.collections import collect_lap_data, TimeSeries - from data_tools.query import DBClient - import datetime - import numpy as np - - - def get_average_speed(start_time: datetime.datetime, end_time: datetime.datetime, data_client: DBClient): - lap_speed: TimeSeries = data_client.query_time_series(start_time, end_time, "VehicleVelocity") - return np.mean(lap_speed) - - - client = DBClient() - - average_speeds = collect_lap_data(get_average_speed, client) - ``` - - :param Callable query_func: must take in parameters (lap_start: datetime, lap_end:datetime, data_client:DBClient) + :: + + from data_tools.collections import collect_lap_data, TimeSeries + from data_tools.query import DBClient + import datetime + import numpy as np + def get_average_speed(start_time: datetime.datetime, end_time: datetime.datetime, data_client: DBClient): + lap_speed: TimeSeries = data_client.query_time_series(start_time, end_time, "VehicleVelocity") + return np.mean(lap_speed) + client = DBClient() + average_speeds = collect_lap_data(get_average_speed, client) + + :param Callable query_func: + must take in the following parameters: + :: + lap_start: datetime + lap_end: datetime + data_client: DBClient + ``query_func`` will be passed in the above parameters for each specified lap and may return an arbitrary output to be stored in the output array. :param DBClient client: client to use for querying :param include_day_2: flag to include the three day 2 laps, driven slowly & under heavy rain - :param verbose: if True, print out queried data during execution - :return: a NumPy ndarray of `query_func` results for all laps + :param verbose: if ``True``, print out queried data during execution + :return: a NumPy ndarray of ``query_func`` results for all laps """ if include_day_2: diff --git a/docs/source/api.rst b/docs/source/api.rst index 8a441bd..96252f8 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -9,3 +9,4 @@ API Reference Collections Querying Tools + Lap Tools diff --git a/docs/source/lap_tools/index.rst b/docs/source/lap_tools/index.rst new file mode 100644 index 0000000..fc389b2 --- /dev/null +++ b/docs/source/lap_tools/index.rst @@ -0,0 +1,4 @@ +.. automodule:: data_tools.lap_tools + :no-members: + :no-inherited-members: + :no-special-members: