Skip to content

Commit 5c0a493

Browse files
more tests
1 parent 89308ef commit 5c0a493

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ version = "0.1.0"
66
[deps]
77
CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157"
88
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
9+
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
910
Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99"
1011

1112
[compat]
12-
julia = "1"
1313
CommonDataModel = "0.3.4"
1414
DataStructures = "0.17, 0.18"
15+
DiskArrays = "0.3.22"
1516
Zarr = "0.9.2"
17+
julia = "1"
1618

1719
[extras]
1820
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/ZarrDatasets.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import CommonDataModel:
2121
parentdataset,
2222
variable
2323

24+
import DiskArrays:
25+
eachchunk,
26+
haschunks
27+
2428
import CommonDataModel as CDM
2529
using DataStructures
2630
using Zarr

src/variable.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ CDM.attrib(v::ZarrVariable,name::SymbolOrString) = v.zarray.attrs[String(name)]
1515

1616

1717
# DiskArray methods
18+
eachchunk(v::ZarrVariable) = eachchunk(v.zarray)
19+
haschunks(v::ZarrVariable) = haschunks(v.zarray)
1820
eachchunk(v::CFVariable{T,N,<:ZarrVariable}) where {T,N} = eachchunk(v.var)
1921
haschunks(v::CFVariable{T,N,<:ZarrVariable}) where {T,N} = haschunks(v.var)

test/runtests.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
using CommonDataModel: iswritable, attribnames, parentdataset, load!, dataset
12
using Dates
3+
using DiskArrays
24
using NCDatasets
35
using Test
46
using ZarrDatasets
5-
using CommonDataModel: iswritable, attribnames, parentdataset
67

78
@testset "ZarrDatasets.jl" begin
8-
#fname = "/tmp/foo.zarr"
99
fname = tempname()
1010
mkpath(fname)
1111

@@ -58,7 +58,17 @@ using CommonDataModel: iswritable, attribnames, parentdataset
5858
Array(ds3["var"])
5959
end
6060

61+
@test DiskArrays.haschunks(dsz["var"]) == DiskArrays.Chunked()
62+
@test length(DiskArrays.eachchunk(dsz["var"])) 1
6163
@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
6272
close(ds)
6373
close(dsz)
6474
end

0 commit comments

Comments
 (0)