Skip to content

Commit

Permalink
Added size on MultiValue type
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed May 19, 2019
1 parent 0febd15 commit c8844a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ end

length(::Type{MultiValue{S,T,N,L}}) where {S,T,N,L} = L

function size(::Type{MultiValue{S,T,N,L}}) where {S,T,N,L}
A = SArray{S,T,N,L}
size(A)
end

# Custom type printing

function show(io::IO,v::MultiValue)
Expand Down
6 changes: 6 additions & 0 deletions test/TypesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ a = ones(Int,3)
b = convert(VectorValue{3,Int},a)
@test isa(b,VectorValue{3,Int})

# Misc operations on the type itself

V = VectorValue{3,Int}
@test length(V) == 3
@test size(V) == (3,)

# Custom type printing

s = "TensorValues.MultiValue{Tuple{3,2},Float64,2,6}(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)"
Expand Down

0 comments on commit c8844a7

Please sign in to comment.