Skip to content

Commit

Permalink
Added conversion from tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Jul 22, 2019
1 parent 8b0c423 commit b661bfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ function convert(
MultiValue(b)
end

function convert(::Type{<:MultiValue{S,T,N,L}},a::NTuple{L,T}) where {S,T,N,L}
MultiValue(SArray{S,T}(a))
end

# Misc operations on the type itself

length(::Type{<: MultiValue{S,T,N,L} where {S,T,N}} ) where L = L
Expand Down
7 changes: 7 additions & 0 deletions test/TypesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ a = ones(Int,1)
b = convert(VectorValue{1,Int},a)
@test isa(b,VectorValue{1,Int})

a = (1,2,2,1,3,2)
V = MultiValue{Tuple{3,2},Int,2,6}
b = convert(V,a)
@test isa(b,V)
b = V[a,a,a,]
@test isa(b,Vector{V})

# Misc operations on the type itself

V = VectorValue{3,Int}
Expand Down

0 comments on commit b661bfb

Please sign in to comment.