Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't cat an empty vector #595

Closed
bjarthur opened this issue Jan 26, 2024 · 0 comments · Fixed by #597
Closed

can't cat an empty vector #595

bjarthur opened this issue Jan 26, 2024 · 0 comments · Fixed by #597

Comments

@bjarthur
Copy link
Contributor

cat works fine if both vectors are not-empty:

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant