Closed bjarthur closed 6 months ago
cat works fine if both vectors are not-empty:
cat
julia> a=rand(X([1,2,3])) 3-element DimArray{Float64,1} with dimensions: X Sampled{Int64} Int64[1, 2, 3] ForwardOrdered Irregular Points 1 0.3884 2 0.454392 3 0.768688 julia> b=rand(X([4,5])) 2-element DimArray{Float64,1} with dimensions: X Sampled{Int64} Int64[4, 5] ForwardOrdered Irregular Points 4 0.828142 5 0.50528 julia> cat(a,b,dims=X) 5-element DimArray{Float64,1} with dimensions: X Sampled{Int64} Int64[1, 2, 3, 4, 5] ForwardOrdered Irregular Points 1 0.3884 2 0.454392 3 0.768688 4 0.828142 5 0.50528
but throws an error if one is empty:
julia> c=rand(X(Int64[])) 0-element DimArray{Float64,1} with dimensions: X Sampled{Int64} Int64[] Unordered Irregular Points julia> cat(c,b,dims=X) ERROR: BoundsError: attempt to access 0-element Vector{Int64} at index [0] Stacktrace: [1] getindex @ Base ./essentials.jl:13 [inlined] [2] last @ Base ./abstractarray.jl:524 [inlined] [3] last @ DimensionalData.Dimensions.LookupArrays ~/.julia/packages/DimensionalData/R7veM/src/LookupArrays/lookup_arrays.jl:30 [inlined] [4] _check_cat_lookup_order @ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/array/methods.jl:391 [inlined] [5] _check_cat_lookups(D::Type, l1::DimensionalData.Dimensions.LookupArrays.Sampled{…}, lookups::DimensionalData.Dimensions.LookupArrays.Sampled{…}) @ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/array/methods.jl:353 [6] check_cat_lookups(::X{…}, ::Vararg{…}) @ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/array/methods.jl:346 [7] (::DimensionalData.var"#127#134"{Tuple{…}, DimArray{…}, Tuple{…}})(catdim::Type) @ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/array/methods.jl:251 [8] map @ ./tuple.jl:291 [inlined] [9] _cat(catdims::Tuple{…}, A1::DimArray{…}, As::DimArray{…}) @ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/array/methods.jl:227 [10] _cat(catdim::Type{…}, A1::DimArray{…}, As::DimArray{…}) @ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/array/methods.jl:223 [11] cat(A1::DimArray{…}, As::DimArray{…}; dims::Type) @ DimensionalData ~/.julia/packages/DimensionalData/R7veM/src/array/methods.jl:220 [12] top-level scope @ REPL[76]:1 Some type information was truncated. Use `show(err)` to see complete types.
works fine for regular (ie non-DimArray) arrays:
julia> cat([],[3,4],dims=1) 2-element Vector{Any}: 3 4
cat
works fine if both vectors are not-empty:but throws an error if one is empty:
works fine for regular (ie non-DimArray) arrays: