Skip to content

Commit

Permalink
test load! for multi-file dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Feb 16, 2024
1 parent 6a1d250 commit 10f96ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99"

[compat]
CommonDataModel = "0.3.4"
CommonDataModel = "0.3.5"
DataStructures = "0.17, 0.18"
DiskArrays = "0.3.22"
Zarr = "0.9.2"
Expand Down
22 changes: 12 additions & 10 deletions test/test_multifile.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using CommonDataModel: iswritable, attribnames, parentdataset, load!, dataset, MFDataset
using CommonDataModel:
iswritable,
attribnames,
parentdataset,
load!,
dataset
using Dates
using DiskArrays
using NCDatasets
Expand All @@ -12,6 +17,7 @@ v = randn(2,3,length(fnames))
nczarr_names = ["file://" * fname * "#mode=zarr" for fname in fnames]

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

for (varname,v) in ds
# @test haskey(dsz,varname)
@test haskey(dsz,varname)

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

@test !iswritable(dsz)
@test "title" in attribnames(dsz)
#@test isnothing(parentdataset(dsz))

zvar = ZarrDataset(fname) do ds3
@test isnothing(parentdataset(dsz))

zvar = ZarrDataset(fnames,aggdim = "time") do ds3
Array(ds3["var"])
end

#=
#@test DiskArrays.haschunks(dsz["var"]) == DiskArrays.Chunked()
@test length(DiskArrays.eachchunk(dsz["var"])) ≥ 1
@test zvar == Array(ds["var"])

v = dsz["var"].var
buffer = zeros(eltype(v),size(v))
load!(v,buffer,:,:)
load!(v,buffer,:,:,:)

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

@test dataset(dsz["var"]) == dsz
close(ds)
close(dsz)
=#

0 comments on commit 10f96ce

Please sign in to comment.