diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a06b195cb..661ae7c66 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,7 +66,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 diff --git a/examples/initialize_from_array/transformation_utilities.py b/examples/initialize_from_array/transformation_utilities.py index adb33b2aa..8e92bc918 100644 --- a/examples/initialize_from_array/transformation_utilities.py +++ b/examples/initialize_from_array/transformation_utilities.py @@ -183,11 +183,11 @@ def __init__(self, x, y, z, px, py, pz, pt): def __repr__(self): mystr = "" for attr in self.attr_list: - mystr += f"self.{attr}={getattr(self,attr)}, " + mystr += f"self.{attr}={getattr(self, attr)}, " return mystr def __str__(self): mystr = "" for attr in self.attr_list: - mystr += f"self.{attr}={getattr(self,attr)}, " + mystr += f"self.{attr}={getattr(self, attr)}, " return mystr diff --git a/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py b/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py index a49a024e3..3539993ae 100644 --- a/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py +++ b/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py @@ -276,9 +276,9 @@ def surrogate_push(self, pc, step, period): def get_lattice_element_iter(sim, j): - assert ( - 0 <= j < len(sim.lattice) - ), f"Argument j must be a nonnegative integer satisfying 0 <= j < {len(sim.lattice)}, not {j}" + assert 0 <= j < len(sim.lattice), ( + f"Argument j must be a nonnegative integer satisfying 0 <= j < {len(sim.lattice)}, not {j}" + ) i = 0 lat_it = sim.lattice.__iter__() next(lat_it) diff --git a/examples/pytorch_surrogate_model/visualize_ml_surrogate_15_stage.py b/examples/pytorch_surrogate_model/visualize_ml_surrogate_15_stage.py index a7ffd5097..6fada2371 100644 --- a/examples/pytorch_surrogate_model/visualize_ml_surrogate_15_stage.py +++ b/examples/pytorch_surrogate_model/visualize_ml_surrogate_15_stage.py @@ -88,9 +88,9 @@ def to_t( dpt = data_arr_s["momentum_t"] elif type(data_arr_s) is np.ndarray: - assert ( - data_arr_s.shape[1] == 6 - ), f"data_arr_s.shape={data_arr_s.shape} but data_arr_s must be an Nx6 array" + assert data_arr_s.shape[1] == 6, ( + f"data_arr_s.shape={data_arr_s.shape} but data_arr_s must be an Nx6 array" + ) dx, dy, dt, dpx, dpy, dpt = data_arr_s.T else: raise Exception( @@ -111,9 +111,9 @@ def to_t( print("applying reference normalization") dpt /= ref_pz elif coord_type is TCoords.GLOBAL: - assert ( - ref_z is not None - ), "Reference particle z coordinate is required to transform to global coordinates" + assert ref_z is not None, ( + "Reference particle z coordinate is required to transform to global coordinates" + ) print("target global coordinates") dt += ref_z dpx *= ref_pz @@ -422,7 +422,7 @@ def plot_beam_df( t_offset = impactx_surrogate_ref_particle.loc[step, "t"] * micron fig, axT = plt.subplots(3, 3, figsize=(10, 8)) -fig.suptitle(f"initially, ct={impactx_surrogate_ref_particle.at[step,'t']:.2f} m") +fig.suptitle(f"initially, ct={impactx_surrogate_ref_particle.at[step, 't']:.2f} m") plot_beam_df( beam_at_step, @@ -459,7 +459,7 @@ def plot_beam_df( t_offset = impactx_surrogate_ref_particle.loc[step, "t"] * micron fig, axT = plt.subplots(3, 3, figsize=(10, 8)) fig.suptitle( - f"stage {stage_i}, ct={impactx_surrogate_ref_particle.at[step,'t']:.2f} m" + f"stage {stage_i}, ct={impactx_surrogate_ref_particle.at[step, 't']:.2f} m" ) plot_beam_df( @@ -473,6 +473,6 @@ def plot_beam_df( z_ticks=[-107.3, -106.6], ) if args.save_png: - plt.savefig(f"stage_{stage_i-1}_phase_spaces.png") + plt.savefig(f"stage_{stage_i - 1}_phase_spaces.png") else: plt.show() diff --git a/setup.py b/setup.py index dcf8bd749..fa49892d6 100644 --- a/setup.py +++ b/setup.py @@ -284,7 +284,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 diff --git a/src/python/impactx/dashboard/Toolbar/exportTemplate.py b/src/python/impactx/dashboard/Toolbar/exportTemplate.py index cc00cd452..1fbf042e0 100644 --- a/src/python/impactx/dashboard/Toolbar/exportTemplate.py +++ b/src/python/impactx/dashboard/Toolbar/exportTemplate.py @@ -32,9 +32,7 @@ def build_distribution_list(): ) else: return ( - f"distr = distribution.{distribution_name}(\n" - f"{distribution_parameters},\n" - f")" + f"distr = distribution.{distribution_name}(\n{distribution_parameters},\n)" ) @@ -45,7 +43,7 @@ def build_lattice_list(): """ lattice_elements = ",\n ".join( - f'elements.{element["name"]}(' + f"elements.{element['name']}(" + ", ".join( f"{key}={value}" for key, value in parameter_input_checker_for_lattice(element).items()