Skip to content

Commit

Permalink
Add Input Validation for area_selection method
Browse files Browse the repository at this point in the history
  • Loading branch information
DahyannAraya committed Sep 10, 2024
1 parent 12eb823 commit 6e6c0b1
Show file tree
Hide file tree
Showing 2 changed files with 437 additions and 427 deletions.
12 changes: 8 additions & 4 deletions climada_petals/hazard/copernicus_forecast/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ def get_bounds_for_area_selection(area_selection, margin=0.2):
For country names, the function uses external utilities to convert names to

Check warning on line 197 in climada_petals/hazard/copernicus_forecast/handler.py

View check run for this annotation

Jenkins - WCR / Pylint

trailing-whitespace

LOW: Trailing whitespace
Raw output
Used when there is whitespace between the end of a line and the newline.
ISO codes and fetch geometries. The bounds are then calculated to encompass
all specified countries with the added margin.
"""
"""

Check warning on line 200 in climada_petals/hazard/copernicus_forecast/handler.py

View check run for this annotation

Jenkins - WCR / Pylint

trailing-whitespace

LOW: Trailing whitespace
Raw output
Used when there is whitespace between the end of a line and the newline.
# Validation for valid input format
if not isinstance(area_selection, str):
raise ValueError("area_selection should be a valid string")

Check warning on line 204 in climada_petals/hazard/copernicus_forecast/handler.py

View check run for this annotation

Jenkins - WCR / Pylint

trailing-whitespace

LOW: Trailing whitespace
Raw output
Used when there is whitespace between the end of a line and the newline.
if area_selection.lower() == 'global':

Check warning on line 205 in climada_petals/hazard/copernicus_forecast/handler.py

View check run for this annotation

Jenkins - WCR / Pylint

no-else-return

LOW: Unnecessary "else" after "return"
Raw output
Used in order to highlight an unnecessary block of code following an ifcontaining a return statement. As such, it will warn when it encounters anelse following a chain of ifs, all of them containing a return statement.
return [90, -180, -90, 180] # north, east, south, west
else:
Expand Down Expand Up @@ -236,7 +240,7 @@ def download_multvar_multlead(self, filename, vars, year, month, l_hours, area,
Parameters:
filename (str): Full path and name for the downloaded file.
vars (list of str): List of variable names to download (e.g., ['2m_temperature', '2m_dewpoint_temperature']).
vars (list of str): List of variable names to download (e.g., ['2m_temperature', '2m_dewpoint_temperature']). These are set by the selection of the index to calculate.

Check warning on line 243 in climada_petals/hazard/copernicus_forecast/handler.py

View check run for this annotation

Jenkins - WCR / Pylint

line-too-long

LOW: Line too long (175/100)
Raw output
Used when a line is longer than a given number of characters.
year (int): The forecast initialization year (e.g., 2023).
month (int): The forecast initialization month (1-12, where 1 is January).
l_hours (list of int): List of lead times in hours to download (e.g., [0, 6, 12, 18, 24]).
Expand Down Expand Up @@ -269,10 +273,10 @@ def download_multvar_multlead(self, filename, vars, year, month, l_hours, area,
'originating_centre': originating_centre,
'area': area,
'system': system,
'variable': vars,
'variable': vars,

Check warning on line 276 in climada_petals/hazard/copernicus_forecast/handler.py

View check run for this annotation

Jenkins - WCR / Pylint

trailing-whitespace

LOW: Trailing whitespace
Raw output
Used when there is whitespace between the end of a line and the newline.
'month': f"{month:02d}",
'year': year,
'day': '01',
'day': '01',

Check warning on line 279 in climada_petals/hazard/copernicus_forecast/handler.py

View check run for this annotation

Jenkins - WCR / Pylint

trailing-whitespace

LOW: Trailing whitespace
Raw output
Used when there is whitespace between the end of a line and the newline.
'leadtime_hour': l_hours,
},
f'{download_file}')
Expand Down
Loading

0 comments on commit 6e6c0b1

Please sign in to comment.