-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopt ruff
as the central tool for linting, formatting, and import sorting
#702
Changes from all commits
ad1af20
7391a2a
569db3a
7b24935
2990ec8
aaa82ea
73f7840
545d19b
8fe33d9
03d350e
e7148e2
d772566
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""This module stores reusable test fixtures.""" | ||
|
||
from typing import Literal | ||
|
||
import cftime | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,7 +204,12 @@ def test_methods(self): | |
xgcm.XGCMRegridder(self.ds, self.output_grid, method="linear", target_data=None) | ||
|
||
with pytest.raises(ValueError, match="'dummy' is invalid, possible choices"): | ||
xgcm.XGCMRegridder(self.ds, self.output_grid, method="dummy", target_data=None) # type: ignore | ||
xgcm.XGCMRegridder( | ||
self.ds, | ||
self.output_grid, | ||
method="dummy", # type: ignore | ||
target_data=None, | ||
) | ||
|
||
def test_missing_input_z_coord(self): | ||
ds = fixtures.generate_dataset( | ||
|
@@ -663,7 +668,7 @@ def test_map_latitude_coarse_to_fine(self): | |
np.testing.assert_allclose(x, y) | ||
|
||
for x2, y2 in zip(weights, expected_weigths): | ||
np.testing.assert_allclose(x, y) | ||
np.testing.assert_allclose(x2, y2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
def test_map_latitude_fine_to_coarse(self): | ||
mapping, weights = regrid2._map_latitude( | ||
|
@@ -1254,7 +1259,7 @@ def test_grid(self): | |
ValueError, | ||
match=r".*lon\d?.*lon\d?.*", | ||
): | ||
ds_multi.regridder.grid | ||
ds_multi.regridder.grid # noqa: B018 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignores B018 - useless-expression |
||
|
||
def test_grid_raises_error_when_dataset_has_multiple_dims_for_an_axis(self): | ||
ds_bounds = fixtures.generate_dataset( | ||
|
@@ -1265,7 +1270,7 @@ def test_grid_raises_error_when_dataset_has_multiple_dims_for_an_axis(self): | |
) | ||
|
||
with pytest.raises(ValueError): | ||
ds_bounds.regridder.grid | ||
ds_bounds.regridder.grid # noqa: B018 | ||
|
||
@mock.patch("xcdat.regridder.accessor._get_input_grid") | ||
def test_horizontal_tool_check(self, _get_input_grid): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Top-level package for xcdat.""" | ||
|
||
from xcdat.axis import ( # noqa: F401 | ||
center_times, | ||
get_dim_coords, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Logger module for setting up a logger.""" | ||
|
||
import logging | ||
import logging.handlers | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
"""Bounds module for functions related to coordinate bounds.""" | ||
|
||
from __future__ import annotations | ||
|
||
import collections | ||
import datetime | ||
import warnings | ||
from typing import Dict, List, Literal, Optional, Union | ||
from typing import Dict, List, Literal, Optional, Tuple, Union | ||
|
||
import cf_xarray as cfxr # noqa: F401 | ||
import cftime | ||
|
@@ -124,7 +127,7 @@ def keys(self) -> List[str]: | |
) | ||
|
||
def add_missing_bounds( # noqa: C901 | ||
self, axes: List[CFAxisKey] = ["X", "Y", "T"] | ||
self, axes: List[CFAxisKey] | Tuple[CFAxisKey, ...] = ("X", "Y", "T") | ||
) -> xr.Dataset: | ||
Comment on lines
129
to
131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"""Adds missing coordinate bounds for supported axes in the Dataset. | ||
|
||
|
@@ -153,9 +156,9 @@ def add_missing_bounds( # noqa: C901 | |
|
||
Parameters | ||
---------- | ||
axes : List[str] | ||
axes : List[CFAxesKey] | Tuple[CFAxisKey, ...] | ||
List of CF axes that function should operate on, by default | ||
["X", "Y", "T"]. Options include "X", "Y", "T", or "Z". | ||
("X", "Y", "T"). Options include "X", "Y", "T", or "Z". | ||
|
||
Returns | ||
------- | ||
|
@@ -614,7 +617,11 @@ def _create_time_bounds( # noqa: C901 | |
hrs = diff.seconds / 3600 | ||
daily_subfreq = int(24 / hrs) # type: ignore | ||
|
||
time_bnds = self._create_daily_time_bounds(timesteps, obj_type, freq=daily_subfreq) # type: ignore | ||
time_bnds = self._create_daily_time_bounds( | ||
timesteps, | ||
obj_type, | ||
freq=daily_subfreq, # type: ignore | ||
) | ||
|
||
# Create the bounds data array | ||
da_time_bnds = xr.DataArray( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes B007 - unused-loop-control-variable