Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] authored Feb 10, 2025
1 parent 60d21fc commit 54e3c1d
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ repos:
- id: requirements-txt-fixer

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down
12 changes: 6 additions & 6 deletions icepyx/core/APIformatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ def check_req_values(self) -> bool:
the values parameter.
"""

assert (
self.partype == "required"
), "You cannot call this function for your parameter type"
assert self.partype == "required", (
"You cannot call this function for your parameter type"
)

if not self._reqtype:
raise TypeGuardException
Expand All @@ -381,9 +381,9 @@ def check_values(self) -> bool:
Check that the non-required keys have values, if the key was
passed in with the values parameter.
"""
assert (
self.partype != "required"
), "You cannot call this function for your parameter type"
assert self.partype != "required", (
"You cannot call this function for your parameter type"
)

spatial_keys = self.poss_keys["spatial"]

Expand Down
18 changes: 9 additions & 9 deletions icepyx/core/granules.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ def get_avail(
query.Query.avail_granules
"""

assert (
CMRparams is not None and reqparams is not None
), "Missing required input parameter dictionaries"
assert CMRparams is not None and reqparams is not None, (
"Missing required input parameter dictionaries"
)

# if not hasattr(self, 'avail'):
self.avail = []
Expand Down Expand Up @@ -260,17 +260,17 @@ def get_avail(

results = json.loads(response.content)
if not results["feed"]["entry"]:
assert len(self.avail) == int(
response.headers["CMR-Hits"]
), "Search failure - unexpected number of results"
assert len(self.avail) == int(response.headers["CMR-Hits"]), (
"Search failure - unexpected number of results"
)
break

# Collect results
self.avail.extend(results["feed"]["entry"])

assert (
len(self.avail) > 0
), "Your search returned no results; try different search parameters"
assert len(self.avail) > 0, (
"Your search returned no results; try different search parameters"
)

# DevNote: currently, default subsetting DOES NOT include variable subsetting,
# only spatial and temporal
Expand Down
21 changes: 10 additions & 11 deletions icepyx/core/is2ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,16 @@ def _validate_OA_product(product):
"""
if isinstance(product, str):
product = str.upper(product)
assert (
product
in [
"ATL06",
"ATL07",
"ATL08",
"ATL10",
"ATL12",
"ATL13",
]
), "Oops! Elevation visualization only supports products ATL06, ATL07, ATL08, ATL10, ATL12, ATL13; please try another product."
assert product in [
"ATL06",
"ATL07",
"ATL08",
"ATL10",
"ATL12",
"ATL13",
], (
"Oops! Elevation visualization only supports products ATL06, ATL07, ATL08, ATL10, ATL12, ATL13; please try another product."
)
else:
raise TypeError("Please enter a product string")
return product
Expand Down
44 changes: 22 additions & 22 deletions icepyx/core/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def check_dateline(extent_type, spatial_extent):

# this works properly, but limits the user to at most 270 deg longitude...
elif extent_type == "polygon":
assert not isinstance(
spatial_extent[0], (list, tuple)
), "Your polygon list is the wrong format for this function."
assert not isinstance(spatial_extent[0], (list, tuple)), (
"Your polygon list is the wrong format for this function."
)
lonlist = spatial_extent[0:-1:2]
if np.any(
[abs(lonlist[i] - lonlist[i + 1]) > 270 for i in range(len(lonlist) - 1)]
Expand Down Expand Up @@ -191,19 +191,19 @@ def validate_bounding_box(spatial_extent):
"""

# Latitude must be between -90 and 90 (inclusive); check for this here
assert (
-90 <= spatial_extent[1] <= 90
), "Invalid latitude value (must be between -90 and 90, inclusive)"
assert (
-90 <= spatial_extent[3] <= 90
), "Invalid latitude value (must be between -90 and 90, inclusive)"

assert (
-180 <= spatial_extent[0] <= 180
), "Invalid longitude value (must be between -180 and 180, inclusive)"
assert (
-180 <= spatial_extent[2] <= 180
), "Invalid longitude value (must be between -180 and 180, inclusive)"
assert -90 <= spatial_extent[1] <= 90, (
"Invalid latitude value (must be between -90 and 90, inclusive)"
)
assert -90 <= spatial_extent[3] <= 90, (
"Invalid latitude value (must be between -90 and 90, inclusive)"
)

assert -180 <= spatial_extent[0] <= 180, (
"Invalid longitude value (must be between -180 and 180, inclusive)"
)
assert -180 <= spatial_extent[2] <= 180, (
"Invalid longitude value (must be between -180 and 180, inclusive)"
)

# If the lower left latitude is greater than the upper right latitude, throw an error
assert spatial_extent[1] <= spatial_extent[3], "Invalid bounding box latitudes"
Expand Down Expand Up @@ -292,9 +292,9 @@ def validate_polygon_list(spatial_extent):

# user-entered polygon as a single list of lon and lat coordinates
assert len(spatial_extent) >= 8, "Your spatial extent polygon has too few vertices"
assert (
len(spatial_extent) % 2 == 0
), "Your spatial extent polygon list should have an even number of entries"
assert len(spatial_extent) % 2 == 0, (
"Your spatial extent polygon list should have an even number of entries"
)

if (spatial_extent[0] != spatial_extent[-2]) or (
spatial_extent[1] != spatial_extent[-1]
Expand Down Expand Up @@ -346,9 +346,9 @@ def validate_polygon_file(spatial_extent):
# Check if the filename path exists; if not, throw an error
# print("print statements work \n")
# print("SPATIAL EXTENT: " + spatial_extent + "\n")
assert os.path.exists(
spatial_extent
), "Check that the path and filename of your geometry file are correct"
assert os.path.exists(spatial_extent), (
"Check that the path and filename of your geometry file are correct"
)

# DevGoal: more robust polygon inputting (see Bruce's code):
# correct for clockwise/counterclockwise coordinates, deal with simplification, etc.
Expand Down
6 changes: 3 additions & 3 deletions icepyx/core/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def check_valid_date_range(start: dt.date, end: dt.date) -> None:
start = start.date()
if isinstance(end, dt.datetime):
end = end.date()
assert (
start <= end
), "Your date range is invalid; end date MUST be on or after the start date."
assert start <= end, (
"Your date range is invalid; end date MUST be on or after the start date."
)


def validate_times(
Expand Down
8 changes: 6 additions & 2 deletions icepyx/core/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ def append(self, defaults=False, var_list=None, beam_list=None, keyword_list=Non
and var_list is None
and beam_list is None
and keyword_list is None
), "You must enter parameters to add to a variable subset list. If you do not want to subset by variable, ensure your is2.subsetparams dictionary does not contain the key 'Coverage'."
), (
"You must enter parameters to add to a variable subset list. If you do not want to subset by variable, ensure your is2.subsetparams dictionary does not contain the key 'Coverage'."
)

final_vars = {}

Expand Down Expand Up @@ -564,7 +566,9 @@ def remove(self, all=False, var_list=None, beam_list=None, keyword_list=None):
and var_list is None
and beam_list is None
and keyword_list is None
), "You must specify which variables/paths/beams you would like to remove from your wanted list."
), (
"You must specify which variables/paths/beams you would like to remove from your wanted list."
)

# if not hasattr(self, 'avail'): self.get_avail()
# vgrp, paths = self.parse_var_list(self.avail)
Expand Down
6 changes: 3 additions & 3 deletions icepyx/core/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,9 @@ def parallel_request_OA(self) -> da.array:
# generate parameter lists for OA requesting
OA_para_list = self.generate_OA_parameters()

assert (
OA_para_list
), "Your search returned no results; try different search parameters"
assert OA_para_list, (
"Your search returned no results; try different search parameters"
)

url_number = len(OA_para_list)

Expand Down
14 changes: 7 additions & 7 deletions icepyx/quest/dataset_scripts/argo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Argo(DataSet):
To search for all parameters, use `params=["all"]`;
be careful using all for floats with BGC data, as this may be result in a large download.
presRange : str, default None
The pressure range (which correllates with depth) to search for data within.
The pressure range (which correlates with depth) to search for data within.
Input as a "shallow-limit,deep-limit" string.
See Also
Expand Down Expand Up @@ -223,10 +223,10 @@ def _validate_parameters(self, params) -> list:
valid_params = self._valid_params()
# checks that params are valid
for i in params:
assert (
i in valid_params
), "Parameter '{0}' is not valid. Valid parameters are {1}".format(
i, valid_params
assert i in valid_params, (
"Parameter '{0}' is not valid. Valid parameters are {1}".format(
i, valid_params
)
)

return list(set(params))
Expand All @@ -252,7 +252,7 @@ def search_data(self, params=None, presRange=None, printURL=False) -> str:
To search for all parameters, use `params=["all"]`;
be careful using all for floats with BGC data, as this may be result in a large download.
presRange : str, default None
The pressure range (which correllates with depth) to search for data within.
The pressure range (which correlates with depth) to search for data within.
This kwarg is used to replace the existing pressure range in `self.presRange`.
Do not submit this kwarg if you would like to use the existing `self.presRange` values.
Input as a "shallow-limit,deep-limit" string.
Expand Down Expand Up @@ -421,7 +421,7 @@ def download(self, params=None, presRange=None, keep_existing=True) -> pd.DataFr
To search for all parameters, use `params=["all"]`.
For a list of available parameters, see: `reg._valid_params`
presRange : str, default None
The pressure range (which correllates with depth) to search for data within.
The pressure range (which correlates with depth) to search for data within.
This kwarg is used to replace the existing pressure range in `self.presRange`.
Do not submit this kwarg if you would like to use the existing `self.presRange` values.
Input as a "shallow-limit,deep-limit" string.
Expand Down
8 changes: 2 additions & 6 deletions icepyx/tests/unit/test_quest_argo.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ def test_search_data_no_available_profiles(argo_quest_instance):
reg_a = argo_quest_instance([-55, 68, -48, 71], ["2019-02-20", "2019-02-28"])
obs = reg_a.search_data()

exp = (
"Warning: Query returned no profiles\n" "Please try different search parameters"
)
exp = "Warning: Query returned no profiles\nPlease try different search parameters"

assert obs == exp

Expand Down Expand Up @@ -198,9 +196,7 @@ def test_replace_param_search(argo_quest_instance):

obs = reg_a.search_data(params=["doxy"])

exp = (
"Warning: Query returned no profiles\n" "Please try different search parameters"
)
exp = "Warning: Query returned no profiles\nPlease try different search parameters"

assert obs == exp

Expand Down

0 comments on commit 54e3c1d

Please sign in to comment.