Skip to content

Commit

Permalink
allow zero dimensional arrays in tables (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz authored Nov 19, 2022
1 parent 1764c38 commit 70f2aef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/DimensionalData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ include("Dimensions/Dimensions.jl")

using .Dimensions
using .Dimensions.LookupArrays
using .Dimensions: StandardIndices, DimOrDimType, DimTuple, DimType, AllDims
using .Dimensions: StandardIndices, DimOrDimType, DimTuple, DimTupleOrEmpty, DimType, AllDims
import .LookupArrays: metadata, set, _set, rebuild, basetypeof,
order, span, sampling, locus, val, index, bounds, hasselection, units, SelectorOrInterval
import .Dimensions: dims, refdims, name, lookup, dimstride, kwdims, hasdim, label, _astuple
Expand Down
2 changes: 1 addition & 1 deletion src/tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct DimArrayColumn{T,A<:AbstractDimArray{T},DS,DL,L} <: AbstractVector{T}
dimlengths::DL
length::L
end
function DimArrayColumn(A::AbstractDimArray{T}, alldims::DimTuple) where T
function DimArrayColumn(A::AbstractDimArray{T}, alldims::DimTupleOrEmpty) where T
# This is the apparent stride for indexing purposes,
# it is not always the real array stride
dimstrides = map(d -> dimstride(alldims, d), dims(A))
Expand Down
8 changes: 8 additions & 0 deletions test/tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,11 @@ end
@test dims(ds) == dims(da)
@test lookup(ds) == lookup(dims(da))
end

@testset "zero dimension tables" begin
a = DimArray(fill(1), (); name=:a);
b = DimArray(fill(2), (); name=:b);
ds = DimStack((a, b))
@test Tables.columntable(a) == (a = [1],)
@test Tables.columntable(ds) == (a = [1], b = [2])
end

0 comments on commit 70f2aef

Please sign in to comment.