From 34c9d4d1fd120ec109dd41247e7185ffe9c07761 Mon Sep 17 00:00:00 2001 From: tomvothecoder Date: Fri, 17 Jan 2025 11:51:47 -0800 Subject: [PATCH] Fix `ruff` issue with `strict=False` in `zip()` --- tests/test_regrid.py | 4 ++-- xcdat/dataset.py | 2 +- xcdat/regridder/grid.py | 2 +- xcdat/temporal.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_regrid.py b/tests/test_regrid.py index 861b0124..64c509a6 100644 --- a/tests/test_regrid.py +++ b/tests/test_regrid.py @@ -664,10 +664,10 @@ def test_map_latitude_coarse_to_fine(self): [[0.29289322]], ] - for x, y in zip(mapping, expected_mapping): + for x, y in zip(mapping, expected_mapping, strict=False): np.testing.assert_allclose(x, y) - for x2, y2 in zip(weights, expected_weigths): + for x2, y2 in zip(weights, expected_weigths, strict=False): np.testing.assert_allclose(x2, y2) def test_map_latitude_fine_to_coarse(self): diff --git a/xcdat/dataset.py b/xcdat/dataset.py index f5139cd2..21932216 100644 --- a/xcdat/dataset.py +++ b/xcdat/dataset.py @@ -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 diff --git a/xcdat/regridder/grid.py b/xcdat/regridder/grid.py index aa4b754b..b9e1ae7f 100644 --- a/xcdat/regridder/grid.py +++ b/xcdat/regridder/grid.py @@ -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] diff --git a/xcdat/temporal.py b/xcdat/temporal.py index 3367e06a..a6853251 100644 --- a/xcdat/temporal.py +++ b/xcdat/temporal.py @@ -1892,7 +1892,7 @@ def _convert_df_to_dt(self, df: pd.DataFrame) -> np.ndarray: dates = [ self.date_type(year, month, day, hour) for year, month, day, hour in zip( - df_new.year, df_new.month, df_new.day, df_new.hour + df_new.year, df_new.month, df_new.day, df_new.hour, strict=False ) ]