@@ -189,18 +189,13 @@ function compile_user_affect(affect::ImperativeAffect, cb, sys, dvs, ps; kwargs.
189189 else
190190 zeros (sz)
191191 end
192- obs_fun = build_explicit_observed_function (
193- sys, Symbolics. scalarize .(obs_exprs);
194- mkarray = (es, _) -> MakeTuple (es))
195- obs_sym_tuple = (obs_syms... ,)
192+ geto_funs = NamedTuple {(obs_syms...,)} ((getsym .((sys,), obs_exprs)... ,))
196193
197194 # okay so now to generate the stuff to assign it back into the system
195+ getm_funs = NamedTuple {(mod_syms...,)} ((getsym .((sys,), mod_exprs)... ,))
196+
198197 mod_pairs = mod_exprs .=> mod_syms
199198 mod_names = (mod_syms... ,)
200- mod_og_val_fun = build_explicit_observed_function (
201- sys, Symbolics. scalarize .(first .(mod_pairs));
202- mkarray = (es, _) -> MakeTuple (es))
203-
204199 upd_funs = NamedTuple {mod_names} ((setu .((sys,), first .(mod_pairs))... ,))
205200
206201 if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing
@@ -212,12 +207,10 @@ function compile_user_affect(affect::ImperativeAffect, cb, sys, dvs, ps; kwargs.
212207 let user_affect = func (affect), ctx = context (affect)
213208 function (integ)
214209 # update the to-be-mutated values; this ensures that if you do a no-op then nothing happens
215- modvals = mod_og_val_fun (integ. u, integ. p, integ. t)
216- upd_component_array = NamedTuple {mod_names} (modvals)
210+ upd_component_array = _generated_readback (integ, getm_funs)
217211
218212 # update the observed values
219- obs_component_array = NamedTuple {obs_sym_tuple} (obs_fun (
220- integ. u, integ. p, integ. t))
213+ obs_component_array = _generated_readback (integ, geto_funs)
221214
222215 # let the user do their thing
223216 upd_vals = user_affect (upd_component_array, obs_component_array, ctx, integ)
0 commit comments