Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#797)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.1](astral-sh/ruff-pre-commit@v0.8.6...v0.9.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Jan 13, 2025
1 parent 5638dfd commit cd74b3a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/initialize_from_array/transformation_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/python/impactx/dashboard/Toolbar/exportTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
)


Expand All @@ -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()
Expand Down

0 comments on commit cd74b3a

Please sign in to comment.