Skip to content

Commit

Permalink
fix #7361 improve grammar for watchpont titles (#7364)
Browse files Browse the repository at this point in the history
  • Loading branch information
moellep authored Nov 19, 2024
1 parent d587811 commit 76f1b7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 76f1b7c

Please sign in to comment.