While wrapping QuantityArrays with KeyedArray from AxisKeys.jl, I met an edge case of dimension with empty arrays.
] activate --temp
] add AxisKeys
] add DynamicQuantities
A = KeyedArray(QuantityArray(Matrix{Float64}(undef,0,6),us"s"); time = Float64[], channel = ["$i" for i in 1:6])
dimension(A)
This throws
julia> dimension(A)
ERROR: BoundsError: attempt to access 0×6 NamedDimsArray(QuantityArray(::Matrix{Float64}, ::Quantity{Float64, SymbolicDimensions{FRInt32}}), (:time, :channel)) at index [1]
Stacktrace:
[1] throw_boundserror(A::NamedDimsArray{(:time, :channel), Quantity{…}, 2, QuantityArray{…}}, I::Tuple{Int64})
@ Base .\essentials.jl:15
[2] checkbounds
@ .\abstractarray.jl:699 [inlined]
[3] getindex
@ D:\bamboo\.julia\packages\AxisKeys\a6h2b\src\struct.jl:76 [inlined]
[4] first
@ .\abstractarray.jl:452 [inlined]
[5] dimension(aq::KeyedArray{Quantity{…}, 2, NamedDimsArray{…}, Tuple{…}})
@ DynamicQuantities D:\bamboo\.julia\packages\DynamicQuantities\wqpWc\src\utils.jl:442
[6] top-level scope
@ REPL[26]:1
Some type information was truncated. Use `show(err)` to see complete types.
at
|
dimension(aq::AbstractArray{<:UnionAbstractQuantity}) = allequal(dimension.(aq)) ? dimension(first(aq)) : throw(DimensionError(aq[begin], aq[begin+1:end])) |
I am not sure how this should be circumvented. If the array is empty, it is obvious that all elements should be of the same type. It may require an additional dispatch.
While wrapping
QuantityArrays withKeyedArrayfromAxisKeys.jl, I met an edge case ofdimensionwith empty arrays.This throws
at
DynamicQuantities.jl/src/utils.jl
Line 442 in f619e16
I am not sure how this should be circumvented. If the array is empty, it is obvious that all elements should be of the same type. It may require an additional dispatch.