From 6c0eeb1555c399068057f28fb62adee39d0578ca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:34:56 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.6...v0.9.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c07ad07f74a..9279bcd038d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -69,7 +69,7 @@ repos: # Python: Ruff linter & formatter # https://docs.astral.sh/ruff/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.9.1 hooks: # Run the linter - id: ruff From 4540d988c26ceb5504d715e8bb43684ce82b5ec5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:35:06 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../ml_materials/run_warpx_training.py | 2 +- .../usage/workflows/ml_materials/train.py | 2 +- .../inputs_base_1d_picmi.py | 2 +- .../laser_acceleration/analysis_openpmd_rz.py | 24 +++++----- .../Physics_applications/laser_ion/plot_2d.py | 4 +- .../spacecraft_charging/analysis.py | 6 +-- .../Tests/accelerator_lattice/analysis.py | 6 ++- Examples/Tests/boundaries/analysis.py | 12 ++--- .../analysis.py | 2 +- ...effective_potential_electrostatic_picmi.py | 6 +-- ...test_2d_ohm_solver_landau_damping_picmi.py | 2 +- ...nputs_test_1d_ohm_solver_ion_beam_picmi.py | 2 +- ..._ohm_solver_magnetic_reconnection_picmi.py | 14 +++--- .../particle_boundary_interaction/analysis.py | 6 +-- .../Tests/pass_mpi_communicator/analysis.py | 6 +-- Examples/Tests/plasma_lens/analysis.py | 12 +++-- Python/pywarpx/fields.py | 4 +- Python/pywarpx/particle_containers.py | 48 +++++++++---------- Python/pywarpx/picmi.py | 16 +++---- Regression/Checksum/checksum.py | 3 +- .../post_processing_utils.py | 2 +- Tools/Algorithms/psatd.ipynb | 6 +-- Tools/Algorithms/stencil.py | 4 +- Tools/Release/releasePR.py | 2 +- setup.py | 2 +- 25 files changed, 99 insertions(+), 96 deletions(-) diff --git a/Docs/source/usage/workflows/ml_materials/run_warpx_training.py b/Docs/source/usage/workflows/ml_materials/run_warpx_training.py index 9e6b5682ec7..9a246de1cc2 100644 --- a/Docs/source/usage/workflows/ml_materials/run_warpx_training.py +++ b/Docs/source/usage/workflows/ml_materials/run_warpx_training.py @@ -260,7 +260,7 @@ def get_laser(antenna_z, profile_t_peak, fill_in=True): diag_particle_list = ["weighting", "position", "momentum"] coarse_btd_end = int((L_plasma_bulk + 0.001 + stage_spacing * (N_stage - 1)) * 100000) stage_end_snapshots = [ - f"{int((L_plasma_bulk+stage_spacing*ii)*100000)}:{int((L_plasma_bulk+stage_spacing*ii)*100000+50)}:5" + f"{int((L_plasma_bulk + stage_spacing * ii) * 100000)}:{int((L_plasma_bulk + stage_spacing * ii) * 100000 + 50)}:5" for ii in range(1) ] btd_particle_diag = picmi.LabFrameParticleDiagnostic( diff --git a/Docs/source/usage/workflows/ml_materials/train.py b/Docs/source/usage/workflows/ml_materials/train.py index 957a652e0c4..35b02c5cd44 100644 --- a/Docs/source/usage/workflows/ml_materials/train.py +++ b/Docs/source/usage/workflows/ml_materials/train.py @@ -180,7 +180,7 @@ def test_dataset(model, test_source, test_target, loss_fun): ) # Manual: Training loop END t4 = time.time() -print(f"total training time: {t4-t3:.3f}s") +print(f"total training time: {t4 - t3:.3f}s") ######### save model ######### diff --git a/Examples/Physics_applications/capacitive_discharge/inputs_base_1d_picmi.py b/Examples/Physics_applications/capacitive_discharge/inputs_base_1d_picmi.py index 3de88f3b3cb..a03cf1954ad 100644 --- a/Examples/Physics_applications/capacitive_discharge/inputs_base_1d_picmi.py +++ b/Examples/Physics_applications/capacitive_discharge/inputs_base_1d_picmi.py @@ -423,7 +423,7 @@ def run_sim(self): assert hasattr(self.solver, "phi") if libwarpx.amr.ParallelDescriptor.MyProc() == 0: - np.save(f"ion_density_case_{self.n+1}.npy", self.ion_density_array) + np.save(f"ion_density_case_{self.n + 1}.npy", self.ion_density_array) # query the particle z-coordinates if this is run during CI testing # to cover that functionality diff --git a/Examples/Physics_applications/laser_acceleration/analysis_openpmd_rz.py b/Examples/Physics_applications/laser_acceleration/analysis_openpmd_rz.py index f136ffeb1d4..1449e54d8ee 100755 --- a/Examples/Physics_applications/laser_acceleration/analysis_openpmd_rz.py +++ b/Examples/Physics_applications/laser_acceleration/analysis_openpmd_rz.py @@ -20,15 +20,15 @@ # this is in C (Python) order; r is the fastest varying index (Nm, Nz, Nr) = jt.shape -assert ( - Nm == 3 -), "Wrong number of angular modes stored or possible incorrect ordering when flushed" -assert ( - Nr == 64 -), "Wrong number of radial points stored or possible incorrect ordering when flushed" -assert ( - Nz == 512 -), "Wrong number of z points stored or possible incorrect ordering when flushed" +assert Nm == 3, ( + "Wrong number of angular modes stored or possible incorrect ordering when flushed" +) +assert Nr == 64, ( + "Wrong number of radial points stored or possible incorrect ordering when flushed" +) +assert Nz == 512, ( + "Wrong number of z points stored or possible incorrect ordering when flushed" +) assert ii.meshes["part_per_grid"][io.Mesh_Record_Component.SCALAR].shape == [ 512, @@ -60,6 +60,6 @@ electron_meanz = np.sum(np.dot(zlist, rhoe0)) / np.sum(rhoe0) beam_meanz = np.sum(np.dot(zlist, rhob0)) / np.sum(rhob0) -assert ( - (electron_meanz > 0) and (beam_meanz < 0) -), "problem with openPMD+RZ. Maybe openPMD+RZ mixed up the order of rho_ diagnostics?" +assert (electron_meanz > 0) and (beam_meanz < 0), ( + "problem with openPMD+RZ. Maybe openPMD+RZ mixed up the order of rho_ diagnostics?" +) diff --git a/Examples/Physics_applications/laser_ion/plot_2d.py b/Examples/Physics_applications/laser_ion/plot_2d.py index b3aefb80606..87b2d76c8f7 100644 --- a/Examples/Physics_applications/laser_ion/plot_2d.py +++ b/Examples/Physics_applications/laser_ion/plot_2d.py @@ -120,7 +120,7 @@ def visualize_density_iteration(ts, iteration, out_dir): for ax in axs[:-1]: ax.set_xticklabels([]) axs[2].set_xlabel(r"$z$ ($\mu$m)") - fig.suptitle(f"Iteration: {it}, Time: {time/1e-15:.1f} fs") + fig.suptitle(f"Iteration: {it}, Time: {time / 1e-15:.1f} fs") plt.tight_layout() @@ -190,7 +190,7 @@ def visualize_field_iteration(ts, iteration, out_dir): for ax in axs[:-1]: ax.set_xticklabels([]) axs[2].set_xlabel(r"$z$ ($\mu$m)") - fig.suptitle(f"Iteration: {it}, Time: {time/1e-15:.1f} fs") + fig.suptitle(f"Iteration: {it}, Time: {time / 1e-15:.1f} fs") plt.tight_layout() diff --git a/Examples/Physics_applications/spacecraft_charging/analysis.py b/Examples/Physics_applications/spacecraft_charging/analysis.py index 8e13657b62e..9e4b9e8219f 100755 --- a/Examples/Physics_applications/spacecraft_charging/analysis.py +++ b/Examples/Physics_applications/spacecraft_charging/analysis.py @@ -68,6 +68,6 @@ def func(x, v0, tau): print("percentage error for v0 = " + str(diff_v0 * 100) + "%") print("percentage error for tau = " + str(diff_tau * 100) + "%") -assert (diff_v0 < tolerance_v0) and ( - diff_tau < tolerance_tau -), "Test spacecraft_charging did not pass" +assert (diff_v0 < tolerance_v0) and (diff_tau < tolerance_tau), ( + "Test spacecraft_charging did not pass" +) diff --git a/Examples/Tests/accelerator_lattice/analysis.py b/Examples/Tests/accelerator_lattice/analysis.py index f53d54cbe12..331c5322e03 100755 --- a/Examples/Tests/accelerator_lattice/analysis.py +++ b/Examples/Tests/accelerator_lattice/analysis.py @@ -118,9 +118,11 @@ def applylens(x0, vx0, vz0, gamma, lens_length, lens_strength): xx = xx + dt * vx # Compare the analytic to the simulated final values -print(f"Error in x position is {abs(np.abs((xx - xx_sim)/xx))}, which should be < 0.01") print( - f"Error in x velocity is {abs(np.abs((ux - ux_sim)/ux))}, which should be < 0.002" + f"Error in x position is {abs(np.abs((xx - xx_sim) / xx))}, which should be < 0.01" +) +print( + f"Error in x velocity is {abs(np.abs((ux - ux_sim) / ux))}, which should be < 0.002" ) assert abs(np.abs((xx - xx_sim) / xx)) < 0.01, Exception("error in x particle position") diff --git a/Examples/Tests/boundaries/analysis.py b/Examples/Tests/boundaries/analysis.py index 9630c07d0ab..29de2bb37cb 100755 --- a/Examples/Tests/boundaries/analysis.py +++ b/Examples/Tests/boundaries/analysis.py @@ -101,9 +101,9 @@ def do_periodic(x): assert len(a_id) == 1, "Absorbing particles not absorbed" assert np.all(vx == -vx0), "Reflecting particle velocity not correct" assert np.all(vz == +vz0), "Periodic particle velocity not correct" -assert np.all( - np.abs((xx - xxa) / xx) < 1.0e-15 -), "Reflecting particle position not correct" -assert np.all( - np.abs((zz - zza) / zz) < 1.0e-15 -), "Periodic particle position not correct" +assert np.all(np.abs((xx - xxa) / xx) < 1.0e-15), ( + "Reflecting particle position not correct" +) +assert np.all(np.abs((zz - zza) / zz) < 1.0e-15), ( + "Periodic particle position not correct" +) diff --git a/Examples/Tests/effective_potential_electrostatic/analysis.py b/Examples/Tests/effective_potential_electrostatic/analysis.py index b51cd129252..20998e0a066 100755 --- a/Examples/Tests/effective_potential_electrostatic/analysis.py +++ b/Examples/Tests/effective_potential_electrostatic/analysis.py @@ -66,7 +66,7 @@ def get_radial_function(field, info): ) plt.plot(r_grid, n_e_analytic, "k--", alpha=0.6) - plt.plot(r_grid, n_e, label=f"t = {ts.t[ii]*1e6:.2f} $\mu$s") + plt.plot(r_grid, n_e, label=f"t = {ts.t[ii] * 1e6:.2f} $\mu$s") print("RMS error (%) in density: ", rms_errors) assert np.all(rms_errors < 0.05) diff --git a/Examples/Tests/effective_potential_electrostatic/inputs_test_3d_effective_potential_electrostatic_picmi.py b/Examples/Tests/effective_potential_electrostatic/inputs_test_3d_effective_potential_electrostatic_picmi.py index 27b1728b7b2..018739aa682 100644 --- a/Examples/Tests/effective_potential_electrostatic/inputs_test_3d_effective_potential_electrostatic_picmi.py +++ b/Examples/Tests/effective_potential_electrostatic/inputs_test_3d_effective_potential_electrostatic_picmi.py @@ -102,13 +102,13 @@ print( f"Plasma parameters:\n" f"\tlambda_e = {lambda_e:.1e} m\n" - f"\tt_pe = {1.0/f_pe:.1e} s\n" + f"\tt_pe = {1.0 / f_pe:.1e} s\n" f"\tv_ti = {v_ti:.1e} m/s\n" ) print( f"Numerical parameters:\n" - f"\tdz/lambda_e = {dz/lambda_e:.2f}\n" - f"\tdt*w_pe = {dt*f_pe*2.0*np.pi:.2f}\n" + f"\tdz/lambda_e = {dz / lambda_e:.2f}\n" + f"\tdt*w_pe = {dt * f_pe * 2.0 * np.pi:.2f}\n" f"\tdiag steps = {diag_steps:d}\n" f"\ttotal steps = {total_steps:d}\n" ) diff --git a/Examples/Tests/ohm_solver_ion_Landau_damping/inputs_test_2d_ohm_solver_landau_damping_picmi.py b/Examples/Tests/ohm_solver_ion_Landau_damping/inputs_test_2d_ohm_solver_landau_damping_picmi.py index 7c1709d059f..320d36785db 100644 --- a/Examples/Tests/ohm_solver_ion_Landau_damping/inputs_test_2d_ohm_solver_landau_damping_picmi.py +++ b/Examples/Tests/ohm_solver_ion_Landau_damping/inputs_test_2d_ohm_solver_landau_damping_picmi.py @@ -93,7 +93,7 @@ def __init__(self, test, dim, m, T_ratio, verbose): if comm.rank == 0: print( f"Initializing simulation with input parameters:\n" - f"\tT = {self.T_plasma*1e-3:.1f} keV\n" + f"\tT = {self.T_plasma * 1e-3:.1f} keV\n" f"\tn = {self.n_plasma:.1e} m^-3\n" f"\tB0 = {self.B0:.2f} T\n" f"\tM/m = {self.m_ion:.0f}\n" diff --git a/Examples/Tests/ohm_solver_ion_beam_instability/inputs_test_1d_ohm_solver_ion_beam_picmi.py b/Examples/Tests/ohm_solver_ion_beam_instability/inputs_test_1d_ohm_solver_ion_beam_picmi.py index 19569a04e5b..52160038831 100644 --- a/Examples/Tests/ohm_solver_ion_beam_instability/inputs_test_1d_ohm_solver_ion_beam_picmi.py +++ b/Examples/Tests/ohm_solver_ion_beam_instability/inputs_test_1d_ohm_solver_ion_beam_picmi.py @@ -110,7 +110,7 @@ def __init__(self, test, dim, resonant, verbose): if comm.rank == 0: print( f"Initializing simulation with input parameters:\n" - f"\tT = {self.T_plasma*1e-3:.1f} keV\n" + f"\tT = {self.T_plasma * 1e-3:.1f} keV\n" f"\tn = {self.n_plasma:.1e} m^-3\n" f"\tB0 = {self.B0:.2f} T\n" f"\tM/m = {self.m_ion:.0f}\n" diff --git a/Examples/Tests/ohm_solver_magnetic_reconnection/inputs_test_2d_ohm_solver_magnetic_reconnection_picmi.py b/Examples/Tests/ohm_solver_magnetic_reconnection/inputs_test_2d_ohm_solver_magnetic_reconnection_picmi.py index f074c81cbb3..2ddbd0df93d 100644 --- a/Examples/Tests/ohm_solver_magnetic_reconnection/inputs_test_2d_ohm_solver_magnetic_reconnection_picmi.py +++ b/Examples/Tests/ohm_solver_magnetic_reconnection/inputs_test_2d_ohm_solver_magnetic_reconnection_picmi.py @@ -83,14 +83,14 @@ def __init__(self, test, verbose): self.Bg *= self.B0 self.dB *= self.B0 self.Bx = ( - f"{self.B0}*tanh(z*{1.0/self.l_i})" - f"+{-self.dB*self.Lx/(2.0*self.Lz)}*cos({2.0*np.pi/self.Lx}*x)" - f"*sin({np.pi/self.Lz}*z)" + f"{self.B0}*tanh(z*{1.0 / self.l_i})" + f"+{-self.dB * self.Lx / (2.0 * self.Lz)}*cos({2.0 * np.pi / self.Lx}*x)" + f"*sin({np.pi / self.Lz}*z)" ) self.By = ( - f"sqrt({self.Bg**2 + self.B0**2}-" f"({self.B0}*tanh(z*{1.0/self.l_i}))**2)" + f"sqrt({self.Bg**2 + self.B0**2}-({self.B0}*tanh(z*{1.0 / self.l_i}))**2)" ) - self.Bz = f"{self.dB}*sin({2.0*np.pi/self.Lx}*x)*cos({np.pi/self.Lz}*z)" + self.Bz = f"{self.dB}*sin({2.0 * np.pi / self.Lx}*x)*cos({np.pi / self.Lz}*z)" self.J0 = self.B0 / constants.mu0 / self.l_i @@ -103,7 +103,7 @@ def __init__(self, test, verbose): if comm.rank == 0: print( f"Initializing simulation with input parameters:\n" - f"\tTi = {self.Ti*1e-3:.1f} keV\n" + f"\tTi = {self.Ti * 1e-3:.1f} keV\n" f"\tn0 = {self.n_plasma:.1e} m^-3\n" f"\tB0 = {self.B0:.2f} T\n" f"\tM/m = {self.m_ion:.0f}\n" @@ -117,7 +117,7 @@ def __init__(self, test, verbose): ) print( f"Numerical parameters:\n" - f"\tdz = {self.Lz/self.NZ:.1e} m\n" + f"\tdz = {self.Lz / self.NZ:.1e} m\n" f"\tdt = {self.dt:.1e} s\n" f"\tdiag steps = {self.diag_steps:d}\n" f"\ttotal steps = {self.total_steps:d}\n" diff --git a/Examples/Tests/particle_boundary_interaction/analysis.py b/Examples/Tests/particle_boundary_interaction/analysis.py index 062569d5553..edf9d463f98 100755 --- a/Examples/Tests/particle_boundary_interaction/analysis.py +++ b/Examples/Tests/particle_boundary_interaction/analysis.py @@ -43,6 +43,6 @@ print("percentage error for x = %5.4f %%" % (diff_x * 100)) print("percentage error for z = %5.4f %%" % (diff_z * 100)) -assert ( - (diff_x < tolerance) and (y[0] < 1e-8) and (diff_z < tolerance) -), "Test particle_boundary_interaction did not pass" +assert (diff_x < tolerance) and (y[0] < 1e-8) and (diff_z < tolerance), ( + "Test particle_boundary_interaction did not pass" +) diff --git a/Examples/Tests/pass_mpi_communicator/analysis.py b/Examples/Tests/pass_mpi_communicator/analysis.py index 041687c4775..cfac572c1b9 100755 --- a/Examples/Tests/pass_mpi_communicator/analysis.py +++ b/Examples/Tests/pass_mpi_communicator/analysis.py @@ -37,7 +37,7 @@ # Dictionaries have same outer keys (levels, species)? if checksum1.data.keys() != checksum2.data.keys(): - print("ERROR: plotfile 1 and plotfile 2 checksums " "have different outer keys:") + print("ERROR: plotfile 1 and plotfile 2 checksums have different outer keys:") print("Plot1: %s" % checksum1.data.keys()) print("Plot2: %s" % checksum2.data.keys()) sys.exit(1) @@ -45,9 +45,7 @@ # Dictionaries have same inner keys (field and particle quantities)? for key1 in checksum1.data.keys(): if checksum1.data[key1].keys() != checksum2.data[key1].keys(): - print( - "ERROR: plotfile 1 and plotfile 2 checksums have " "different inner keys:" - ) + print("ERROR: plotfile 1 and plotfile 2 checksums have different inner keys:") print("Common outer keys: %s" % checksum2.data.keys()) print("Plotfile 1 inner keys in %s: %s" % (key1, checksum1.data[key1].keys())) print("Plotfile 2 inner keys in %s: %s" % (key1, checksum2.data[key1].keys())) diff --git a/Examples/Tests/plasma_lens/analysis.py b/Examples/Tests/plasma_lens/analysis.py index 44671eea791..ed7ee653af6 100755 --- a/Examples/Tests/plasma_lens/analysis.py +++ b/Examples/Tests/plasma_lens/analysis.py @@ -160,13 +160,17 @@ def applylens(x0, vx0, vz0, gamma, lens_length, lens_strength): xx = xx + dt0 * vx yy = yy + dt1 * vy -print(f"Error in x position is {abs(np.abs((xx - xx_sim)/xx))}, which should be < 0.02") -print(f"Error in y position is {abs(np.abs((yy - yy_sim)/yy))}, which should be < 0.02") print( - f"Error in x velocity is {abs(np.abs((ux - ux_sim)/ux))}, which should be < 0.002" + f"Error in x position is {abs(np.abs((xx - xx_sim) / xx))}, which should be < 0.02" ) print( - f"Error in y velocity is {abs(np.abs((uy - uy_sim)/uy))}, which should be < 0.002" + f"Error in y position is {abs(np.abs((yy - yy_sim) / yy))}, which should be < 0.02" +) +print( + f"Error in x velocity is {abs(np.abs((ux - ux_sim) / ux))}, which should be < 0.002" +) +print( + f"Error in y velocity is {abs(np.abs((uy - uy_sim) / uy))}, which should be < 0.002" ) if plasma_lens_lengths[0] < 0.01: diff --git a/Python/pywarpx/fields.py b/Python/pywarpx/fields.py index 5d3b892b543..9beef1de5c8 100644 --- a/Python/pywarpx/fields.py +++ b/Python/pywarpx/fields.py @@ -284,10 +284,10 @@ def _find_start_stop(self, ii, imin, imax, d): iistart = ii iistop = ii + 1 assert imin <= iistart <= imax, Exception( - f"Dimension {d+1} lower index is out of bounds" + f"Dimension {d + 1} lower index is out of bounds" ) assert imin <= iistop <= imax, Exception( - f"Dimension {d+1} upper index is out of bounds" + f"Dimension {d + 1} upper index is out of bounds" ) return iistart, iistop diff --git a/Python/pywarpx/particle_containers.py b/Python/pywarpx/particle_containers.py index db5dfda883e..9a4d7257a69 100644 --- a/Python/pywarpx/particle_containers.py +++ b/Python/pywarpx/particle_containers.py @@ -107,31 +107,31 @@ def add_particles( maxlen = max(maxlen, lenw) # --- Make sure that the lengths of the input parameters are consistent - assert ( - x is None or lenx == maxlen or lenx == 1 - ), "Length of x doesn't match len of others" - assert ( - y is None or leny == maxlen or leny == 1 - ), "Length of y doesn't match len of others" - assert ( - z is None or lenz == maxlen or lenz == 1 - ), "Length of z doesn't match len of others" - assert ( - ux is None or lenux == maxlen or lenux == 1 - ), "Length of ux doesn't match len of others" - assert ( - uy is None or lenuy == maxlen or lenuy == 1 - ), "Length of uy doesn't match len of others" - assert ( - uz is None or lenuz == maxlen or lenuz == 1 - ), "Length of uz doesn't match len of others" - assert ( - w is None or lenw == maxlen or lenw == 1 - ), "Length of w doesn't match len of others" + assert x is None or lenx == maxlen or lenx == 1, ( + "Length of x doesn't match len of others" + ) + assert y is None or leny == maxlen or leny == 1, ( + "Length of y doesn't match len of others" + ) + assert z is None or lenz == maxlen or lenz == 1, ( + "Length of z doesn't match len of others" + ) + assert ux is None or lenux == maxlen or lenux == 1, ( + "Length of ux doesn't match len of others" + ) + assert uy is None or lenuy == maxlen or lenuy == 1, ( + "Length of uy doesn't match len of others" + ) + assert uz is None or lenuz == maxlen or lenuz == 1, ( + "Length of uz doesn't match len of others" + ) + assert w is None or lenw == maxlen or lenw == 1, ( + "Length of w doesn't match len of others" + ) for key, val in kwargs.items(): - assert ( - np.size(val) == 1 or len(val) == maxlen - ), f"Length of {key} doesn't match len of others" + assert np.size(val) == 1 or len(val) == maxlen, ( + f"Length of {key} doesn't match len of others" + ) # --- Broadcast scalars into appropriate length arrays # --- If the parameter was not supplied, use the default value diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index d464c44726f..f8261cd7847 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -2556,7 +2556,7 @@ def __init__( **kw, ): assert stl_file is None or implicit_function is None, Exception( - "Only one between implicit_function and " "stl_file can be specified" + "Only one between implicit_function and stl_file can be specified" ) self.implicit_function = implicit_function @@ -2666,9 +2666,9 @@ def __init__( self.strengths_E = strengths_E self.strengths_B = strengths_B - assert (self.strengths_E is not None) or ( - self.strengths_B is not None - ), Exception("One of strengths_E or strengths_B must be supplied") + assert (self.strengths_E is not None) or (self.strengths_B is not None), ( + Exception("One of strengths_E or strengths_B must be supplied") + ) self.handle_init(kw) @@ -3011,9 +3011,9 @@ def initialize_inputs(self): particle_shape = self.particle_shape for s in self.species: if s.particle_shape is not None: - assert ( - particle_shape is None or particle_shape == s.particle_shape - ), Exception("WarpX only supports one particle shape for all species") + assert particle_shape is None or particle_shape == s.particle_shape, ( + Exception("WarpX only supports one particle shape for all species") + ) # --- If this was set for any species, use that value. particle_shape = s.particle_shape @@ -4102,7 +4102,7 @@ def __init__( kw = self._handle_charge_on_eb(**kw) else: raise RuntimeError( - f"{self.type} reduced diagnostic is not yet supported " "in pywarpx." + f"{self.type} reduced diagnostic is not yet supported in pywarpx." ) self.handle_init(kw) diff --git a/Regression/Checksum/checksum.py b/Regression/Checksum/checksum.py index b2f327e36e3..8c93f4ea6ea 100644 --- a/Regression/Checksum/checksum.py +++ b/Regression/Checksum/checksum.py @@ -238,8 +238,7 @@ def evaluate(self, rtol=1.0e-9, atol=1.0e-40): # Dictionaries have same outer keys (levels, species)? if self.data.keys() != ref_benchmark.data.keys(): print( - "ERROR: Benchmark and output file checksum " - "have different outer keys:" + "ERROR: Benchmark and output file checksum have different outer keys:" ) print("Benchmark: %s" % ref_benchmark.data.keys()) print("Test file: %s" % self.data.keys()) diff --git a/Regression/PostProcessingUtils/post_processing_utils.py b/Regression/PostProcessingUtils/post_processing_utils.py index 55bc357c28b..cbd55c433d3 100644 --- a/Regression/PostProcessingUtils/post_processing_utils.py +++ b/Regression/PostProcessingUtils/post_processing_utils.py @@ -164,6 +164,6 @@ def check_random_filter(fn, filtered_fn, random_fraction, dim, species_name): ## Dirty trick to find particles with the same ID + same CPU (does not work with more than 10 ## MPI ranks) random_filter_expression = ( - "np.isin(ids + 0.1*cpus," "ids_filtered_warpx + 0.1*cpus_filtered_warpx)" + "np.isin(ids + 0.1*cpus,ids_filtered_warpx + 0.1*cpus_filtered_warpx)" ) check_particle_filter(fn, filtered_fn, random_filter_expression, dim, species_name) diff --git a/Tools/Algorithms/psatd.ipynb b/Tools/Algorithms/psatd.ipynb index 3e8b2a82d2e..6153b904968 100644 --- a/Tools/Algorithms/psatd.ipynb +++ b/Tools/Algorithms/psatd.ipynb @@ -64,9 +64,9 @@ " Wd[i, j] = Wd[i, j].expand().simplify()\n", " diff = W[i, j] - Wd[i, j]\n", " diff = diff.expand().simplify()\n", - " assert (\n", - " diff == 0\n", - " ), f\"Diagonalization failed: W[{i},{j}] - Wd[{i},{j}] = {diff} is not zero\"\n", + " assert diff == 0, (\n", + " f\"Diagonalization failed: W[{i},{j}] - Wd[{i},{j}] = {diff} is not zero\"\n", + " )\n", "\n", "\n", "def simple_mat(W):\n", diff --git a/Tools/Algorithms/stencil.py b/Tools/Algorithms/stencil.py index 2fe67d1c681..1fafd3837a7 100644 --- a/Tools/Algorithms/stencil.py +++ b/Tools/Algorithms/stencil.py @@ -361,10 +361,10 @@ def run_main( print("\nCell size:") print(f"- dx = {dx_boosted}") if dims > 1: - print(f"- dx[1:]/dx[0] = {dx_boosted[1:]/dx_boosted[0]}") + print(f"- dx[1:]/dx[0] = {dx_boosted[1:] / dx_boosted[0]}") print("\nTime step:") print(f"- dt = {dt}") - print(f"- c*dt/dx = {c*dt/dx_boosted}") + print(f"- c*dt/dx = {c * dt / dx_boosted}") print("\nSpectral order:") print(f"- order = {psatd_order}") print("\nLorentz boost, Galilean velocity:") diff --git a/Tools/Release/releasePR.py b/Tools/Release/releasePR.py index 3fd1b016efd..9dfa178e5b4 100755 --- a/Tools/Release/releasePR.py +++ b/Tools/Release/releasePR.py @@ -171,7 +171,7 @@ def concat_answers(answers): "--title", f"Release {WarpX_version}", "--body", - f"""Prepare the {datetime.now().strftime('%B')} release of WarpX: + f"""Prepare the {datetime.now().strftime("%B")} release of WarpX: ```bash # update dependencies ./Tools/Release/updateAMReX.py diff --git a/setup.py b/setup.py index c3f2e730726..ad5501371c5 100644 --- a/setup.py +++ b/setup.py @@ -342,7 +342,7 @@ def build_extension(self, ext): "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", ( - "License :: OSI Approved :: " "BSD License" + "License :: OSI Approved :: BSD License" ), # TODO: use real SPDX: BSD-3-Clause-LBNL ], # new PEP 639 format