Skip to content
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

Fix DeprecationWarning and FutureWarning found in test suite #724

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def generate_multiple_variable_dataset(
var_names = list(["ts"])

if separate_dims:
var_names += list(ds_base.dims.keys()) # type: ignore[arg-type]
var_names += list(ds_base.sizes.keys()) # type: ignore[arg-type]

ds_copy = ds_copy.rename({x: f"{x}{idx+1}" for x in var_names})

Expand Down
6 changes: 3 additions & 3 deletions tests/test_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def test_output_bounds_missing_temporal(self):
decode_times=True, cf_compliant=False, has_bounds=True
)

ds = self.coarse_3d_ds.drop("time_bnds")
ds = self.coarse_3d_ds.drop_vars("time_bnds")

output_grid = grid.create_gaussian_grid(32)

Expand Down Expand Up @@ -517,7 +517,7 @@ def test_unknown_variable(self):
with pytest.raises(KeyError):
regridder.horizontal("unknown", self.coarse_2d_ds)

@pytest.mark.filterwarnings("ignore:.*invalid value.*true_divide.*:RuntimeWarning")
@pytest.mark.filterwarnings("ignore:.*invalid value.*divide.*:RuntimeWarning")
def test_regrid_input_mask(self):
regridder = regrid2.Regrid2Regridder(self.coarse_2d_ds, self.fine_2d_ds)

Expand All @@ -540,7 +540,7 @@ def test_regrid_input_mask(self):

assert np.all(output_data.ts.values == expected_output)

@pytest.mark.filterwarnings("ignore:.*invalid value.*true_divide.*:RuntimeWarning")
@pytest.mark.filterwarnings("ignore:.*invalid value.*divide.*:RuntimeWarning")
def test_regrid_input_mask_unmapped_to_nan(self):
regridder = regrid2.Regrid2Regridder(
self.coarse_2d_ds, self.fine_2d_ds, unmapped_to_nan=False
Expand Down
4 changes: 2 additions & 2 deletions xcdat/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def decode_time(dataset: xr.Dataset) -> xr.Dataset:
"""Decodes CF and non-CF time coordinates and time bounds using ``cftime``.

By default, ``xarray`` only supports decoding time with CF compliant units
[5]_. This function enables also decoding time with non-CF compliant units.
[5]_. This function enables also decoding time with non-CF compliant units.x
It skips decoding time coordinates that have already been decoded as
``"datetime64[ns]"`` or ``cftime.datetime``.

Expand Down Expand Up @@ -652,7 +652,7 @@ def _get_cftime_coords(offsets: np.ndarray, units: str, calendar: str) -> np.nda

# Convert offsets to `np.float64` to avoid "TypeError: unsupported type
# for timedelta days component: numpy.int64".
flat_offsets = flat_offsets.astype("float")
flat_offsets = flat_offsets.astype("float") # type: ignore

# We don't need to do calendar arithmetic here because the units and
# offsets are in "months" or "years", which means leap days should not
Expand Down
2 changes: 1 addition & 1 deletion xcdat/regridder/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _create_gaussian_axis(nlats: int) -> Tuple[xr.DataArray, xr.DataArray]:
},
)

bounds = (180.0 / np.pi) * np.arcsin(bounds)
bounds = (180.0 / np.pi) * np.arcsin(bounds) # type: ignore

bounds_data = np.zeros((points.shape[0], 2))
bounds_data[:, 0] = bounds[:-1]
Expand Down
Loading