Skip to content

Commit 10f96ce

Browse files
test load! for multi-file dataset
1 parent 6a1d250 commit 10f96ce

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
1010
Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99"
1111

1212
[compat]
13-
CommonDataModel = "0.3.4"
13+
CommonDataModel = "0.3.5"
1414
DataStructures = "0.17, 0.18"
1515
DiskArrays = "0.3.22"
1616
Zarr = "0.9.2"

test/test_multifile.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using CommonDataModel: iswritable, attribnames, parentdataset, load!, dataset, MFDataset
1+
using CommonDataModel:
2+
iswritable,
3+
attribnames,
4+
parentdataset,
5+
load!,
6+
dataset
27
using Dates
38
using DiskArrays
49
using NCDatasets
@@ -12,6 +17,7 @@ v = randn(2,3,length(fnames))
1217
nczarr_names = ["file://" * fname * "#mode=zarr" for fname in fnames]
1318

1419
for i = 1:length(fnames)
20+
local ds
1521
mkpath(fnames[i])
1622
ds = NCDataset(nczarr_names[i],"c")
1723
defVar(ds,"var",v[:,:,i:i],("lon","lat","time"),attrib = Dict(
@@ -33,7 +39,7 @@ for (name,len) in ds.dim
3339
end
3440

3541
for (varname,v) in ds
36-
# @test haskey(dsz,varname)
42+
@test haskey(dsz,varname)
3743

3844
v2 = dsz[varname]
3945
@test Array(v2) == Array(v)
@@ -54,25 +60,21 @@ str = String(take!(io))
5460

5561
@test !iswritable(dsz)
5662
@test "title" in attribnames(dsz)
57-
#@test isnothing(parentdataset(dsz))
5863

59-
zvar = ZarrDataset(fname) do ds3
64+
@test isnothing(parentdataset(dsz))
65+
66+
zvar = ZarrDataset(fnames,aggdim = "time") do ds3
6067
Array(ds3["var"])
6168
end
6269

63-
#=
64-
65-
#@test DiskArrays.haschunks(dsz["var"]) == DiskArrays.Chunked()
66-
@test length(DiskArrays.eachchunk(dsz["var"])) ≥ 1
6770
@test zvar == Array(ds["var"])
6871

6972
v = dsz["var"].var
7073
buffer = zeros(eltype(v),size(v))
71-
load!(v,buffer,:,:)
74+
load!(v,buffer,:,:,:)
7275

7376
@test buffer == Array(ds["var"].var)
7477

7578
@test dataset(dsz["var"]) == dsz
7679
close(ds)
7780
close(dsz)
78-
=#

0 commit comments

Comments
 (0)