Skip to content

Commit 1cae58d

Browse files
docs: fix DiffCache aliasing odeprob.p.tunable in remake doc example
1 parent 10c9b06 commit 1cae58d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/src/examples/remake.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ using SymbolicIndexingInterface
9898
optfn = OptimizationFunction(loss, Optimization.AutoForwardDiff())
9999
# function to set the parameters we are optimizing
100100
setter = setp(odeprob, [α, β, γ, δ])
101-
# `DiffCache` to avoid allocations
102-
diffcache = DiffCache(canonicalize(Tunable(), parameter_values(odeprob))[1])
101+
# `DiffCache` to avoid allocations.
102+
# `copy` prevents the buffer stored by `DiffCache` from aliasing the one in
103+
# `parameter_values(odeprob)`.
104+
diffcache = DiffCache(copy(canonicalize(Tunable(), parameter_values(odeprob))[1]))
103105
# parameter object is a tuple, to store differently typed objects together
104106
optprob = OptimizationProblem(
105107
optfn, rand(4), (odeprob, timesteps, data, setter, diffcache),

0 commit comments

Comments
 (0)