Skip to content

Commit

Permalink
refactor: make repack call replace
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Oct 22, 2024
1 parent f658073 commit 2811b1d
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/systems/parameter_buffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,7 @@ function SciMLStructures.canonicalize(::SciMLStructures.Tunable, p::MTKParameter
arr = p.tunable
repack = let p = p
function (new_val)
if new_val !== p.tunable
copyto!(p.tunable, new_val)
end
return p
return SciMLStructures.replace(SciMLStructures.Tunable(), p, new_val)
end
end
return arr, repack, true
Expand All @@ -303,12 +300,9 @@ for (Portion, field, recurse) in [(SciMLStructures.Discrete, :discrete, 1)
(Nonnumeric, :nonnumeric, 1)]
@eval function SciMLStructures.canonicalize(::$Portion, p::MTKParameters)
as_vector = buffer_to_arraypartition(p.$field)
repack = let as_vector = as_vector, p = p
repack = let p = p
function (new_val)
if new_val !== as_vector
update_tuple_of_buffers(new_val, p.$field)
end
p
return SciMLStructures.replace(($Portion)(), p, new_val)
end
end
return as_vector, repack, true
Expand Down

0 comments on commit 2811b1d

Please sign in to comment.