Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Aug 31, 2023
1 parent 1a7d8ef commit 2af083a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function uniquekeys(das::Tuple{AbstractDimArray,Vararg{AbstractDimArray}})
uniquekeys(map(Symbol name, das))
end
function uniquekeys(das::Vector{<:AbstractDimArray})
map(uniquekeys Symbol name, das)
length(das) == 0 ? Symbol[] : uniquekeys(map(Symbol name, das))
end
function uniquekeys(keys::Vector{Symbol})
map(enumerate(keys)) do (id, k)
Expand Down
1 change: 0 additions & 1 deletion test/stack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ mixed = DimStack(da1, da2, da4)
DimStack((one=da1, two=da2, three=da3)) == s
@test length(DimStack(NamedTuple())) == length(DimStack()) == 0
@test dims(DimStack()) == dims(DimStack(NamedTuple())) == ()
DimStack(, ())
end

@testset "ConstructionBase" begin
Expand Down
13 changes: 13 additions & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DimensionalData, Test, Dates
using DimensionalData.LookupArrays, DimensionalData.Dimensions
using .LookupArrays: shiftlocus, maybeshiftlocus
using DimensionalData: uniquekeys

@testset "reverse" begin
@testset "dimension" begin
Expand Down Expand Up @@ -215,3 +216,15 @@ end
1.0 2.0 3.0]
end
end

@testset "uniquekeys" begin
da1 = rand(X(2), Y(2); name=:name1)
da2 = rand(X(2), Y(2); name=:name1)
da3 = rand(X(2), Y(2); name=:name2)
@test uniquekeys([da1, da2, da3]) == [:layer1, :layer2, :name2] # Should we keep thoe original name?
@test uniquekeys((da1, da2, da3)) == (:layer1, :layer2, :name2) # Should we keep thoe original name?
@test uniquekeys([:name1, :name1, :name2]) == [:layer1, :layer2, :name2] # Should we keep thoe original name?
@test uniquekeys((:name1, :name1, :name2)) == (:layer1, :layer2, :name2)
@test uniquekeys(Symbol[]) == Symbol[]
@test uniquekeys(()) == ()
end

0 comments on commit 2af083a

Please sign in to comment.