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 Aug 19, 2024
1 parent 1fd513e commit c457d32
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 @@ -264,10 +264,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 @@ -288,12 +285,9 @@ for (Portion, field, recurse) in [(SciMLStructures.Discrete, :discrete, 2)
(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 c457d32

Please sign in to comment.