Skip to content

Commit 76f4b85

Browse files
committed
Added strict keyword argument to zip
1 parent 1460749 commit 76f4b85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+105
-77
lines changed

pySDC/helpers/blocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def ranks(self):
102102
@property
103103
def localBounds(self):
104104
iLocList, nLocList = [], []
105-
for rank, nPoints, nBlocks in zip(self.ranks, self.gridSizes, self.nBlocks):
105+
for rank, nPoints, nBlocks in zip(self.ranks, self.gridSizes, self.nBlocks, strict=True):
106106
n0 = nPoints // nBlocks
107107
nRest = nPoints - nBlocks * n0
108108
nLoc = n0 + 1 * (rank < nRest)

pySDC/helpers/fieldsIO.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def writeFields_MPI(fileName, dtypeIdx, algo, nSteps, nVar, gridSizes):
714714

715715
iLoc, nLoc = blocks.localBounds
716716
Rectilinear.setupMPI(comm, iLoc, nLoc)
717-
s = [slice(i, i + n) for i, n in zip(iLoc, nLoc)]
717+
s = [slice(i, i + n) for i, n in zip(iLoc, nLoc, strict=True)]
718718
u0 = u0[(slice(None), *s)]
719719

720720
f1 = Rectilinear(DTYPES[dtypeIdx], fileName)

pySDC/helpers/transfer_helper.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def next_neighbors_periodic(p, ps, k):
2727

2828
# zip it
2929
value_index = []
30-
for d, i in zip(distance_to_p, range(distance_to_p.size)):
30+
for d, i in zip(distance_to_p, range(distance_to_p.size, strict=True)):
3131
value_index.append((d, i))
3232
# sort by distance
3333
value_index_sorted = sorted(value_index, key=lambda s: s[0])
@@ -53,7 +53,7 @@ def next_neighbors(p, ps, k):
5353
distance_to_p = np.abs(ps - p)
5454
# zip it
5555
value_index = []
56-
for d, i in zip(distance_to_p, range(distance_to_p.size)):
56+
for d, i in zip(distance_to_p, range(distance_to_p.size, strict=True)):
5757
value_index.append((d, i))
5858
# sort by distance
5959
value_index_sorted = sorted(value_index, key=lambda s: s[0])
@@ -80,7 +80,7 @@ def continue_periodic_array(arr, nn):
8080
else:
8181
cont_arr = [arr[nn[0]]]
8282
shift = 0.0
83-
for n, d in zip(nn[1:], d_nn):
83+
for n, d in zip(nn[1:], d_nn, strict=True):
8484
if d != 1:
8585
shift = -1
8686
cont_arr.append(arr[n] + shift)
@@ -107,7 +107,7 @@ def restriction_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1):
107107

108108
if periodic:
109109
M = np.zeros((coarse_grid.size, fine_grid.size))
110-
for i, p in zip(range(n_g), coarse_grid):
110+
for i, p in zip(range(n_g), coarse_grid, strict=True):
111111
nn = next_neighbors_periodic(p, fine_grid, k)
112112
circulating_one = np.asarray([1.0] + [0.0] * (k - 1))
113113
cont_arr = continue_periodic_array(fine_grid, nn)
@@ -120,7 +120,7 @@ def restriction_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1):
120120
M[i, nn] = np.asarray(list(map(lambda x: x(p), bary_pol)))
121121
else:
122122
M = np.zeros((coarse_grid.size, fine_grid.size + 2 * pad))
123-
for i, p in zip(range(n_g), coarse_grid):
123+
for i, p in zip(range(n_g), coarse_grid, strict=True):
124124
padded_f_grid = border_padding(fine_grid, pad, pad)
125125
nn = next_neighbors(p, padded_f_grid, k)
126126
# construct the lagrange polynomials for the k neighbors
@@ -158,7 +158,7 @@ def interpolation_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1,
158158
M = np.zeros((fine_grid.size, coarse_grid.size))
159159

160160
if equidist_nested:
161-
for i, p in zip(range(n_f), fine_grid):
161+
for i, p in zip(range(n_f), fine_grid, strict=True):
162162
if i % 2 == 0:
163163
M[i, int(i / 2)] = 1.0
164164
else:
@@ -189,7 +189,7 @@ def interpolation_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1,
189189
M[i, nn] = np.asarray(list(map(lambda x: x(p), bary_pol)))
190190

191191
else:
192-
for i, p in zip(range(n_f), fine_grid):
192+
for i, p in zip(range(n_f), fine_grid, strict=True):
193193
nn = next_neighbors_periodic(p, coarse_grid, k)
194194
circulating_one = np.asarray([1.0] + [0.0] * (k - 1))
195195
cont_arr = continue_periodic_array(coarse_grid, nn)
@@ -208,7 +208,7 @@ def interpolation_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1,
208208
padded_c_grid = border_padding(coarse_grid, pad, pad)
209209

210210
if equidist_nested:
211-
for i, p in zip(range(n_f), fine_grid):
211+
for i, p in zip(range(n_f), fine_grid, strict=True):
212212
if i % 2 != 0:
213213
M[i, int((i - 1) / 2) + 1] = 1.0
214214
else:
@@ -231,7 +231,7 @@ def interpolation_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1,
231231
M[i, nn] = np.asarray(list(map(lambda x: x(p), bary_pol)))
232232

233233
else:
234-
for i, p in zip(range(n_f), fine_grid):
234+
for i, p in zip(range(n_f), fine_grid, strict=True):
235235
nn = next_neighbors(p, padded_c_grid, k)
236236
# construct the lagrange polynomials for the k neighbors
237237
circulating_one = np.asarray([1.0] + [0.0] * (k - 1))

pySDC/helpers/vtkIO.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def field(u):
5252
return numpy_support.numpy_to_vtk(num_array=u.ravel(order='F'), deep=True, array_type=vtk.VTK_FLOAT)
5353

5454
pointData = vtr.GetPointData()
55-
for name, u in zip(varNames, data):
55+
for name, u in zip(varNames, data, strict=True):
5656
uVTK = field(u)
5757
uVTK.SetName(name)
5858
pointData.AddArray(uVTK)

pySDC/implementations/problem_classes/AllenCahn_Temp_MPIFFT.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def __init__(
134134
N = self.fft.global_shape()
135135
k = [np.fft.fftfreq(n, 1.0 / n).astype(int) for n in N[:-1]]
136136
k.append(np.fft.rfftfreq(N[-1], 1.0 / N[-1]).astype(int))
137-
K = [ki[si] for ki, si in zip(k, s)]
137+
K = [ki[si] for ki, si in zip(k, s, strict=True)]
138138
Ks = list(np.meshgrid(*K, indexing='ij', sparse=True))
139139
Lp = 2 * np.pi / L
140140
for i in range(ndim):

pySDC/implementations/problem_classes/Brusselator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def plot(self, u, t=None, fig=None): # pragma: no cover
178178

179179
vmin = u.min()
180180
vmax = u.max()
181-
for i, label in zip([self.iU, self.iV], [r'$u$', r'$v$']):
181+
for i, label in zip([self.iU, self.iV], [r'$u$', r'$v$'], strict=True):
182182
im = axs[i].pcolormesh(self.X[0], self.X[1], u[i], vmin=vmin, vmax=vmax)
183183
axs[i].set_aspect(1)
184184
axs[i].set_title(label)

pySDC/implementations/problem_classes/Burgers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def plot(self, u, t=None, fig=None, vmin=None, vmax=None): # pragma: no cover
324324
imV = axs[1].pcolormesh(self.X, self.Z, u[iv].real, vmin=vmin, vmax=vmax)
325325
imVort = axs[2].pcolormesh(self.X, self.Z, self.compute_vorticity(u).real)
326326

327-
for i, label in zip([0, 1, 2], [r'$u$', '$v$', 'vorticity']):
327+
for i, label in zip([0, 1, 2], [r'$u$', '$v$', 'vorticity'], strict=True):
328328
axs[i].set_aspect(1)
329329
axs[i].set_title(label)
330330

pySDC/implementations/problem_classes/GrayScott_MPIFFT.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def plot(self, u, t=None, fig=None): # pragma: no cover
343343

344344
vmin = u.min()
345345
vmax = u.max()
346-
for i, label in zip([self.iU, self.iV], [r'$u$', r'$v$']):
346+
for i, label in zip([self.iU, self.iV], [r'$u$', r'$v$'], strict=True):
347347
im = axs[i].pcolormesh(self.X[0], self.X[1], u[i], vmin=vmin, vmax=vmax)
348348
axs[i].set_aspect(1)
349349
axs[i].set_title(label)

pySDC/implementations/problem_classes/RayleighBenard.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def plot(self, u, t=None, fig=None, quantity='T'): # pragma: no cover
363363

364364
imT = axs[0].pcolormesh(self.X, self.Z, u[self.index(quantity)].real)
365365

366-
for i, label in zip([0, 1], [rf'${quantity}$', 'vorticity']):
366+
for i, label in zip([0, 1], [rf'${quantity}$', 'vorticity'], strict=True):
367367
axs[i].set_aspect(1)
368368
axs[i].set_title(label)
369369

@@ -630,6 +630,7 @@ def post_step(self, step, level_number):
630630
for key, value in zip(
631631
['Nusselt', 'buoyancy_production', 'viscous_dissipation'],
632632
[Nusselt, buoyancy_production, viscous_dissipation],
633+
strict=True,
633634
):
634635
self.add_to_stats(
635636
process=step.status.slot,

pySDC/implementations/problem_classes/RayleighBenard3D.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def eval_f(self, u, *args, **kwargs):
255255

256256
fexpl_pad = self.xp.zeros_like(u_pad)
257257
for i in derivative_indices:
258-
for i_vel, iD in zip([iu, iv, iw], range(self.ndim)):
258+
for i_vel, iD in zip([iu, iv, iw], range(self.ndim), strict=True):
259259
fexpl_pad[i] -= u_pad[i_vel] * derivatives[iD][i]
260260

261261
if self.spectral_space:
@@ -398,7 +398,7 @@ def get_frequency_spectrum(self, u):
398398

399399
# compute local spectrum
400400
local_spectrum = self.xp.empty(shape=(2, energy.shape[3], n_k))
401-
for i, k in zip(range(n_k), unique_k):
401+
for i, k in zip(range(n_k), unique_k, strict=True):
402402
mask = xp.logical_or(abs_kx == k, abs_ky == k)
403403
local_spectrum[..., i] = xp.sum(energy[indices, mask, :], axis=1)
404404

@@ -411,7 +411,7 @@ def get_frequency_spectrum(self, u):
411411

412412
spectra = self.comm.allgather(local_spectrum)
413413
spectrum = self.xp.zeros(shape=(2, self.axes[2].N, n_k_all))
414-
for ks, _spectrum in zip(k_all, spectra):
414+
for ks, _spectrum in zip(k_all, spectra, strict=True):
415415
ks = list(ks)
416416
unique_k_all = list(unique_k_all)
417417
for k in ks:

0 commit comments

Comments
 (0)