Skip to content

Commit fed81dc

Browse files
fix symbol handling
1 parent 2ed2e42 commit fed81dc

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/LabelledArrays.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ function ArrayInterfaceCore.ismutable(::Type{<:LArray{T, N, D, Syms}}) where {T,
6464
end
6565
ArrayInterfaceCore.can_setindex(::Type{<:SLArray}) = false
6666

67+
lenfun(x) = length(x)
68+
lenfun(::Symbol) = 1
6769
function ArrayInterfaceCore.undefmatrix(x::LArray{T, N, D, Syms}) where {T, N, D, Syms}
68-
n = sum(length, Syms)
70+
n = sum(lenfun, Syms)
6971
similar(x.__x, n, n)
7072
end
7173

src/larray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct LArray{T, N, D <: AbstractArray{T, N}, Syms} <: DenseArray{T, N}
55
end
66

77
function LArray{T, N, D, Syms}(::UndefInitializer, n::Int64) where {T, N, D, Syms}
8-
@assert sum(length, Syms) == n
8+
@assert sum(lenfun, Syms) == n
99
LArray{T, N, D, Syms}(similar(D, n))
1010
end
1111

test/larrays.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ using LabelledArrays, Test, InteractiveUtils
1616
syms = (:a, :b, :c)
1717
@test typeof(typeof(x)(undef, 3)) == typeof(x)
1818

19-
x = LabelledArrays.LArray{Float64, 1, Vector{Float64}, (x = 1:4, y = 5:8)}(undef, 8)
20-
@test length(x) == 8
21-
@test size(LabelledArrays.ArrayInterfaceCore.undefmatrix(x)) == (8, 8)
19+
z = LabelledArrays.LArray{Float64, 1, Vector{Float64}, (x = 1:4, y = 5:8)}(undef, 8)
20+
@test length(z) == 8
21+
@test size(LabelledArrays.ArrayInterfaceCore.undefmatrix(z)) == (8, 8)
2222

2323
for (i, s) in enumerate(syms)
2424
@show i, s

0 commit comments

Comments
 (0)