Skip to content

Commit

Permalink
fix #6611 frame_arg enums may be treated as intergers (#6612)
Browse files Browse the repository at this point in the history
* fixed test, + character is not decoded in paths
  • Loading branch information
moellep authored Dec 20, 2023
1 parent 21b5b5b commit a6afbac
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion sirepo/template/flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _files():
frame_args.var,
frame_args.axis,
_LINEOUTS_SAMPLING_SIZE,
interpolate=frame_args.get("interpolate", "1") == "1",
interpolate=str(frame_args.get("interpolate", "1")) == "1",
)
x = xs[0]
r = [numpy.min(x), numpy.max(x)]
Expand Down
17 changes: 8 additions & 9 deletions sirepo/template/srw.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,6 @@ def _copy_frame_args_into_model(frame_args, name):
for f in frame_args:
if f in m and f in m_schema:
m[f] = frame_args[f]
if m_schema[f][1] == "Float":
m[f] = re.sub(r"\s", "+", m[f])
m[f] = float(m[f])
elif m_schema[f][1] == "Integer":
m[f] = int(m[f])
return m


Expand Down Expand Up @@ -2179,6 +2174,10 @@ def _is_for_rsopt(report):
return report == _SIM_DATA.EXPORT_RSOPT


def _is_true(model, field):
return str(model.get(field, "0")) == "1"


def _load_user_model_list(model_name, qcall=None):
f = _SIM_DATA.lib_file_write_path(
_USER_MODEL_LIST_FILENAME[model_name], qcall=qcall
Expand Down Expand Up @@ -2241,7 +2240,7 @@ def _remap_3d(info, allrange, out, report):
info.subtitle = info.subtitle + " Image Rotate {}^0".format(rotate_angle)
if out.units[2]:
out.labels[2] = "{} [{}]".format(out.labels[2], out.units[2])
if report.get("useIntensityLimits", "0") == "1":
if _is_true(report, "useIntensityLimits"):
z_range = [report.minIntensityLimit, report.maxIntensityLimit]
else:
z_range = [np.min(ar2d), np.max(ar2d)]
Expand All @@ -2265,9 +2264,9 @@ def _reshape_3d(ar1d, allrange, report):
totLen = int(x_range[2] * y_range[2])
n = len(ar1d) if totLen > len(ar1d) else totLen
ar2d = np.reshape(ar1d[0:n], (int(y_range[2]), int(x_range[2])))
if report.get("usePlotRange", "0") == "1":
if _is_true(report, "usePlotRange"):
ar2d, x_range, y_range = _update_report_range(report, ar2d, x_range, y_range)
if report.get("useIntensityLimits", "0") == "1":
if _is_true(report, "useIntensityLimits"):
ar2d[ar2d < report["minIntensityLimit"]] = report["minIntensityLimit"]
ar2d[ar2d > report["maxIntensityLimit"]] = report["maxIntensityLimit"]
ar2d, x_range, y_range = _resize_report(report, ar2d, x_range, y_range)
Expand Down Expand Up @@ -2309,7 +2308,7 @@ def _rotate_report(report, ar2d, x_range, y_range):
from scipy import ndimage

rotate_angle = report.rotateAngle
rotate_reshape = report.get("rotateReshape", "0") == "1"
rotate_reshape = _is_true(report, "rotateReshape")
pkdc("Size before: {} Dimensions: {}", ar2d.size, ar2d.shape)
shape_before = list(ar2d.shape)
ar2d = ndimage.rotate(
Expand Down
4 changes: 2 additions & 2 deletions sirepo/template/zgoubi.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,13 @@ def _extract_animation(frame_args):
if row[kex_index] != "1":
# particle isn't active
continue
if frame_args.showAllFrames == "1":
if str(frame_args.showAllFrames) == "1":
if it_filter and row[it_index] != it_filter:
continue
rows.append(row)
elif int(row[ipass_index]) == ipass:
rows.append(row)
if frame_args.showAllFrames == "1":
if str(frame_args.showAllFrames) == "1":
title = "All Frames"
if it_filter:
title += ", Particle {}".format(it_filter)
Expand Down
2 changes: 1 addition & 1 deletion sirepo/uri_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def _init_uris(simulation_db, sim_types):
def _path_to_route(path):
if path is None:
return (None, _route_default, PKDict(path_info=None))
parts = re.sub(r"\+", " ", path).split("/")
parts = path.split("/")
route = None
kwargs = None
try:
Expand Down
2 changes: 1 addition & 1 deletion tests/server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ def test_srw(fc):
d = fc.sr_post("listSimulations", {"simulationType": fc.sr_sim_type})
r = fc.sr_get("/find-by-name-auth/srw/default/UndulatorRadiation")
r.assert_http_status(404)
for sep in (" ", "%20", "+"):
for sep in (" ", "%20"):
r = fc.sr_get("/find-by-name-auth/srw/default/Undulator{}Radiation".format(sep))
r.assert_http_status(200)

0 comments on commit a6afbac

Please sign in to comment.