From e29c0901bdc6c9096b35bf5f88d839d2c613e124 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 29 Jul 2024 00:46:21 -0700 Subject: [PATCH] use strict zip --- gridlock/draw.py | 8 ++++---- gridlock/grid.py | 2 +- gridlock/read.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gridlock/draw.py b/gridlock/draw.py index 75eccc6..b4b2176 100644 --- a/gridlock/draw.py +++ b/gridlock/draw.py @@ -144,13 +144,13 @@ def draw_polygons( # Find indices in w_xy which are modified by polygon # First for the edge coordinates (+1 since we're indexing edges) - edge_slices = [numpy.s_[i:f + 2] for i, f in zip(corner_min, corner_max)] + edge_slices = [numpy.s_[i:f + 2] for i, f in zip(corner_min, corner_max, strict=True)] # Then for the pixel centers (-bdi_min since we're # calculating weights within a subspace) centers_slice = tuple(numpy.s_[i:f + 1] for i, f in zip(corner_min - bdi_min[surface], - corner_max - bdi_min[surface])) + corner_max - bdi_min[surface], strict=True)) - aa_x, aa_y = (self.shifted_exyz(i)[a][s] for a, s in zip(surface, edge_slices)) + aa_x, aa_y = (self.shifted_exyz(i)[a][s] for a, s in zip(surface, edge_slices, strict=True)) w_xy[centers_slice] += raster(polygon.T, aa_x, aa_y) # Clamp overlapping polygons to 1 @@ -380,7 +380,7 @@ def draw_extrude_rectangle( def f_foreground(xs, ys, zs, i=i, foreground=foreground) -> NDArray[numpy.int_]: # transform from natural position to index xyzi = numpy.array([self.pos2ind(qrs, which_shifts=i) - for qrs in zip(xs.flat, ys.flat, zs.flat)], dtype=int) + for qrs in zip(xs.flat, ys.flat, zs.flat, strict=True)], dtype=int) # reshape to original shape and keep only in-plane components qi, ri = (numpy.reshape(xyzi[:, k], xs.shape) for k in surface) return foreground[qi, ri] diff --git a/gridlock/grid.py b/gridlock/grid.py index d8e9653..2fb721b 100644 --- a/gridlock/grid.py +++ b/gridlock/grid.py @@ -135,7 +135,7 @@ class Grid: list of [dxs, dys, dzs] with each element same length as elements of `self.xyz` """ el = [0 if p else -1 for p in self.periodic] - return [numpy.hstack((self.dxyz[a], self.dxyz[a][e])) for a, e in zip(range(3), el)] + return [numpy.hstack((self.dxyz[a], self.dxyz[a][e])) for a, e in zip(range(3), el, strict=True)] @property def center(self) -> NDArray[numpy.float64]: diff --git a/gridlock/read.py b/gridlock/read.py index 2fe35d5..54afa36 100644 --- a/gridlock/read.py +++ b/gridlock/read.py @@ -72,7 +72,7 @@ def get_slice( # Extract grid values from planes above and below visualized slice sliced_grid = numpy.zeros(self.shape[surface]) - for ci, weight in zip(centers, w): + for ci, weight in zip(centers, w, strict=True): s = tuple(ci if a == surface_normal else numpy.s_[::sp] for a in range(3)) sliced_grid += weight * cell_data[which_shifts][tuple(s)] @@ -193,7 +193,7 @@ def visualize_isosurface( ybs = 0.5 * max_range * mg[1].flatten() + 0.5 * (ys.max() + ys.min()) zbs = 0.5 * max_range * mg[2].flatten() + 0.5 * (zs.max() + zs.min()) # Comment or uncomment following both lines to test the fake bounding box: - for xb, yb, zb in zip(xbs, ybs, zbs): + for xb, yb, zb in zip(xbs, ybs, zbs, strict=True): ax.plot([xb], [yb], [zb], 'w') if finalize: