diff --git a/src/DatasetAPI/Datasets.jl b/src/DatasetAPI/Datasets.jl index a46b21b01..8ad7112ef 100644 --- a/src/DatasetAPI/Datasets.jl +++ b/src/DatasetAPI/Datasets.jl @@ -318,6 +318,7 @@ function testrange(x) end function testrange(x::AbstractArray{<:Integer}) + length(x) == 1 && return x steps = diff(x) if all(isequal(steps[1]), steps) && !iszero(steps[1]) return range(first(x), step = steps[1], length = length(x)) diff --git a/test/Datasets/datasets.jl b/test/Datasets/datasets.jl index c8986e290..b2f3d1ec9 100644 --- a/test/Datasets/datasets.jl +++ b/test/Datasets/datasets.jl @@ -419,6 +419,15 @@ end @test :b in keys(ds3.cubes) @test !in(:c,keys(ds3.cubes)) + # arrays with a dimension of length 1 + a4 = YAXArray(ones(5, 1)) + ds4 = Dataset(layer=a4) + path = tempname() * ".zarr" + savedataset(ds4; path=path) + ds5 = open_dataset(path) + @test length(ds4.Dim_2) == length(ds5.Dim_2) == 1 + @test ds4.Dim_2 == ds5.Dim_2 + rm(path, recursive=true, force=true) end @testset "Saving, OutDims" begin