Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cscherrer committed Apr 25, 2021
1 parent a93451b commit 7869ebf
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/chainvec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,30 @@ to information stored in a single sample.
"""
function chainvec end


function chainvec(nt::NamedTuple, n=1)
tv = TupleVector(undef, nt, n)
@inbounds tv[1] = nt
return tv
function chainvec(nt::NamedTuple, n = 1)
tv = TupleVector(undef, nt, n)
@inbounds tv[1] = nt
return tv
end

function chainvec(x::T, n=1) where {T<:Real}
ev = ElasticVector{T}(undef, n)
@inbounds ev[1] = x
return ev
function chainvec(x::T, n = 1) where {T<:Real}
ev = ElasticVector{T}(undef, n)
@inbounds ev[1] = x
return ev
end

function chainvec(x::T, n=1) where {T}
if isstructtype(T)
v = StructArrays.replace_storage(ElasticVector, StructVector{T}(undef, n))
@inbounds v[1] = x
return v
end
ev = ElasticVector{T}(undef, n)
@inbounds ev[1] = x
return ev
function chainvec(x::T, n = 1) where {T}
if isstructtype(T)
v = StructArrays.replace_storage(ElasticVector, StructVector{T}(undef, n))
@inbounds v[1] = x
return v
end
@inbounds ev[1] = x
return ev
end

function chainvec(x::DenseArray{T,N}, n=1) where {T,N}
nv = nestedview(ElasticArray{T,N+1}(undef, size(x)..., n), N)
@inbounds nv[1] = x
return nv
end
function chainvec(x::DenseArray{T,N}, n = 1) where {T,N}
nv = nestedview(ElasticArray{T,N + 1}(undef, size(x)..., n), N)
@inbounds nv[1] = x
return nv
end

0 comments on commit 7869ebf

Please sign in to comment.