Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #7361 improve grammar for watchpont titles #7364

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions sirepo/template/srw.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
units=["m", "m", "m"],
),
multiElectronAnimation=PKDict(
title="Intensity After {name}, {position} (E={photonEnergyWithUnits})",
title="Intensity {name}, {position} (E={photonEnergyWithUnits})",
filename="res_int_pr_me.dat",
dimensions=3,
),
Expand All @@ -115,7 +115,7 @@
dimensions=2,
),
watchpointReport=PKDict(
title="Intensity After {name}, {position} (E={photonEnergyWithUnits})",
title="Intensity {name}, {position} (E={photonEnergyWithUnits})",
subtitle="{characteristic}",
filename="res_int_pr_se.dat",
dimensions=3,
Expand Down Expand Up @@ -1517,7 +1517,12 @@ def _element_name(sim_in, watchpoint_id):
watchpoint_id = sim_in.models.multiElectronAnimation.get("watchpointId", 0)
for e in sim_in.models.beamline:
if e.id == watchpoint_id:
return e.title
# use "at {title}" unless the watchpoint name contains a common preposition
if re.search(
r"\b(after|at|before|in|near)\b", e.title, re.IGNORECASE
) or re.search(r"\b(pre|post)", e.title, re.IGNORECASE):
return e.title
return f"at {e.title}"
return ""


Expand Down
2 changes: 1 addition & 1 deletion tests/animation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_srw(fc):
multiElectronAnimation=PKDict(
# Prevents "Memory Error" because SRW uses computeJobStart as frameCount
frame_index=0,
expect_title="Intensity After W60, 60 m \(E=4.24 keV\)",
expect_title="Intensity at W60, 60 m \(E=4.24 keV\)",
),
),
timeout=20,
Expand Down