Skip to content

Commit dca9606

Browse files
multi-file
1 parent efe7c05 commit dca9606

File tree

3 files changed

+5
-71
lines changed

3 files changed

+5
-71
lines changed

src/ZarrDatasets.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Base:
88

99
import CommonDataModel:
1010
CFVariable,
11+
MFDataset,
1112
SymbolOrString,
1213
attrib,
1314
attribnames,

src/dataset.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ function ZarrDataset(url::AbstractString,mode = "r";
117117
end
118118

119119

120-
ZarrDataset(keys::AbstractArray{<:AbstractString,N}, args...; kwargs...) where N =
121-
ZarrDataset(ZarrDataset,fnames, args...; kwargs...)
120+
ZarrDataset(fnames::AbstractArray{<:AbstractString,N}, args...; kwargs...) where N =
121+
MFDataset(ZarrDataset,fnames, args...; kwargs...)
122122

123123

124124
function ZarrDataset(f::Function,args...; kwargs...)

test/runtests.jl

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,7 @@
1-
using CommonDataModel: iswritable, attribnames, parentdataset, load!, dataset
2-
using Dates
3-
using DiskArrays
4-
using NCDatasets
51
using Test
62
using ZarrDatasets
73

84
@testset "ZarrDatasets.jl" begin
9-
fname = tempname()
10-
mkpath(fname)
11-
12-
nczarr_name = "file://" * fname * "#mode=zarr"
13-
@debug "filenames " nczarr_name fname
14-
v = randn(2,3)
15-
ds = NCDataset(nczarr_name,"c")
16-
defVar(ds,"var",v,("lon","lat"),attrib = Dict(
17-
"foo" => "bar",
18-
"int_attribute" => 1,
19-
"float_attribute" => 1.,
20-
"scale_factor" => 1.23))
21-
ds.attrib["title"] = "test file"
22-
close(ds)
23-
24-
ds = NCDataset(nczarr_name)
25-
dsz = ZarrDataset(fname)
26-
27-
@test Set(dimnames(dsz)) == Set(dimnames(ds))
28-
29-
for (name,len) in ds.dim
30-
@test dsz.dim[name] == len
31-
end
32-
33-
for (varname,v) in ds
34-
@test haskey(dsz,varname)
35-
36-
v2 = dsz[varname]
37-
@test Array(v2) == Array(v)
38-
39-
for (attribname,attribval) in v.attrib
40-
@test v2.attrib[attribname] == attribval
41-
end
42-
end
43-
44-
for (attribname,attribval) in ds.attrib
45-
@test dsz.attrib[attribname] == attribval
46-
end
47-
48-
io = IOBuffer()
49-
show(io,dsz)
50-
str = String(take!(io))
51-
@test occursin("title",str)
52-
53-
@test !iswritable(dsz)
54-
@test "title" in attribnames(dsz)
55-
@test isnothing(parentdataset(dsz))
56-
57-
zvar = ZarrDataset(fname) do ds3
58-
Array(ds3["var"])
59-
end
60-
61-
@test DiskArrays.haschunks(dsz["var"]) == DiskArrays.Chunked()
62-
@test length(DiskArrays.eachchunk(dsz["var"])) 1
63-
@test zvar == Array(ds["var"])
64-
65-
v = dsz["var"].var
66-
buffer = zeros(eltype(v),size(v))
67-
load!(v,buffer,:,:)
68-
69-
@test buffer == Array(ds["var"].var)
70-
71-
@test dataset(dsz["var"]) == dsz
72-
close(ds)
73-
close(dsz)
5+
include("test_cdm.jl")
6+
include("test_multifile.jl")
747
end

0 commit comments

Comments
 (0)