Skip to content

Commit

Permalink
Add docstrings, simplify some plotting/metrics methods signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-florentin-charles committed Feb 17, 2024
1 parent 8966c96 commit 5e63447
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/core/models/all_rainfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ def bar_rainfall_averages(
:param monthly: if True, plots monthly rainfall averages.
if False, plots seasonal rainfall averages.
:param begin_year: An integer representing the year
to start getting our rainfall values.
:param end_year: An integer representing the year
to end getting our rainfall values (optional).
:return: A list of the Rainfall averages for each month or season.
"""
label: str = f"Average rainfall (mm) between {begin_year or self.starting_year} and {self.get_last_year()}"
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils/functions/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_average_rainfall(yearly_rainfall: pd.DataFrame, round_precision=2) -> fl
Computes Rainfall average.
:param yearly_rainfall: A pandas DataFrame displaying rainfall data (in mm) according to year.
:param round_precision: A float representing the rainfall precision (optional).
:param round_precision: A float representing the rainfall precision (optional). Defaults to 2.
:return: A float representing the average Rainfall.
"""
nb_years: int = len(yearly_rainfall)
Expand Down Expand Up @@ -68,7 +68,7 @@ def get_normal(yearly_rainfall: pd.DataFrame, begin_year, round_precision=2) ->
:param yearly_rainfall: A pandas DataFrame displaying rainfall data (in mm) according to year.
:param begin_year: A year to start the time frame.
:param round_precision: A float representing the rainfall precision (optional).
:param round_precision: A float representing the rainfall precision (optional). Defaults to 2.
:return: A float storing the normal.
"""

Expand Down
8 changes: 5 additions & 3 deletions src/core/utils/functions/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def plot_column_according_to_year(


def scatter_column_according_to_year(
yearly_rainfall: pd.DataFrame, label: Label, display_label: bool = True
yearly_rainfall: pd.DataFrame, label: Label, display_label=True
) -> bool:
"""
Scatter specified column data according to year.
Expand Down Expand Up @@ -88,7 +88,7 @@ def bar_column_according_to_year(yearly_rainfall: pd.DataFrame, label: Label) ->

def bar_monthly_rainfall_averages(
monthly_rainfalls: dict,
label: str | None = "Average rainfall (mm)",
label="Average rainfall (mm)",
begin_year: int | None = None,
end_year: int | None = None,
) -> list:
Expand All @@ -98,6 +98,7 @@ def bar_monthly_rainfall_averages(
:param monthly_rainfalls: A list of instances of MonthlyRainfall.
To be purposeful, all instances should have the same time frame in years.
:param label: A string to use as a label for bar graphic. (optional)
Defaults to "Average rainfall (mm)".
:param begin_year: An integer representing the year
to start getting our rainfall values (optional).
:param end_year: An integer representing the year
Expand Down Expand Up @@ -140,7 +141,7 @@ def bar_monthly_rainfall_linreg_slopes(monthly_rainfalls: dict) -> list:

def bar_seasonal_rainfall_averages(
seasonal_rainfalls: dict,
label: str | None = "Average rainfall (mm)",
label="Average rainfall (mm)",
begin_year: int | None = None,
end_year: int | None = None,
) -> list:
Expand All @@ -150,6 +151,7 @@ def bar_seasonal_rainfall_averages(
:param seasonal_rainfalls: A list of instances of SeasonalRainfall.
To be purposeful, all instances should have the same time frame in years.
:param label: A string to use as a label for bar graphic. (optional)
Defaults to "Average rainfall (mm)".
:param begin_year: An integer representing the year
to start getting our rainfall values (optional).
:param end_year: An integer representing the year
Expand Down

0 comments on commit 5e63447

Please sign in to comment.