IndexedTables.jl icon indicating copy to clipboard operation
IndexedTables.jl copied to clipboard

Column constructor with a single Array doesn't reduce to an Array but remains a tuple

Open sylvaticus opened this issue 8 years ago • 0 comments

While looking for a consistent way to programmatically build an IndexedTable I run into the problem that if the Columns() is built with a single Array, the IndexedArray has inconsistent behaviour:

using IndexedTables
tok = IndexedTables.Table(
    Columns(
        String["price","price","price","price","waterContent","waterContent"],
        String["banana","banana","apple","apple","banana", "apple"],
        Union{String,DataArrays.NAtype}["FR","UK","FR","UK",NA,NA]
    ),
    Float64[2.8,2.7,1.1,0.8,0.2,0.7]
)
tbad = IndexedTables.Table(
    Columns(
        String["price","price","price","price","waterContent","waterContent"],
        String["banana","banana","apple","apple","banana", "apple"],
        Union{String,DataArrays.NAtype}["FR","UK","FR","UK",NA,NA]
    ),
    Columns(
       Float64[2.8,2.7,1.1,0.8,0.2,0.7]
    )
)
tok["price","orange","FR"]   = 3.2
tbad["price","orange","FR" ] = 3.2
MethodError: no method matching push!(::IndexedTables.Columns{Tuple{Float64},Tuple{Array{Float64,1}}}, ::Float64)

tbad["price","orange","FR" ] = 3.2, works but, as IndexedTuples explicitly consider the specific case of a single data column, doesn't seem the expected behaviour.

sylvaticus avatar Oct 23 '17 09:10 sylvaticus