-
-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Is your feature request related to a problem? Please describe.
I use Symbolics to generate code for some components in simulation. Sometimes, it is desired to copy those components. However it is still important to check, whether different components have the same functional behavior, i.e. are derived from the same models. This works with "normal" julia functions:
f = function(du, u)
du[1] = u[1]^2
du[2] = u[2]^2
end
f2 = deepcopy(f)
f == f2 # true
f === f2 # trueHowever, the == and === property is lost on RGFs:
using Symbolics
@variables x y
formulas = [x^2, y^2]
_, f_rgf = build_function(formulas, [x, y]; expression=Val{false})
f_rgf2 = deepcopy(f_rgf)
f_rgf == f_rgf2 # false
f_rgf === f_rgf2 # falseDescribe the solution you’d like
I think it would be possible to define deepcopy_internal as stated in the deepcopy docstring to avoid this:
using Symbolics.RuntimeGeneratedFunctions: RuntimeGeneratedFunction
Base.deepcopy_internal(f::RuntimeGeneratedFunction, stackdict::IdDict) = fThis definition aligns the behavior of RGFs with "normal" functions.
Additional context
DISCLAIMER: I don't know the inner workings of RGF. Somebody who knows would need to chime in on that. Is the current behavior actually desired and important? If so, feel free to just close this issue :)