rafaqz / DimensionalData.jl

Named dimensions and indexing for julia arrays and other data
https://rafaqz.github.io/DimensionalData.jl/stable/
MIT License
271 stars 38 forks source link

Difference between vcat and cat(a,b, dims=1) for Dimensions #518

Closed felixcremer closed 11 months ago

felixcremer commented 1 year ago

According to the docstring of Base.cat the vcat function is a special case of cat with dims=1. This is not the case for Dimensions. When I use cat(a,b, dims=1) I get a two element vector which includes a and b. When I use vcat I get the concatenated dimension which I intended to get. I am not sure, how bad the difference is, but it took me some time to spot what is happening.

I tried to construct a MWE but when I use simple Dimensions I get the following error:

julia> x1 = X(collect(1:10))
X Int64[1, 2, …, 9, 10]

julia> x2 = X(collect(11:20))
X Int64[11, 12, …, 19, 20]

julia> vcat(x1,x2)
ERROR: MethodError: no method matching _vcat_lookups(::Vector{Int64}, ::Vector{Int64})

Closest candidates are:
  _vcat_lookups(::Any, ::DimensionalData.Dimensions.LookupArrays.Regular, ::Any...)
   @ DimensionalData ~/.julia/packages/DimensionalData/4TpBG/src/array/methods.jl:303

Stacktrace:
 [1] vcat(d1::X{Vector{Int64}}, ds::X{Vector{Int64}})
   @ DimensionalData ~/.julia/packages/DimensionalData/4TpBG/src/array/methods.jl:289
 [2] top-level scope
   @ REPL[134]:1
rafaqz commented 1 year ago

This is fixed on main but its a breaking change and needs a few more fixes first.