Skip to content

Commit

Permalink
add tests for open_mfdataset
Browse files Browse the repository at this point in the history
  • Loading branch information
meggart committed Nov 28, 2024
1 parent e13e918 commit ddd98d6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "YAXArrays"
uuid = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c"
authors = ["Fabian Gans <fgans@bgc-jena.mpg.de>"]
version = "0.5.14"
version = "0.5.15"

[deps]
CFTime = "179af706-886a-5703-950a-314cd64e0468"
Expand Down
33 changes: 33 additions & 0 deletions test/Datasets/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,36 @@ end
ds = Dataset(a=a1, b=a2, c=a3, d=a4, e=a5)
@test_throws ArgumentError Cube(ds)
end

@testset "Open_mfdataset" begin
import NetCDF
d1 = DD.X(1:20)
d2 = DD.Y(1:10)
a1 = rand(20,10)
a2 = rand(20,10)
td = mktempdir()
f1, f2 = joinpath.(td,("file_1.nc","file_2.nc"))

array1 = YAXArray((d1,d2),a1)
array2 = YAXArray((d1,d2),a2)

savecube(array1,f1)
savecube(array2,f2)

ds = open_mfdataset(DD.DimArray([f1,f2],(DD.Ti(1:2),)))

@test ds.layer.data[:,:,1] == array1
@test ds.layer.data[:,:,2] == array2

td = mktempdir()
f1, f2 = joinpath.(td,("file_1.nc","file_2.nc"))
td1, td2 = DD.Ti(1:2), DD.Ti(3:4)
a1,a2 = rand(20,10,2), rand(20,10,2)
array1,array2 = YAXArray((d1,d2,td1),a1), YAXArray((d1,d2,td2),a2)
savecube(array1,f1)
savecube(array2,f2)

ds = open_mfdataset(joinpath(td,"*.nc"))
@test ds.layer.data[:,:,1:2] == array1
@test ds.layer.data[:,:,3:4] == array2
end

0 comments on commit ddd98d6

Please sign in to comment.