Skip to content

Commit 49e0947

Browse files
committed
Fix rational test
1 parent 0562453 commit 49e0947

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

test/datasets.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,27 @@ function test_write(T)
9999
add_var(ds, 0.5:1:9.5, "lon", ("lon",), Dict("units"=>"degrees_east"))
100100
add_var(ds, 20:-1.0:1, "lat", ("lat",), Dict("units"=>"degrees_north"))
101101
v = add_var(ds, Float32, "tas", (10,20), ("lon", "lat"), Dict{String,Any}("units"=>"Celsius"))
102-
if T isa YAXArrayBase.backendlist[:zarr]
102+
# This is needed, since netcdf can not write rationals.
103+
if T == YAXArrayBase.backendlist[:zarr]
103104
w = add_var(ds, Rational{Int}, "tas2", (10,20), ("lon", "lat"), Dict{String,Any}("units"=>"Celsius"))
104105
w[:,:] = collect(reshape(1:200, 10, 20)) .// 2
105106
w = get_var_handle(ds, "tas2")
106107
@test w[1:2,1:2] == [1 11; 2 12] .// 2
108+
w = get_var_handle(ds, "tas2")
109+
@test w[1:2,1:2] == [1 11; 2 12] .// 2
110+
@test sort(get_varnames(ds)) == ["lat","lon","tas", "tas2"]
111+
else
112+
@test sort(get_varnames(ds)) == ["lat","lon","tas"]
107113
end
108114
v[:,:] = collect(reshape(1:200, 10, 20))
109115

110-
@test sort(get_varnames(ds)) == ["lat","lon","tas", "tas2"]
111116
@test get_var_dims(ds, "tas") == ["lon", "lat"]
112117
@test get_var_dims(ds, "lon") == ["lon"]
113118
@test get_var_attrs(ds,"tas")["units"] == "Celsius"
114119
h = get_var_handle(ds, "lon")
115120
@test h[:] == 0.5:1:9.5
116121
v = get_var_handle(ds, "tas")
117122
@test v[1:2,1:2] == [1 11; 2 12]
118-
w = get_var_handle(ds, "tas2")
119-
@test w[1:2,1:2] == [1 11; 2 12] .// 2
120123
end
121124

122125
@testset "Writing NetCDF" begin

0 commit comments

Comments
 (0)