TypedTables.jl
TypedTables.jl copied to clipboard
Explicit error for unequal column sizes
Low priority, QOL issue. The constructors could throw an error if the column sizes don't match. Currently they are quietly accepted until the table is shown/acessed, and then:
julia> t = Table(a = [1, 2, 3], b = [2.0, 4.0])
Table with 2 columns and 3 rowsError showing value of type Table{NamedTuple{(:a, :b), Tuple{Int64, Float64}}, 1, NamedTuple{(:a, :b), Tuple{Vector{Int64}, Vector{Float64}}}}:
ERROR: BoundsError: attempt to access 3-element Table{NamedTuple{(:a, :b), Tuple{Int64, Float64}}, 1, NamedTuple{(:a, :b), Tuple{Vector{Int64}, Vector{Float64}}}} at index [3]
Stacktrace:
[1] throw_boundserror(A::Table{NamedTuple{(:a, :b), Tuple{Int64, Float64}}, 1, NamedTuple{(:a, :b), Tuple{Vector{Int64}, Vector{Float64}}}}, I::Tuple{Int64})
@ Base ./abstractarray.jl:691
[2] checkbounds
@ ./abstractarray.jl:656 [inlined]
[3] getindex(t::Table{NamedTuple{(:a, :b), Tuple{Int64, Float64}}, 1, NamedTuple{(:a, :b), Tuple{Vector{Int64}, Vector{Float64}}}}, i::Int64)
@ TypedTables ~/vcs/TypedTables.jl/src/Table.jl:128
[4] showtable(io::IOContext{Base.TTY}, t::Any, keyname::Nothing)
@ TypedTables ~/vcs/TypedTables.jl/src/show.jl:141
[5] showtable
@ ~/vcs/TypedTables.jl/src/show.jl:102 [inlined]
[...]
Yes, I think we should look at this. The dictionary-based tables have some checks now I believe.