Skip to content

Commit 01ee0e7

Browse files
committed
patch mypy errors
Some errors due to grid iheritence hierarchy which aren't trivial to fix
1 parent c9902ad commit 01ee0e7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

parcels/_index_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def search_indices_vertical_s(
7979
eta = 1
8080
if time < grid.time[ti]:
8181
ti -= 1
82-
if grid._z4d:
82+
if grid._z4d: # type: ignore[attr-defined]
8383
if ti == len(grid.time) - 1:
8484
depth_vector = (
8585
(1 - xsi) * (1 - eta) * grid.depth[-1, :, yi, xi]
@@ -232,7 +232,7 @@ def _search_indices_curvilinear(field: Field, time, z, y, x, ti=-1, particle=Non
232232
else:
233233
xi = int(field.grid.xdim / 2) - 1
234234
yi = int(field.grid.ydim / 2) - 1
235-
xsi = eta = -1
235+
xsi = eta = -1.0
236236
grid = field.grid
237237
invA = np.array([[1, 0, 0, 0], [-1, 1, 0, 0], [-1, 0, 0, 1], [1, -1, 1, -1]])
238238
maxIterSearch = 1e6

parcels/_interpolation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _linear_invdist_land_tracer_2d(ctx: InterpolationContext2D) -> float:
146146
return 0
147147
elif nb_land > 0:
148148
val = 0
149-
w_sum = 0
149+
w_sum = 0.0
150150
for j in range(2):
151151
for i in range(2):
152152
distance = pow((eta - j), 2) + pow((xsi - i), 2)
@@ -196,8 +196,8 @@ def _linear_invdist_land_tracer_3d(ctx: InterpolationContext3D) -> float:
196196
if nb_land == 8:
197197
return 0
198198
elif nb_land > 0:
199-
val = 0
200-
w_sum = 0
199+
val = 0.0
200+
w_sum = 0.0
201201
for k in range(2):
202202
for j in range(2):
203203
for i in range(2):

parcels/grid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ def _calc_cell_edge_sizes(grid: RectilinearGrid) -> None:
830830
attribute to the grid.
831831
"""
832832
if not grid.cell_edge_sizes:
833-
if grid._gtype in (GridType.RectilinearZGrid, GridType.RectilinearSGrid):
833+
if grid._gtype in (GridType.RectilinearZGrid, GridType.RectilinearSGrid): # type: ignore[attr-defined]
834834
grid.cell_edge_sizes["x"] = np.zeros((grid.ydim, grid.xdim), dtype=np.float32)
835835
grid.cell_edge_sizes["y"] = np.zeros((grid.ydim, grid.xdim), dtype=np.float32)
836836

@@ -842,7 +842,7 @@ def _calc_cell_edge_sizes(grid: RectilinearGrid) -> None:
842842
grid.cell_edge_sizes["y"][y, x] = y_conv.to_source(dy, grid.depth[0], lat, lon)
843843
else:
844844
raise ValueError(
845-
f"_cell_edge_sizes() not implemented for {grid._gtype} grids. "
845+
f"_cell_edge_sizes() not implemented for {grid._gtype} grids. " # type: ignore[attr-defined]
846846
"You can provide Field.grid.cell_edge_sizes yourself by in, e.g., "
847847
"NEMO using the e1u fields etc from the mesh_mask.nc file."
848848
)

0 commit comments

Comments
 (0)