Skip to content

Commit

Permalink
reorganise
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 7, 2024
1 parent a5ca986 commit 95c7918
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/outputs/transformed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@ function TransformedOutput(f::Function, init::Union{NamedTuple,AbstractMatrix};
extent = extent isa Nothing ? Extent(; init=init, tspan, kw...) : extent
# Define buffers to copy to before applying `f`
buffer = _replicate_init(init, replicates(extent))
f1 = deepcopy(f(buffer))
f1 = f(buffer)
if buffer isa NamedTuple
map(buffer) do b
b .= (zero(first(b)),)
end
else
buffer .= (zero(first(buffer)),)
end
zeroframe = f(buffer)
# Build simulation frames from the output of `f` for empty frames
frames = if isnothing(eltype)
[deepcopy(zeroframe) for _ in eachindex(tspan)]
[deepcopy(f1) for _ in eachindex(tspan)]
else
eltype[deepcopy(zeroframe) for _ in eachindex(tspan)]
eltype[deepcopy(f1) for _ in eachindex(tspan)]
end
# Set the first frame to the output of `f` for `init`
frames[1] = f1
Expand Down

0 comments on commit 95c7918

Please sign in to comment.