Skip to content

Commit

Permalink
obey numexpr 2.9 (?) expression sanity check rules
Browse files Browse the repository at this point in the history
otherwise numexpr raises an error "expression xxx has forbidden control characters"
  • Loading branch information
skuschel committed Jul 8, 2024
1 parent f1d2687 commit b5bbb92
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions postpic/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ def _linear_phase(field, dx, phi0=0.0):

# calculate linear phase
# arg = sum([dx[i]*mesh[i] for i in dx.keys()])
arg_expr = '+'.join('({}*k{})'.format(repr(v), i) for i, v in dx.items())
arg_expr = '+'.join('({:}*k{})'.format(v, i) for i, v in dx.items())

if transform_state is True:
exp_ikdx_expr = 'exp(1j * ({arg} + phi0))'.format(arg=arg_expr)
Expand Down Expand Up @@ -1057,7 +1057,7 @@ def _kspace_propagate_generator(kspace, dt, moving_window_vect=None,
# m = kspace.matrix.copy()
# m[sum(k*dx for k, dx in zip(kspace.meshgrid(), moving_window_vect)) < 0.0] = 0.0
# kspace = kspace.replace_data(m)
arg_expr = '+'.join('({}*k{})'.format(repr(v), i)
arg_expr = '+'.join('({:}*k{})'.format(v, i)
for i, v
in enumerate(moving_window_vect))
numexpr_vars = dict(kspace=kspace)
Expand Down

0 comments on commit b5bbb92

Please sign in to comment.