@@ -673,7 +673,7 @@ function generate_single_rootfinding_callback(
673
673
rf_oop (u, parameter_values (integ), t)
674
674
end
675
675
end
676
- user_initfun = (affect_function. initialize == NULL_AFFECT ) ? SciMLBase. INITIALIZE_DEFAULT :
676
+ user_initfun = isnothing (affect_function. initialize) ? SciMLBase. INITIALIZE_DEFAULT :
677
677
(c, u, t, i) -> affect_function. initialize (i)
678
678
if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing &&
679
679
(save_idxs = get (ic. callback_to_clocks, cb, nothing )) != = nothing
@@ -691,7 +691,7 @@ function generate_single_rootfinding_callback(
691
691
return ContinuousCallback (
692
692
cond, affect_function. affect, affect_function. affect_neg, rootfind = cb. rootfind,
693
693
initialize = initfn,
694
- finalize = (affect_function. finalize == NULL_AFFECT ) ? SciMLBase. FINALIZE_DEFAULT : (c, u, t, i) -> affect_function. finalize (i),
694
+ finalize = isnothing (affect_function. finalize) ? SciMLBase. FINALIZE_DEFAULT : (c, u, t, i) -> affect_function. finalize (i),
695
695
initializealg = reinitialization_alg (cb))
696
696
end
697
697
@@ -763,9 +763,35 @@ function generate_vector_rootfinding_callback(
763
763
end
764
764
end
765
765
end
766
-
767
- initialize = handle_optional_setup_fn (
768
- map (fn -> fn. initialize, affect_functions), SciMLBase. INITIALIZE_DEFAULT)
766
+ initialize = nothing
767
+ if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing
768
+ initialize = handle_optional_setup_fn (map ((cb, fn) -> begin
769
+ if (save_idxs = get (ic. callback_to_clocks, cb, nothing )) != = nothing
770
+ let save_idxs = save_idxs
771
+ if ! isnothing (fn. initialize)
772
+ (i) -> begin
773
+ for idx in save_idxs
774
+ SciMLBase. save_discretes! (i, idx)
775
+ end
776
+ fn. initialize (i)
777
+ end
778
+ else
779
+ (i) -> begin
780
+ for idx in save_idxs
781
+ SciMLBase. save_discretes! (i, idx)
782
+ end
783
+ end
784
+ end
785
+ end
786
+ else
787
+ fn. initialize
788
+ end
789
+ end , cbs, affect_functions), SciMLBase. INITIALIZE_DEFAULT)
790
+
791
+ else
792
+ initialize = handle_optional_setup_fn (map (fn -> fn. initialize, affect_functions), SciMLBase. INITIALIZE_DEFAULT)
793
+ end
794
+
769
795
finalize = handle_optional_setup_fn (
770
796
map (fn -> fn. finalize, affect_functions), SciMLBase. FINALIZE_DEFAULT)
771
797
return VectorContinuousCallback (
0 commit comments