From b661bfb5e8688391022e6d5031c9eb166e1967de Mon Sep 17 00:00:00 2001 From: fverdugo Date: Mon, 22 Jul 2019 15:13:29 +0200 Subject: [PATCH] Added conversion from tuple --- src/Types.jl | 4 ++++ test/TypesTests.jl | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/Types.jl b/src/Types.jl index 7931361..1c59edf 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -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 diff --git a/test/TypesTests.jl b/test/TypesTests.jl index 05e2f84..a5d8ead 100644 --- a/test/TypesTests.jl +++ b/test/TypesTests.jl @@ -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}