Skip to content

Commit 0871439

Browse files
test scaling
1 parent 970eb26 commit 0871439

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ using Test
44
@testset "CommonDataModel" begin
55
include("test_conversion.jl")
66
include("test_empty.jl")
7+
include("test_scaling.jl")
78
end
89

test/test_empty.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import CommonDataModel as CDM
33
struct DummyEmptyDataset <: CDM.AbstractDataset
44
end
55

6+
67
dd = DummyEmptyDataset();
78
@test CDM.dimnames(dd) == ()
89
@test_throws Exception CDM.dim(dd,"does_not_exist")

test/test_scaling.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using NCDatasets
2+
using Test
3+
4+
5+
fname = tempname()
6+
ds = NCDataset(fname,"c")
7+
8+
data = Array{Union{Missing,Float32},2}(undef,10,10)
9+
data .= 3
10+
data[2,2] = missing
11+
12+
add_offset = 12.
13+
scale_factor = 45
14+
fill_value = 9999.f0
15+
16+
v = defVar(ds,"temp",data,("lon","lat"),attrib = Dict(
17+
"_FillValue" => fill_value,
18+
"add_offset" => add_offset,
19+
"scale_factor" => scale_factor))
20+
21+
v.var[1,1] = 1
22+
23+
@test v[1,1] scale_factor * v.var[1,1] + add_offset
24+
@test ismissing(v[2,2])
25+
@test fillvalue(v) == fill_value
26+
27+
close(ds)

0 commit comments

Comments
 (0)