From c509e212f30ca71efd71954321481a3cc748e3c0 Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Tue, 21 Oct 2025 11:06:07 +0200 Subject: [PATCH 1/4] Exclude B905 (zip without strict) from linting --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 47e393f676..14a650a80e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,6 +93,7 @@ ignore = ["E203", # Whitespace before punctuation "C901", # Complex name "E501", # Line length, as enforced by black, but black ignores comments "E721" # Type comparison + "B905" # zip without strict ] # W504 is not supported by ruff and does not need to be excluded From 14607497eeca39e10abf41bea4575221e09c79bd Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Tue, 21 Oct 2025 11:08:16 +0200 Subject: [PATCH 2/4] Fix typo --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 14a650a80e..1b5a902a58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ ignore = ["E203", # Whitespace before punctuation # Newly added "C901", # Complex name "E501", # Line length, as enforced by black, but black ignores comments - "E721" # Type comparison + "E721", # Type comparison "B905" # zip without strict ] # W504 is not supported by ruff and does not need to be excluded From 76f4b85f7e73d4c1746c9eb1c956574ca9a9ec9d Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:07:46 +0200 Subject: [PATCH 3/4] Added strict keyword argument to zip --- pySDC/helpers/blocks.py | 2 +- pySDC/helpers/fieldsIO.py | 2 +- pySDC/helpers/transfer_helper.py | 18 +++++++++--------- pySDC/helpers/vtkIO.py | 2 +- .../problem_classes/AllenCahn_Temp_MPIFFT.py | 2 +- .../problem_classes/Brusselator.py | 2 +- .../implementations/problem_classes/Burgers.py | 2 +- .../problem_classes/GrayScott_MPIFFT.py | 2 +- .../problem_classes/RayleighBenard.py | 3 ++- .../problem_classes/RayleighBenard3D.py | 6 +++--- .../generic_MPIFFT_Laplacian.py | 2 +- .../sweeper_classes/Runge_Kutta.py | 11 ++++++----- .../transfer_classes/TransferMesh_MPIFFT.py | 2 +- .../run_simple_forcing_verification.py | 2 +- pySDC/projects/AllenCahn_Bayreuth/visualize.py | 2 +- .../AllenCahn_Bayreuth/visualize_temp.py | 4 ++-- pySDC/projects/AsympConv/conv_test_to0.py | 2 +- pySDC/projects/AsympConv/conv_test_toinf.py | 2 +- pySDC/projects/DAE/plotting/loglog_plot.py | 3 ++- pySDC/projects/DAE/plotting/semilogy_plot.py | 2 +- pySDC/projects/DAE/problems/wscc9BusSystem.py | 2 +- .../DAE/run/synchronous_machine_playground.py | 2 +- .../analysis_scripts/plot_large_simulations.py | 6 +++--- pySDC/projects/GPU/run_experiment.py | 2 +- .../test_monodomain_iterations_parallel.py | 2 +- pySDC/projects/Performance/visualize.py | 2 +- pySDC/projects/PinTSimE/battery_model.py | 7 ++++--- pySDC/projects/PinTSimE/estimation_check.py | 16 ++++++++++------ pySDC/projects/Resilience/work_precision.py | 14 +++++++++----- .../TOMS/AllenCahn_contracting_circle.py | 2 +- pySDC/projects/parallelSDC/newton_vs_sdc.py | 2 +- .../parallelSDC/preconditioner_playground.py | 2 +- .../preconditioner_playground_MPI.py | 2 +- .../parallelSDC_reloaded/convergence.py | 2 +- .../parallelSDC_reloaded/scripts/fig01_conv.py | 2 +- .../scripts/fig03_lorenz.py | 4 ++-- .../scripts/fig04_protheroRobinson.py | 2 +- .../scripts/fig05_allenCahn.py | 2 +- .../scripts/fig06_allenCahnMPI_plot.py | 9 ++++++--- .../parallelSDC_reloaded/vanderpol_accuracy.py | 2 +- .../parallelSDC_reloaded/vanderpol_setup.py | 2 +- .../step_7/F_2_plot_pySDC_with_Gusto_result.py | 18 ++++++++++++++++-- pySDC/tutorial/step_8/B_multistep_SDC.py | 2 +- pySDC/tutorial/step_8/C_iteration_estimator.py | 2 +- pyproject.toml | 1 - 45 files changed, 105 insertions(+), 77 deletions(-) diff --git a/pySDC/helpers/blocks.py b/pySDC/helpers/blocks.py index d6c846aa9b..16e6b19718 100644 --- a/pySDC/helpers/blocks.py +++ b/pySDC/helpers/blocks.py @@ -102,7 +102,7 @@ def ranks(self): @property def localBounds(self): iLocList, nLocList = [], [] - for rank, nPoints, nBlocks in zip(self.ranks, self.gridSizes, self.nBlocks): + for rank, nPoints, nBlocks in zip(self.ranks, self.gridSizes, self.nBlocks, strict=True): n0 = nPoints // nBlocks nRest = nPoints - nBlocks * n0 nLoc = n0 + 1 * (rank < nRest) diff --git a/pySDC/helpers/fieldsIO.py b/pySDC/helpers/fieldsIO.py index 43e4fdb562..a57fa77f2e 100644 --- a/pySDC/helpers/fieldsIO.py +++ b/pySDC/helpers/fieldsIO.py @@ -714,7 +714,7 @@ def writeFields_MPI(fileName, dtypeIdx, algo, nSteps, nVar, gridSizes): iLoc, nLoc = blocks.localBounds Rectilinear.setupMPI(comm, iLoc, nLoc) - s = [slice(i, i + n) for i, n in zip(iLoc, nLoc)] + s = [slice(i, i + n) for i, n in zip(iLoc, nLoc, strict=True)] u0 = u0[(slice(None), *s)] f1 = Rectilinear(DTYPES[dtypeIdx], fileName) diff --git a/pySDC/helpers/transfer_helper.py b/pySDC/helpers/transfer_helper.py index 196d50f0a5..378635e812 100644 --- a/pySDC/helpers/transfer_helper.py +++ b/pySDC/helpers/transfer_helper.py @@ -27,7 +27,7 @@ def next_neighbors_periodic(p, ps, k): # zip it value_index = [] - for d, i in zip(distance_to_p, range(distance_to_p.size)): + for d, i in zip(distance_to_p, range(distance_to_p.size, strict=True)): value_index.append((d, i)) # sort by distance value_index_sorted = sorted(value_index, key=lambda s: s[0]) @@ -53,7 +53,7 @@ def next_neighbors(p, ps, k): distance_to_p = np.abs(ps - p) # zip it value_index = [] - for d, i in zip(distance_to_p, range(distance_to_p.size)): + for d, i in zip(distance_to_p, range(distance_to_p.size, strict=True)): value_index.append((d, i)) # sort by distance value_index_sorted = sorted(value_index, key=lambda s: s[0]) @@ -80,7 +80,7 @@ def continue_periodic_array(arr, nn): else: cont_arr = [arr[nn[0]]] shift = 0.0 - for n, d in zip(nn[1:], d_nn): + for n, d in zip(nn[1:], d_nn, strict=True): if d != 1: shift = -1 cont_arr.append(arr[n] + shift) @@ -107,7 +107,7 @@ def restriction_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1): if periodic: M = np.zeros((coarse_grid.size, fine_grid.size)) - for i, p in zip(range(n_g), coarse_grid): + for i, p in zip(range(n_g), coarse_grid, strict=True): nn = next_neighbors_periodic(p, fine_grid, k) circulating_one = np.asarray([1.0] + [0.0] * (k - 1)) 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): M[i, nn] = np.asarray(list(map(lambda x: x(p), bary_pol))) else: M = np.zeros((coarse_grid.size, fine_grid.size + 2 * pad)) - for i, p in zip(range(n_g), coarse_grid): + for i, p in zip(range(n_g), coarse_grid, strict=True): padded_f_grid = border_padding(fine_grid, pad, pad) nn = next_neighbors(p, padded_f_grid, k) # 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, M = np.zeros((fine_grid.size, coarse_grid.size)) if equidist_nested: - for i, p in zip(range(n_f), fine_grid): + for i, p in zip(range(n_f), fine_grid, strict=True): if i % 2 == 0: M[i, int(i / 2)] = 1.0 else: @@ -189,7 +189,7 @@ def interpolation_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1, M[i, nn] = np.asarray(list(map(lambda x: x(p), bary_pol))) else: - for i, p in zip(range(n_f), fine_grid): + for i, p in zip(range(n_f), fine_grid, strict=True): nn = next_neighbors_periodic(p, coarse_grid, k) circulating_one = np.asarray([1.0] + [0.0] * (k - 1)) 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, padded_c_grid = border_padding(coarse_grid, pad, pad) if equidist_nested: - for i, p in zip(range(n_f), fine_grid): + for i, p in zip(range(n_f), fine_grid, strict=True): if i % 2 != 0: M[i, int((i - 1) / 2) + 1] = 1.0 else: @@ -231,7 +231,7 @@ def interpolation_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1, M[i, nn] = np.asarray(list(map(lambda x: x(p), bary_pol))) else: - for i, p in zip(range(n_f), fine_grid): + for i, p in zip(range(n_f), fine_grid, strict=True): nn = next_neighbors(p, padded_c_grid, k) # construct the lagrange polynomials for the k neighbors circulating_one = np.asarray([1.0] + [0.0] * (k - 1)) diff --git a/pySDC/helpers/vtkIO.py b/pySDC/helpers/vtkIO.py index 9cf0c7f994..d4c10de29e 100644 --- a/pySDC/helpers/vtkIO.py +++ b/pySDC/helpers/vtkIO.py @@ -52,7 +52,7 @@ def field(u): return numpy_support.numpy_to_vtk(num_array=u.ravel(order='F'), deep=True, array_type=vtk.VTK_FLOAT) pointData = vtr.GetPointData() - for name, u in zip(varNames, data): + for name, u in zip(varNames, data, strict=True): uVTK = field(u) uVTK.SetName(name) pointData.AddArray(uVTK) diff --git a/pySDC/implementations/problem_classes/AllenCahn_Temp_MPIFFT.py b/pySDC/implementations/problem_classes/AllenCahn_Temp_MPIFFT.py index 054154d172..7a8a87b2db 100644 --- a/pySDC/implementations/problem_classes/AllenCahn_Temp_MPIFFT.py +++ b/pySDC/implementations/problem_classes/AllenCahn_Temp_MPIFFT.py @@ -134,7 +134,7 @@ def __init__( N = self.fft.global_shape() k = [np.fft.fftfreq(n, 1.0 / n).astype(int) for n in N[:-1]] k.append(np.fft.rfftfreq(N[-1], 1.0 / N[-1]).astype(int)) - K = [ki[si] for ki, si in zip(k, s)] + K = [ki[si] for ki, si in zip(k, s, strict=True)] Ks = list(np.meshgrid(*K, indexing='ij', sparse=True)) Lp = 2 * np.pi / L for i in range(ndim): diff --git a/pySDC/implementations/problem_classes/Brusselator.py b/pySDC/implementations/problem_classes/Brusselator.py index 746747d4c8..5591eaccbf 100644 --- a/pySDC/implementations/problem_classes/Brusselator.py +++ b/pySDC/implementations/problem_classes/Brusselator.py @@ -178,7 +178,7 @@ def plot(self, u, t=None, fig=None): # pragma: no cover vmin = u.min() vmax = u.max() - for i, label in zip([self.iU, self.iV], [r'$u$', r'$v$']): + for i, label in zip([self.iU, self.iV], [r'$u$', r'$v$'], strict=True): im = axs[i].pcolormesh(self.X[0], self.X[1], u[i], vmin=vmin, vmax=vmax) axs[i].set_aspect(1) axs[i].set_title(label) diff --git a/pySDC/implementations/problem_classes/Burgers.py b/pySDC/implementations/problem_classes/Burgers.py index 7ff48e16ad..5b395cb51a 100644 --- a/pySDC/implementations/problem_classes/Burgers.py +++ b/pySDC/implementations/problem_classes/Burgers.py @@ -324,7 +324,7 @@ def plot(self, u, t=None, fig=None, vmin=None, vmax=None): # pragma: no cover imV = axs[1].pcolormesh(self.X, self.Z, u[iv].real, vmin=vmin, vmax=vmax) imVort = axs[2].pcolormesh(self.X, self.Z, self.compute_vorticity(u).real) - for i, label in zip([0, 1, 2], [r'$u$', '$v$', 'vorticity']): + for i, label in zip([0, 1, 2], [r'$u$', '$v$', 'vorticity'], strict=True): axs[i].set_aspect(1) axs[i].set_title(label) diff --git a/pySDC/implementations/problem_classes/GrayScott_MPIFFT.py b/pySDC/implementations/problem_classes/GrayScott_MPIFFT.py index cabc012929..0c881016cc 100644 --- a/pySDC/implementations/problem_classes/GrayScott_MPIFFT.py +++ b/pySDC/implementations/problem_classes/GrayScott_MPIFFT.py @@ -343,7 +343,7 @@ def plot(self, u, t=None, fig=None): # pragma: no cover vmin = u.min() vmax = u.max() - for i, label in zip([self.iU, self.iV], [r'$u$', r'$v$']): + for i, label in zip([self.iU, self.iV], [r'$u$', r'$v$'], strict=True): im = axs[i].pcolormesh(self.X[0], self.X[1], u[i], vmin=vmin, vmax=vmax) axs[i].set_aspect(1) axs[i].set_title(label) diff --git a/pySDC/implementations/problem_classes/RayleighBenard.py b/pySDC/implementations/problem_classes/RayleighBenard.py index 9bad277536..3c43826551 100644 --- a/pySDC/implementations/problem_classes/RayleighBenard.py +++ b/pySDC/implementations/problem_classes/RayleighBenard.py @@ -363,7 +363,7 @@ def plot(self, u, t=None, fig=None, quantity='T'): # pragma: no cover imT = axs[0].pcolormesh(self.X, self.Z, u[self.index(quantity)].real) - for i, label in zip([0, 1], [rf'${quantity}$', 'vorticity']): + for i, label in zip([0, 1], [rf'${quantity}$', 'vorticity'], strict=True): axs[i].set_aspect(1) axs[i].set_title(label) @@ -630,6 +630,7 @@ def post_step(self, step, level_number): for key, value in zip( ['Nusselt', 'buoyancy_production', 'viscous_dissipation'], [Nusselt, buoyancy_production, viscous_dissipation], + strict=True, ): self.add_to_stats( process=step.status.slot, diff --git a/pySDC/implementations/problem_classes/RayleighBenard3D.py b/pySDC/implementations/problem_classes/RayleighBenard3D.py index 69bd051e30..cf67e03f79 100644 --- a/pySDC/implementations/problem_classes/RayleighBenard3D.py +++ b/pySDC/implementations/problem_classes/RayleighBenard3D.py @@ -255,7 +255,7 @@ def eval_f(self, u, *args, **kwargs): fexpl_pad = self.xp.zeros_like(u_pad) for i in derivative_indices: - for i_vel, iD in zip([iu, iv, iw], range(self.ndim)): + for i_vel, iD in zip([iu, iv, iw], range(self.ndim), strict=True): fexpl_pad[i] -= u_pad[i_vel] * derivatives[iD][i] if self.spectral_space: @@ -398,7 +398,7 @@ def get_frequency_spectrum(self, u): # compute local spectrum local_spectrum = self.xp.empty(shape=(2, energy.shape[3], n_k)) - for i, k in zip(range(n_k), unique_k): + for i, k in zip(range(n_k), unique_k, strict=True): mask = xp.logical_or(abs_kx == k, abs_ky == k) local_spectrum[..., i] = xp.sum(energy[indices, mask, :], axis=1) @@ -411,7 +411,7 @@ def get_frequency_spectrum(self, u): spectra = self.comm.allgather(local_spectrum) spectrum = self.xp.zeros(shape=(2, self.axes[2].N, n_k_all)) - for ks, _spectrum in zip(k_all, spectra): + for ks, _spectrum in zip(k_all, spectra, strict=True): ks = list(ks) unique_k_all = list(unique_k_all) for k in ks: diff --git a/pySDC/implementations/problem_classes/generic_MPIFFT_Laplacian.py b/pySDC/implementations/problem_classes/generic_MPIFFT_Laplacian.py index 223b931cb4..e6b845d1cc 100644 --- a/pySDC/implementations/problem_classes/generic_MPIFFT_Laplacian.py +++ b/pySDC/implementations/problem_classes/generic_MPIFFT_Laplacian.py @@ -120,7 +120,7 @@ def getLaplacian(self): s = self.fft.local_slice() N = self.fft.global_shape() k = [self.xp.fft.fftfreq(n, 1.0 / n).astype(int) for n in N] - K = [ki[si] for ki, si in zip(k, s)] + K = [ki[si] for ki, si in zip(k, s, strict=True)] Ks = list(self.xp.meshgrid(*K, indexing='ij', sparse=True)) Lp = 2 * np.pi / self.L for i in range(self.ndim): diff --git a/pySDC/implementations/sweeper_classes/Runge_Kutta.py b/pySDC/implementations/sweeper_classes/Runge_Kutta.py index 6c6c07641e..6f9c03df89 100644 --- a/pySDC/implementations/sweeper_classes/Runge_Kutta.py +++ b/pySDC/implementations/sweeper_classes/Runge_Kutta.py @@ -279,16 +279,16 @@ def compute_end_point(self): lvl.uend = lvl.prob.dtype_u(lvl.u[-1]) if type(self.coll) == ButcherTableauEmbedded: self.u_secondary = lvl.prob.dtype_u(lvl.u[0]) - for w2, k in zip(self.coll.weights[1], lvl.f[1:]): + for w2, k in zip(self.coll.weights[1], lvl.f[1:], strict=True): self.u_secondary += lvl.dt * w2 * k else: lvl.uend = lvl.prob.dtype_u(lvl.u[0]) if type(self.coll) == ButcherTableau: - for w, k in zip(self.coll.weights, lvl.f[1:]): + for w, k in zip(self.coll.weights, lvl.f[1:], strict=True): lvl.uend += lvl.dt * w * k elif type(self.coll) == ButcherTableauEmbedded: self.u_secondary = lvl.prob.dtype_u(lvl.u[0]) - for w1, w2, k in zip(self.coll.weights[0], self.coll.weights[1], lvl.f[1:]): + for w1, w2, k in zip(self.coll.weights[0], self.coll.weights[1], lvl.f[1:], strict=True): lvl.uend += lvl.dt * w1 * k self.u_secondary += lvl.dt * w2 * k @@ -459,12 +459,12 @@ def compute_end_point(self): lvl.uend = lvl.u[-1] if type(self.coll) == ButcherTableauEmbedded: self.u_secondary = lvl.prob.dtype_u(lvl.u[0]) - for w2, w2E, k in zip(self.coll.weights[1], self.coll_explicit.weights[1], lvl.f[1:]): + for w2, w2E, k in zip(self.coll.weights[1], self.coll_explicit.weights[1], lvl.f[1:], strict=True): self.u_secondary += lvl.dt * (w2 * k.impl + w2E * k.expl) else: lvl.uend = lvl.prob.dtype_u(lvl.u[0]) if type(self.coll) == ButcherTableau: - for w, wE, k in zip(self.coll.weights, self.coll_explicit.weights, lvl.f[1:]): + for w, wE, k in zip(self.coll.weights, self.coll_explicit.weights, lvl.f[1:], strict=True): lvl.uend += lvl.dt * (w * k.impl + wE * k.expl) elif type(self.coll) == ButcherTableauEmbedded: self.u_secondary = lvl.u[0].copy() @@ -474,6 +474,7 @@ def compute_end_point(self): self.coll_explicit.weights[0], self.coll_explicit.weights[1], lvl.f[1:], + strict=True, ): lvl.uend += lvl.dt * (w1 * k.impl + w1E * k.expl) self.u_secondary += lvl.dt * (w2 * k.impl + w2E * k.expl) diff --git a/pySDC/implementations/transfer_classes/TransferMesh_MPIFFT.py b/pySDC/implementations/transfer_classes/TransferMesh_MPIFFT.py index 907b826cdd..c41f32e622 100644 --- a/pySDC/implementations/transfer_classes/TransferMesh_MPIFFT.py +++ b/pySDC/implementations/transfer_classes/TransferMesh_MPIFFT.py @@ -29,7 +29,7 @@ def __init__(self, fine_prob, coarse_prob, params): Nf = list(self.fine_prob.fft.global_shape()) Nc = list(self.coarse_prob.fft.global_shape()) - self.ratio = [int(nf / nc) for nf, nc in zip(Nf, Nc)] + self.ratio = [int(nf / nc) for nf, nc in zip(Nf, Nc, strict=True)] axes = tuple(range(len(Nf))) fft_args = {} diff --git a/pySDC/projects/AllenCahn_Bayreuth/run_simple_forcing_verification.py b/pySDC/projects/AllenCahn_Bayreuth/run_simple_forcing_verification.py index 7544005c16..cc1c0cb0bc 100644 --- a/pySDC/projects/AllenCahn_Bayreuth/run_simple_forcing_verification.py +++ b/pySDC/projects/AllenCahn_Bayreuth/run_simple_forcing_verification.py @@ -124,7 +124,7 @@ def run_simulation(name='', spectral=None, nprocs_space=None): # print and store radii and error over time err_test = 0.0 results = dict() - for cr, er, cv, ev in zip(computed_radii, exact_radii, computed_vol, exact_vol): + for cr, er, cv, ev in zip(computed_radii, exact_radii, computed_vol, exact_vol, strict=True): if name == 'AC-test-noforce': exrad = er[1] exvol = ev[1] diff --git a/pySDC/projects/AllenCahn_Bayreuth/visualize.py b/pySDC/projects/AllenCahn_Bayreuth/visualize.py index 70812a4865..733580c81c 100644 --- a/pySDC/projects/AllenCahn_Bayreuth/visualize.py +++ b/pySDC/projects/AllenCahn_Bayreuth/visualize.py @@ -21,7 +21,7 @@ def plot_data(name=''): json_files = sorted(glob.glob(f'./data/{name}_*.json')) data_files = sorted(glob.glob(f'./data/{name}_*.dat')) - for json_file, data_file in zip(json_files, data_files): + for json_file, data_file in zip(json_files, data_files, strict=True): with open(json_file, 'r') as fp: obj = json.load(fp) diff --git a/pySDC/projects/AllenCahn_Bayreuth/visualize_temp.py b/pySDC/projects/AllenCahn_Bayreuth/visualize_temp.py index 6dfbdfe55e..0342a49b67 100644 --- a/pySDC/projects/AllenCahn_Bayreuth/visualize_temp.py +++ b/pySDC/projects/AllenCahn_Bayreuth/visualize_temp.py @@ -27,7 +27,7 @@ def plot_data(path='./data', name='', output='.'): json_files = sorted(glob.glob(f'{path}/{name}_*.json')) data_files = sorted(glob.glob(f'{path}/{name}_*.dat')) - for json_file, data_file in zip(json_files, data_files): + for json_file, data_file in zip(json_files, data_files, strict=True): with open(json_file, 'r') as fp: obj = json.load(fp) @@ -74,7 +74,7 @@ def make_movie(path='./data', name='', output='.'): data_files = sorted(glob.glob(f'{path}/{name}_*.dat')) img_list = [] - for json_file, data_file in zip(json_files, data_files): + for json_file, data_file in zip(json_files, data_files, strict=True): with open(json_file, 'r') as fp: obj = json.load(fp) diff --git a/pySDC/projects/AsympConv/conv_test_to0.py b/pySDC/projects/AsympConv/conv_test_to0.py index 51f7622d48..c63bb10d86 100644 --- a/pySDC/projects/AsympConv/conv_test_to0.py +++ b/pySDC/projects/AsympConv/conv_test_to0.py @@ -33,7 +33,7 @@ def compute_and_plot_specrad(Nnodes, lam): color_list = ['red', 'blue'] marker_list = ['s', 'o'] - setup_list = zip(Nsteps_list, color_list, marker_list) + setup_list = zip(Nsteps_list, color_list, marker_list, strict=True) xlist = [0.1**i for i in range(11)] diff --git a/pySDC/projects/AsympConv/conv_test_toinf.py b/pySDC/projects/AsympConv/conv_test_toinf.py index 2583f3e560..4cee01e021 100644 --- a/pySDC/projects/AsympConv/conv_test_toinf.py +++ b/pySDC/projects/AsympConv/conv_test_toinf.py @@ -35,7 +35,7 @@ def compute_and_plot_specrad(Nnodes, lam): color_list = ['red', 'blue', 'green'] marker_list = ['s', 'o', 'd'] - setup_list = zip(Nsweep_list, color_list, marker_list) + setup_list = zip(Nsweep_list, color_list, marker_list, strict=True) xlist = [10**i for i in range(11)] diff --git a/pySDC/projects/DAE/plotting/loglog_plot.py b/pySDC/projects/DAE/plotting/loglog_plot.py index 6fe716ea03..9f8b2c76f0 100644 --- a/pySDC/projects/DAE/plotting/loglog_plot.py +++ b/pySDC/projects/DAE/plotting/loglog_plot.py @@ -68,7 +68,7 @@ def plot_convergence(): # pragma: no cover ylim = (sys.float_info.max, sys.float_info.min) for num_nodes, color, shape, style, order in zip( - num_nodes_list, color_list, shape_list, style_list, order_list + num_nodes_list, color_list, shape_list, style_list, order_list, strict=True ): # Plot convergence data ax.loglog( @@ -99,6 +99,7 @@ def plot_convergence(): # pragma: no cover data[qd_type][num_nodes]['dt'], data[qd_type][num_nodes]['position'], data[qd_type][num_nodes]['offset'], + strict=True, ): ax.annotate( niter, diff --git a/pySDC/projects/DAE/plotting/semilogy_plot.py b/pySDC/projects/DAE/plotting/semilogy_plot.py index 5ea71d6d6a..03f8154036 100644 --- a/pySDC/projects/DAE/plotting/semilogy_plot.py +++ b/pySDC/projects/DAE/plotting/semilogy_plot.py @@ -29,7 +29,7 @@ def plot_convergence(): # pragma: no cover lns1 = list() lns2 = list() - for num_nodes, color, shape in zip(num_nodes_list, color_list, shape_list): + for num_nodes, color, shape in zip(num_nodes_list, color_list, shape_list, strict=True): # Plot convergence data lns1.append( ax1.semilogy( diff --git a/pySDC/projects/DAE/problems/wscc9BusSystem.py b/pySDC/projects/DAE/problems/wscc9BusSystem.py index 7d16a11ce6..9117c8c51e 100644 --- a/pySDC/projects/DAE/problems/wscc9BusSystem.py +++ b/pySDC/projects/DAE/problems/wscc9BusSystem.py @@ -866,7 +866,7 @@ def __init__(self, newton_tol=1e-10): self.IC6 = [row[3] for row in self.bus] # Column 4 in MATLAB is indexed as 3 in Python self.IC6 = [val / self.baseMVA for val in self.IC6] - self.IC = list(zip(self.IC1, self.IC2, self.IC3, self.IC4, self.IC5, self.IC6)) + self.IC = list(zip(self.IC1, self.IC2, self.IC3, self.IC4, self.IC5, self.IC6, strict=True)) self.PL = [row[4] for row in self.IC] # Column 5 in MATLAB is indexed as 4 in Python self.QL = [row[5] for row in self.IC] # Column 6 in MATLAB is indexed as 5 in Python diff --git a/pySDC/projects/DAE/run/synchronous_machine_playground.py b/pySDC/projects/DAE/run/synchronous_machine_playground.py index e14ce4706f..7295a7398d 100644 --- a/pySDC/projects/DAE/run/synchronous_machine_playground.py +++ b/pySDC/projects/DAE/run/synchronous_machine_playground.py @@ -98,7 +98,7 @@ def main(): sol_data = np.array( [ [(sol[j][1].diff[id], sol[j][1].alg[ia]) for j in range(len(sol))] - for id, ia in zip(range(len(uend.diff)), range(len(uend.alg))) + for id, ia in zip(range(len(uend.diff)), range(len(uend.alg)), strict=True) ] ) niter = filter_stats(stats, type='niter') diff --git a/pySDC/projects/GPU/analysis_scripts/plot_large_simulations.py b/pySDC/projects/GPU/analysis_scripts/plot_large_simulations.py index 8296007e38..64c592f623 100644 --- a/pySDC/projects/GPU/analysis_scripts/plot_large_simulations.py +++ b/pySDC/projects/GPU/analysis_scripts/plot_large_simulations.py @@ -65,7 +65,7 @@ def prob(self): def plot_work(self): # pragma: no cover fig, ax = self.get_fig() - for key, label in zip(['factorizations', 'rhs'], ['LU decompositions', 'rhs evaluations']): + for key, label in zip(['factorizations', 'rhs'], ['LU decompositions', 'rhs evaluations'], strict=True): work = get_sorted(self.stats, type=f'work_{key}') ax.plot([me[0] for me in work], np.cumsum([4 * me[1] for me in work]), label=fr'\#{label}') ax.set_yscale('log') @@ -191,7 +191,7 @@ def get_CFL_limit(self, recompute=False): def plot_work(self): # pragma: no cover fig, ax = self.get_fig() - for key, label in zip(['factorizations', 'rhs'], ['LU decompositions', 'rhs evaluations']): + for key, label in zip(['factorizations', 'rhs'], ['LU decompositions', 'rhs evaluations'], strict=True): work = get_sorted(self.stats, type=f'work_{key}') ax.plot([me[0] for me in work], np.cumsum([4 * me[1] for me in work]), label=fr'\#{label}') ax.set_yscale('log') @@ -251,7 +251,7 @@ def plot_single(idx, ax): # pragma: no cover im = ax.pcolormesh(X[r], Z[r], data['u'][2], vmin=0, vmax=2, cmap='plasma', rasterized=True), data['t'] return im - for i, ax in zip(indices, axs): + for i, ax in zip(indices, axs, strict=True): im, t = plot_single(i, ax) fig.colorbar(im, caxs[ax], label=f'$T(t={{{t:.1f}}})$') diff --git a/pySDC/projects/GPU/run_experiment.py b/pySDC/projects/GPU/run_experiment.py index b992306d74..c39bdf353d 100644 --- a/pySDC/projects/GPU/run_experiment.py +++ b/pySDC/projects/GPU/run_experiment.py @@ -124,7 +124,7 @@ def plot_series(args, config): # pragma: no cover idxs = np.linspace(0, config.num_frames * 0.9, 9, dtype=int) - for idx, ax in zip(idxs, axs.flatten()): + for idx, ax in zip(idxs, axs.flatten(), strict=True): try: _fig = config.plot(P=P, idx=idx, n_procs_list=args['procs'], ax=ax) except FileNotFoundError: diff --git a/pySDC/projects/Monodomain/tests/test_monodomain_iterations_parallel.py b/pySDC/projects/Monodomain/tests/test_monodomain_iterations_parallel.py index feab5126e9..12d88b79ab 100644 --- a/pySDC/projects/Monodomain/tests/test_monodomain_iterations_parallel.py +++ b/pySDC/projects/Monodomain/tests/test_monodomain_iterations_parallel.py @@ -20,7 +20,7 @@ def plot_iter_info(iters_info_list, labels_list, key1, key2, logy, xlabel, ylabe if logy: plt_helper.plt.yscale("log", base=10) - for i, (iters_info, label) in enumerate(zip(iters_info_list, labels_list)): + for i, (iters_info, label) in enumerate(zip(iters_info_list, labels_list, strict=True)): plt_helper.plt.plot( iters_info[key1], iters_info[key2], diff --git a/pySDC/projects/Performance/visualize.py b/pySDC/projects/Performance/visualize.py index 4bca5e1d2d..c06cf6d56a 100644 --- a/pySDC/projects/Performance/visualize.py +++ b/pySDC/projects/Performance/visualize.py @@ -72,7 +72,7 @@ def plot_data(name=''): # setup plotting plt_helper.setup_mpl() - for json_file, data_file in zip(json_files, data_files): + for json_file, data_file in zip(json_files, data_files, strict=True): with open(json_file, 'r') as fp: obj = json.load(fp) diff --git a/pySDC/projects/PinTSimE/battery_model.py b/pySDC/projects/PinTSimE/battery_model.py index 4ee37ef276..48f3a9ae3c 100644 --- a/pySDC/projects/PinTSimE/battery_model.py +++ b/pySDC/projects/PinTSimE/battery_model.py @@ -249,7 +249,7 @@ def main(): use_detection = [True, False] use_adaptivity = [True, False] - for problem, sweeper in zip([battery, battery_implicit], [imex_1st_order, generic_implicit]): + for problem, sweeper in zip([battery, battery_implicit], [imex_1st_order, generic_implicit], strict=True): for defaults in [False, True]: # for hardcoded solutions problem parameter defaults should match with parameters here if defaults: @@ -476,7 +476,7 @@ def plotSolution(u_num, prob_cls_name, use_adaptivity, use_detection): # pragma unknowns = u_num['unknowns'] unknowns_labels = u_num['unknowns_labels'] - for unknown, unknown_label in zip(unknowns, unknowns_labels): + for unknown, unknown_label in zip(unknowns, unknowns_labels, strict=True): ax.plot(u_num['t'], u_num[unknown], label=unknown_label) if use_detection: @@ -577,7 +577,8 @@ def getDataDict(stats, prob_cls_name, use_adaptivity, use_detection, recomputed, if not all(t is None for t in t_switch_exact): event_err = [ - abs(num_item - ex_item) for (num_item, ex_item) in zip(res['t_switches'], res['t_switch_exact']) + abs(num_item - ex_item) + for (num_item, ex_item) in zip(res['t_switches'], res['t_switch_exact'], strict=True) ] res['e_event'] = event_err diff --git a/pySDC/projects/PinTSimE/estimation_check.py b/pySDC/projects/PinTSimE/estimation_check.py index de05b8d6b3..874abd9529 100644 --- a/pySDC/projects/PinTSimE/estimation_check.py +++ b/pySDC/projects/PinTSimE/estimation_check.py @@ -99,7 +99,7 @@ def run_estimation_check(): use_detection = [True, False] use_adaptivity = [True, False] - for problem, sweeper, prob_cls_name in zip(problem_classes, sweeper_classes, prob_class_names): + for problem, sweeper, prob_cls_name in zip(problem_classes, sweeper_classes, prob_class_names, strict=True): u_num = runSimulation( problem=problem, sweeper=sweeper, @@ -251,7 +251,7 @@ def plotStateFunctionAroundEvent(u_num, prob_cls_name, M_fix): # pragma: no cov dt_list, [ h_item[m] - for (t_item, h_item, t_switch_item) in zip(t, h, t_switch) + for (t_item, h_item, t_switch_item) in zip(t, h, t_switch, strict=True) for m in range(len(t_item)) if abs(t_item[m] - t_switch_item) <= 2.7961188919789493e-11 ], @@ -266,7 +266,9 @@ def plotStateFunctionAroundEvent(u_num, prob_cls_name, M_fix): # pragma: no cov dt_list, [ h_item[m - 1] - for (t_item, h_item, t_switch_item) in zip(t_no_handling, h_no_handling, t_switch) + for (t_item, h_item, t_switch_item) in zip( + t_no_handling, h_no_handling, t_switch, strict=True + ) for m in range(1, len(t_item)) if t_item[m - 1] < t_switch_item < t_item[m] ], @@ -281,7 +283,9 @@ def plotStateFunctionAroundEvent(u_num, prob_cls_name, M_fix): # pragma: no cov dt_list, [ h_item[m] - for (t_item, h_item, t_switch_item) in zip(t_no_handling, h_no_handling, t_switch) + for (t_item, h_item, t_switch_item) in zip( + t_no_handling, h_no_handling, t_switch, strict=True + ) for m in range(1, len(t_item)) if t_item[m - 1] < t_switch_item < t_item[m] ], @@ -297,7 +301,7 @@ def plotStateFunctionAroundEvent(u_num, prob_cls_name, M_fix): # pragma: no cov dt_list, [ h_item[m - 1] - for (t_item, h_item, t_switch_item) in zip(t, h, t_switch) + for (t_item, h_item, t_switch_item) in zip(t, h, t_switch, strict=True) for m in range(1, len(t_item)) if t_item[m - 1] < t_switch_item < t_item[m] ], @@ -312,7 +316,7 @@ def plotStateFunctionAroundEvent(u_num, prob_cls_name, M_fix): # pragma: no cov dt_list, [ h_item[m] - for (t_item, h_item, t_switch_item) in zip(t, h, t_switch) + for (t_item, h_item, t_switch_item) in zip(t, h, t_switch, strict=True) for m in range(1, len(t_item)) if t_item[m - 1] < t_switch_item < t_item[m] ], diff --git a/pySDC/projects/Resilience/work_precision.py b/pySDC/projects/Resilience/work_precision.py index f4bc016bcb..f7b663fc6d 100644 --- a/pySDC/projects/Resilience/work_precision.py +++ b/pySDC/projects/Resilience/work_precision.py @@ -1250,7 +1250,7 @@ def get_configs(mode, problem): i = 0 for interpolate_between_restarts, handle, ls in zip( - [True, False], ['Interpolation between restarts', 'regular'], ['--', '-'] + [True, False], ['Interpolation between restarts', 'regular'], ['--', '-'], strict=True ): configurations[i] = { 'strategies': [ @@ -1275,7 +1275,7 @@ def get_configs(mode, problem): for parallel in [False, True]: desc = {'sweeper_class': parallel_sweeper} if parallel else {} - for num_nodes, ls in zip([3, 4, 2], ['-', '--', ':', '-.']): + for num_nodes, ls in zip([3, 4, 2], ['-', '--', ':', '-.'], strict=True): configurations[num_nodes + (99 if parallel else 0)] = { 'custom_description': {**desc, 'sweeper_params': {'num_nodes': num_nodes}}, 'strategies': [ @@ -1362,7 +1362,11 @@ def get_configs(mode, problem): 'MIN-SR-S', # 'MIN-SR-FLEX', ], - [9991, 12123127391, 1231723109247102731092], + [ + 9991, + # 12123127391, 1231723109247102731092 + ], + strict=True, ): configurations[i] = { 'custom_description': { @@ -1762,7 +1766,7 @@ def all_problems( _ncols = ncols.get(mode, None) if shared_params['work_key'] == 'param': - for ax, prob in zip(fig.get_axes(), problems): + for ax, prob in zip(fig.get_axes(), problems, strict=True): add_param_order_lines(ax, prob) save_fig( fig=fig, @@ -1961,7 +1965,7 @@ def aggregate_parallel_efficiency_plot(): # pragma: no cover num_procs_sweeper_list = [2, 3, 4] - for problem, ax in zip([run_vdp, run_Lorenz, run_quench], axs.flatten()): + for problem, ax in zip([run_vdp, run_Lorenz, run_quench], axs.flatten(), strict=True): speedup = [] for num_procs_sweeper in num_procs_sweeper_list: s, e = plot_parallel_efficiency_diagonalSDC( diff --git a/pySDC/projects/TOMS/AllenCahn_contracting_circle.py b/pySDC/projects/TOMS/AllenCahn_contracting_circle.py index 1fa5656d92..a47c490135 100644 --- a/pySDC/projects/TOMS/AllenCahn_contracting_circle.py +++ b/pySDC/projects/TOMS/AllenCahn_contracting_circle.py @@ -247,7 +247,7 @@ def show_results(fname, cwd=''): exact_radii = get_sorted(item, type='exact_radius', sortby='time') - diff = np.array([abs(item0[1] - item1[1]) for item0, item1 in zip(exact_radii, computed_radii)]) + diff = np.array([abs(item0[1] - item1[1]) for item0, item1 in zip(exact_radii, computed_radii, strict=True)]) max_pos = int(np.argmax(diff)) assert max(diff) < 0.07, 'ERROR: computed radius is too far away from exact radius, got %s' % max(diff) assert 0.028 < computed_radii[max_pos][0] < 0.03, ( diff --git a/pySDC/projects/parallelSDC/newton_vs_sdc.py b/pySDC/projects/parallelSDC/newton_vs_sdc.py index f0030ecc86..fb9863b903 100644 --- a/pySDC/projects/parallelSDC/newton_vs_sdc.py +++ b/pySDC/projects/parallelSDC/newton_vs_sdc.py @@ -123,7 +123,7 @@ def plot_graphs(cwd=''): elif sweeper == 'linearized_implicit_fixed_parallel_prec': label_list.append('Inexact Newton') - setups = zip(sweeper_list, color_list, marker_list, label_list) + setups = zip(sweeper_list, color_list, marker_list, label_list, strict=True) plt_helper.setup_mpl() diff --git a/pySDC/projects/parallelSDC/preconditioner_playground.py b/pySDC/projects/parallelSDC/preconditioner_playground.py index 0ddaeb9f90..bc988e6095 100644 --- a/pySDC/projects/parallelSDC/preconditioner_playground.py +++ b/pySDC/projects/parallelSDC/preconditioner_playground.py @@ -188,7 +188,7 @@ def plot_iterations(): for setup in setup_list: plt_helper.newfig(textwidth=238.96, scale=0.89) - for qd_type, marker, color in zip(qd_type_list, marker_list, color_list): + for qd_type, marker, color in zip(qd_type_list, marker_list, color_list, strict=True): niter = np.zeros(len(results[setup][1])) for key in results.keys(): if isinstance(key, ID): diff --git a/pySDC/projects/parallelSDC/preconditioner_playground_MPI.py b/pySDC/projects/parallelSDC/preconditioner_playground_MPI.py index 574b95db9e..c6820b1673 100644 --- a/pySDC/projects/parallelSDC/preconditioner_playground_MPI.py +++ b/pySDC/projects/parallelSDC/preconditioner_playground_MPI.py @@ -206,7 +206,7 @@ def plot_setup(results, setup): fig, ax = plt_helper.newfig(textwidth=238.96, scale=0.89) - for qd_type, marker, color in zip(qd_type_list, marker_list, color_list): + for qd_type, marker, color in zip(qd_type_list, marker_list, color_list, strict=True): niter = np.zeros(len(results[setup][1])) for key in results.keys(): if isinstance(key, ID): diff --git a/pySDC/projects/parallelSDC_reloaded/convergence.py b/pySDC/projects/parallelSDC_reloaded/convergence.py index 04128c661c..85caef292e 100644 --- a/pySDC/projects/parallelSDC_reloaded/convergence.py +++ b/pySDC/projects/parallelSDC_reloaded/convergence.py @@ -46,7 +46,7 @@ def getError(uNum, uRef): # Script execution # ----------------------------------------------------------------------------- plt.figure() -for (qDelta, nSweeps), style in zip(schemes, styles): +for (qDelta, nSweeps), style in zip(schemes, styles, strict=True): if nSweeps is None: params = getParamsRK(qDelta) label = None diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py index 618810e6a1..d6bd751d38 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py @@ -66,7 +66,7 @@ def getError(uNum, uRef): # Figure generation figName = f"{sweepType}_{quadType}" plt.figure(f"{sweepType}_{quadType}") - for (qDelta, nSweeps), style in zip(schemes, styles): + for (qDelta, nSweeps), style in zip(schemes, styles, strict=True): params = getParamsSDC(quadType, nNodes, qDelta, nSweeps, nodeType) label = f"$K={nSweeps}$" errors = [] diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py index 04527c625a..e2b2e7e054 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py @@ -69,7 +69,7 @@ def getError(uNum, uRef): config = ["PIC", "MIN-SR-NS"] -for qDelta, sym in zip(config, symList): +for qDelta, sym in zip(config, symList, strict=True): figName = f"{SCRIPT}_conv_{qDelta}" plt.figure(figName) @@ -132,7 +132,7 @@ def getCost(counters): i += 1 plt.figure(figName) - for qDelta, sym in zip(qDeltaList, symList): + for qDelta, sym in zip(qDeltaList, symList, strict=True): try: params = getParamsRK(qDelta) except KeyError: diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig04_protheroRobinson.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig04_protheroRobinson.py index ae004ca75b..82b161e421 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig04_protheroRobinson.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig04_protheroRobinson.py @@ -60,7 +60,7 @@ def getCost(counters): figNameCost = f"{SCRIPT}_cost_{i}" i += 1 - for qDelta, sym in zip(qDeltaList, symList): + for qDelta, sym in zip(qDeltaList, symList, strict=True): try: params = getParamsRK(qDelta) except KeyError: diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py index 78e3e3bd46..940ad0b3b4 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py @@ -84,7 +84,7 @@ def getCost(counters): figNameCost = f"{SCRIPT}_cost_{i}" i += 1 - for qDelta, sym in zip(qDeltaList, symList): + for qDelta, sym in zip(qDeltaList, symList, strict=True): try: params = getParamsRK(qDelta) except KeyError: diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py index 9f5d5560c3..e21f136554 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py @@ -36,7 +36,7 @@ figNameConv = f"{SCRIPT}_conv_1" figNameCost = f"{SCRIPT}_cost_1" - for qDelta, sym in zip(qDeltaList, symList): + for qDelta, sym in zip(qDeltaList, symList, strict=True): if qDelta == "MIN-SR-NS": res = timings["MIN-SR-S_MPI"].copy() res["errors"] = [np.nan for _ in res["errors"]] @@ -83,7 +83,10 @@ ), f"parallel and sequential errors are not close for {qDelta}" tComp = seq["costs"] tCompMPI = par["costs"] - meanEff += np.mean([tS / tP for tP, tS in zip(tCompMPI, tComp)]) - print(f"{qDelta:12} |" + '|'.join(f" {tS/tP:1.1f} ({tS/tP/4*100:1.0f}%) " for tP, tS in zip(tCompMPI, tComp))) + meanEff += np.mean([tS / tP for tP, tS in zip(tCompMPI, tComp, strict=True)]) + print( + f"{qDelta:12} |" + + '|'.join(f" {tS/tP:1.1f} ({tS/tP/4*100:1.0f}%) " for tP, tS in zip(tCompMPI, tComp, strict=True)) + ) meanEff /= 3 print("Mean parallel efficiency :", meanEff / 4) diff --git a/pySDC/projects/parallelSDC_reloaded/vanderpol_accuracy.py b/pySDC/projects/parallelSDC_reloaded/vanderpol_accuracy.py index 82e7e01d98..d0d9eb9871 100644 --- a/pySDC/projects/parallelSDC_reloaded/vanderpol_accuracy.py +++ b/pySDC/projects/parallelSDC_reloaded/vanderpol_accuracy.py @@ -57,7 +57,7 @@ def getCost(counters): fig, axs = plt.subplots(2, len(muVals)) -for j, (mu, tEnd) in enumerate(zip(muVals, tEndVals)): +for j, (mu, tEnd) in enumerate(zip(muVals, tEndVals, strict=True)): print("-" * 80) print(f"mu={mu}") print("-" * 80) diff --git a/pySDC/projects/parallelSDC_reloaded/vanderpol_setup.py b/pySDC/projects/parallelSDC_reloaded/vanderpol_setup.py index 1d6c59461c..80503af764 100644 --- a/pySDC/projects/parallelSDC_reloaded/vanderpol_setup.py +++ b/pySDC/projects/parallelSDC_reloaded/vanderpol_setup.py @@ -38,7 +38,7 @@ muPeriods.append(period) # Compute and plot solution for each mu on one period, scale time with period -for mu, tEnd in zip(muVals, muPeriods): +for mu, tEnd in zip(muVals, muPeriods, strict=True): nSteps = 200 tVals = np.linspace(0, tEnd, nSteps + 1) diff --git a/pySDC/tutorial/step_7/F_2_plot_pySDC_with_Gusto_result.py b/pySDC/tutorial/step_7/F_2_plot_pySDC_with_Gusto_result.py index 8d091e3337..bc6970dcca 100644 --- a/pySDC/tutorial/step_7/F_2_plot_pySDC_with_Gusto_result.py +++ b/pySDC/tutorial/step_7/F_2_plot_pySDC_with_Gusto_result.py @@ -77,7 +77,14 @@ def plot_williamson_5( time_idx = 0 for i, (field_name, colour_scheme, field_label, contour_to_remove, contours) in enumerate( - zip(init_field_names, init_colour_schemes, init_field_labels, init_contours_to_remove, init_contours) + zip( + init_field_names, + init_colour_schemes, + init_field_labels, + init_contours_to_remove, + init_contours, + strict=True, + ) ): # Make axes @@ -150,7 +157,14 @@ def plot_williamson_5( time_idx = -1 for i, (field_name, colour_scheme, field_label, contours, contour_to_remove) in enumerate( - zip(final_field_names, final_colour_schemes, final_field_labels, final_contours, final_contours_to_remove) + zip( + final_field_names, + final_colour_schemes, + final_field_labels, + final_contours, + final_contours_to_remove, + strict=True, + ) ): # Make axes diff --git a/pySDC/tutorial/step_8/B_multistep_SDC.py b/pySDC/tutorial/step_8/B_multistep_SDC.py index f0fff9779d..00c27b2208 100644 --- a/pySDC/tutorial/step_8/B_multistep_SDC.py +++ b/pySDC/tutorial/step_8/B_multistep_SDC.py @@ -136,7 +136,7 @@ def main(): # compute and print statistics for item_pfasst, item_mssdc_jac, item_mssdc_gs in zip( - iter_counts_pfasst, iter_counts_mssdc_jac, iter_counts_mssdc_gs + iter_counts_pfasst, iter_counts_mssdc_jac, iter_counts_mssdc_gs, strict=True ): out = 'Number of iterations for time %4.2f (PFASST/parMSSDC/serMSSDC): %2i / %2i / %2i' % ( item_pfasst[0], diff --git a/pySDC/tutorial/step_8/C_iteration_estimator.py b/pySDC/tutorial/step_8/C_iteration_estimator.py index 63d9c856a7..0244f46d79 100644 --- a/pySDC/tutorial/step_8/C_iteration_estimator.py +++ b/pySDC/tutorial/step_8/C_iteration_estimator.py @@ -259,7 +259,7 @@ def run_simulations(type=None, ndim_list=None, Tend=None, nsteps_list=None, ml=F # filter statistics by type (error after time-step) PDE_errors = get_sorted(stats, type='PDE_error_after_step', sortby='time') coll_errors = get_sorted(stats, type='coll_error_after_step', sortby='time') - for iters, PDE_err, coll_err in zip(iter_counts, PDE_errors, coll_errors): + for iters, PDE_err, coll_err in zip(iter_counts, PDE_errors, coll_errors, strict=True): assert coll_err[1] < description['step_params']['errtol'], f'Error too high, got {coll_err[1]:8.4e}' out = ( f' Errors after step {PDE_err[0]:8.4f} with {iters[1]} iterations: ' diff --git a/pyproject.toml b/pyproject.toml index 1b5a902a58..469b12ecb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,6 @@ ignore = ["E203", # Whitespace before punctuation "C901", # Complex name "E501", # Line length, as enforced by black, but black ignores comments "E721", # Type comparison - "B905" # zip without strict ] # W504 is not supported by ruff and does not need to be excluded From 9f4f318392bff14a5ba00880801407c0362ee3a2 Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:15:53 +0200 Subject: [PATCH 4/4] Fixes --- pySDC/helpers/transfer_helper.py | 4 ++-- pySDC/projects/GPU/analysis_scripts/plot_RBC_matrix.py | 2 +- pySDC/projects/PinTSimE/battery_model.py | 2 +- pySDC/projects/parallelSDC_reloaded/convergence.py | 2 +- pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py | 2 +- pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py | 4 ++-- .../parallelSDC_reloaded/scripts/fig04_protheroRobinson.py | 2 +- .../projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py | 2 +- .../parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pySDC/helpers/transfer_helper.py b/pySDC/helpers/transfer_helper.py index 378635e812..1b91cfc33a 100644 --- a/pySDC/helpers/transfer_helper.py +++ b/pySDC/helpers/transfer_helper.py @@ -27,7 +27,7 @@ def next_neighbors_periodic(p, ps, k): # zip it value_index = [] - for d, i in zip(distance_to_p, range(distance_to_p.size, strict=True)): + for d, i in zip(distance_to_p, range(distance_to_p.size), strict=True): value_index.append((d, i)) # sort by distance value_index_sorted = sorted(value_index, key=lambda s: s[0]) @@ -53,7 +53,7 @@ def next_neighbors(p, ps, k): distance_to_p = np.abs(ps - p) # zip it value_index = [] - for d, i in zip(distance_to_p, range(distance_to_p.size, strict=True)): + for d, i in zip(distance_to_p, range(distance_to_p.size), strict=True): value_index.append((d, i)) # sort by distance value_index_sorted = sorted(value_index, key=lambda s: s[0]) diff --git a/pySDC/projects/GPU/analysis_scripts/plot_RBC_matrix.py b/pySDC/projects/GPU/analysis_scripts/plot_RBC_matrix.py index 9ae2743406..ba6a86ca8f 100644 --- a/pySDC/projects/GPU/analysis_scripts/plot_RBC_matrix.py +++ b/pySDC/projects/GPU/analysis_scripts/plot_RBC_matrix.py @@ -15,7 +15,7 @@ def plot_preconditioners(): # pragma: no cover fig, axs = plt.subplots(1, 4, figsize=figsize_by_journal('TUHH_thesis', 1, 0.4), sharex=True, sharey=True) - for M, ax in zip([A, A_b, A_r, A_l], axs): + for M, ax in zip([A, A_b, A_r, A_l], axs, strict=True): ax.imshow((M / abs(M)).real + (M / abs(M)).imag, rasterized=False, cmap='Spectral') for ax in axs: diff --git a/pySDC/projects/PinTSimE/battery_model.py b/pySDC/projects/PinTSimE/battery_model.py index 48f3a9ae3c..a437a532dd 100644 --- a/pySDC/projects/PinTSimE/battery_model.py +++ b/pySDC/projects/PinTSimE/battery_model.py @@ -578,7 +578,7 @@ def getDataDict(stats, prob_cls_name, use_adaptivity, use_detection, recomputed, if not all(t is None for t in t_switch_exact): event_err = [ abs(num_item - ex_item) - for (num_item, ex_item) in zip(res['t_switches'], res['t_switch_exact'], strict=True) + for (num_item, ex_item) in zip(res['t_switches'], res['t_switch_exact'], strict=False) ] res['e_event'] = event_err diff --git a/pySDC/projects/parallelSDC_reloaded/convergence.py b/pySDC/projects/parallelSDC_reloaded/convergence.py index 85caef292e..8db023b16e 100644 --- a/pySDC/projects/parallelSDC_reloaded/convergence.py +++ b/pySDC/projects/parallelSDC_reloaded/convergence.py @@ -46,7 +46,7 @@ def getError(uNum, uRef): # Script execution # ----------------------------------------------------------------------------- plt.figure() -for (qDelta, nSweeps), style in zip(schemes, styles, strict=True): +for (qDelta, nSweeps), style in zip(schemes, styles, strict=False): if nSweeps is None: params = getParamsRK(qDelta) label = None diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py index d6bd751d38..d3c8d7786a 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig01_conv.py @@ -66,7 +66,7 @@ def getError(uNum, uRef): # Figure generation figName = f"{sweepType}_{quadType}" plt.figure(f"{sweepType}_{quadType}") - for (qDelta, nSweeps), style in zip(schemes, styles, strict=True): + for (qDelta, nSweeps), style in zip(schemes, styles, strict=False): params = getParamsSDC(quadType, nNodes, qDelta, nSweeps, nodeType) label = f"$K={nSweeps}$" errors = [] diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py index e2b2e7e054..b875281435 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig03_lorenz.py @@ -69,7 +69,7 @@ def getError(uNum, uRef): config = ["PIC", "MIN-SR-NS"] -for qDelta, sym in zip(config, symList, strict=True): +for qDelta, sym in zip(config, symList, strict=False): figName = f"{SCRIPT}_conv_{qDelta}" plt.figure(figName) @@ -132,7 +132,7 @@ def getCost(counters): i += 1 plt.figure(figName) - for qDelta, sym in zip(qDeltaList, symList, strict=True): + for qDelta, sym in zip(qDeltaList, symList, strict=False): try: params = getParamsRK(qDelta) except KeyError: diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig04_protheroRobinson.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig04_protheroRobinson.py index 82b161e421..6a5e4555af 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig04_protheroRobinson.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig04_protheroRobinson.py @@ -60,7 +60,7 @@ def getCost(counters): figNameCost = f"{SCRIPT}_cost_{i}" i += 1 - for qDelta, sym in zip(qDeltaList, symList, strict=True): + for qDelta, sym in zip(qDeltaList, symList, strict=False): try: params = getParamsRK(qDelta) except KeyError: diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py index 940ad0b3b4..dc8ee3a54c 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig05_allenCahn.py @@ -84,7 +84,7 @@ def getCost(counters): figNameCost = f"{SCRIPT}_cost_{i}" i += 1 - for qDelta, sym in zip(qDeltaList, symList, strict=True): + for qDelta, sym in zip(qDeltaList, symList, strict=False): try: params = getParamsRK(qDelta) except KeyError: diff --git a/pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py b/pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py index e21f136554..3294e21f4c 100644 --- a/pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py +++ b/pySDC/projects/parallelSDC_reloaded/scripts/fig06_allenCahnMPI_plot.py @@ -36,7 +36,7 @@ figNameConv = f"{SCRIPT}_conv_1" figNameCost = f"{SCRIPT}_cost_1" - for qDelta, sym in zip(qDeltaList, symList, strict=True): + for qDelta, sym in zip(qDeltaList, symList, strict=False): if qDelta == "MIN-SR-NS": res = timings["MIN-SR-S_MPI"].copy() res["errors"] = [np.nan for _ in res["errors"]]