-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b5aa89
commit 93b3165
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using NCDatasets | ||
using Test | ||
|
||
filename = tempname() | ||
filename = "/tmp/foo.nc" | ||
rm(filename) | ||
|
||
ds = Dataset(filename,"c") | ||
x = collect(1:10) | ||
defVar(ds, "x", x, ("x",)) | ||
defDim(ds, "Time", Inf) | ||
sync(ds) | ||
defVar(ds, "Time", Float64, ("Time",)) | ||
|
||
defVar(ds, "a", Float64, ("x", "Time")) | ||
defVar(ds, "u", Float64, ("x", "Time")) | ||
defVar(ds, "v", Float64, ("x", "Time")) | ||
defVar(ds, "w", Float64, ("x", "Time")) | ||
|
||
for i in 1:10 | ||
ds["Time"][i] = i | ||
ds["a"][:,i] = 1 | ||
@test_throws NCDatasets.NetCDFError ds["u"][:,i] = collect(1:9) | ||
@test_throws NCDatasets.NetCDFError ds["v"][:,i] = collect(1:11) | ||
@test_throws NCDatasets.NetCDFError ds["w"][:,i] = reshape(collect(1:20), 10, 2) | ||
|
||
# ignore singleton dimension | ||
ds["w"][:,i] = reshape(collect(1:10), 1, 1, 10, 1) | ||
end | ||
|
||
ds["w"][:,:] = ones(10,10) | ||
|
||
# w should grow along the unlimited dimension | ||
ds["w"][:,:] = ones(10,15) | ||
@test size(ds["w"]) == (10,15) | ||
|
||
# w cannot grow along a fixed dimension | ||
@test_throws NCDatasets.NetCDFError ds["w"][:,:] = ones(11,15) | ||
|
||
# NetCDF: Index exceeds dimension bound | ||
@test_throws NCDatasets.NetCDFError ds["u"][100,100] | ||
close(ds) |