Skip to content

Commit

Permalink
clean-up test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Apr 29, 2024
1 parent 5271611 commit fbd3258
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions test/test_variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ data2 = zeros(Int,10)
close(ds)

# issue 250

fname = tempname()
ds = NCDataset(fname,"c")
defDim(ds,"lon",100)
Expand All @@ -299,20 +298,15 @@ v = defVar(ds,"temperature",Float32,("lon","lat"))
data = [Float32(i+j) for i = 1:100, j = 1:110];
v[:,:] = data;
close(ds)

# reading
ds = NCDataset(fname)

# works:
ds["temperature"][CartesianIndices((1:10,10:30))]
ds["temperature"][CartesianIndex(1,1)]
@test ds["temperature"][CartesianIndices((1:10,10:30))] == data[CartesianIndices((1:10,10:30))]
@test ds["temperature"][CartesianIndex(1,1)] == data[CartesianIndex(1,1)]

# read in-place
v = zeros(Float32, 10, 21);
NCDatasets.load!(variable(ds, "temperature"), v, CartesianIndices((1:10,10:30)))
@test v[:,:] == data[CartesianIndices((1:10,10:30))]


vv = [1.0f0]
NCDatasets.load!(variable(ds, "temperature"), vv, CartesianIndex(5,5))
@test vv[1] == data[CartesianIndex(5,5)]
close(ds)

0 comments on commit fbd3258

Please sign in to comment.