Skip to content

Commit 74151b6

Browse files
fix 0.7 warnings and 0.6 iteration
1 parent f6ff634 commit 74151b6

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/NCDatasets.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,15 +1150,15 @@ Base.start(a::NCIterable) = keys(a)
11501150
Base.done(a::NCIterable,state) = length(state) == 0
11511151
Base.next(a::NCIterable,state) = (state[1] => a[popfirst!(state)], state)
11521152

1153-
1153+
@static if VERSION >= v"0.7.0-beta.0"
11541154
function Base.iterate(a::NCIterable, state = keys(a))
11551155
if length(state) == 0
11561156
return nothing
11571157
end
11581158

11591159
return (state[1] => a[popfirst!(state)], state)
11601160
end
1161-
1161+
end
11621162

11631163
"""
11641164
escape(val)

test/test_writevar.jl

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
using NCDatasets
2+
if VERSION >= v"0.7.0-beta.0"
3+
using Test
4+
using Dates
5+
using Printf
6+
else
7+
using Base.Test
8+
end
9+
10+
using Compat
11+
112
sz = (4,5)
213
filename = tempname()
314
#filename = "/tmp/test-9.nc"
@@ -75,45 +86,49 @@ v = NCDatasets.defVar(ds,"var-Char",Char,("lon","lat"))
7586

7687
# write array (without transformation)
7788
v.var[:,:] = fill('a',size(v))
78-
@test all(v.var[:,:][:] .== 'a')
89+
@test all(i -> i == 'a',v.var[:,:][:])
7990

8091
# write scalar
8192
v.var[:,:] = 'b'
82-
@test all(v.var[:,:][:] .== 'b')
93+
@test all(i -> i == 'b',v.var[:,:][:])
8394

8495
# write array (with transformation)
8596
v[:,:] = fill('c',size(v))
86-
@test all(v[:,:][:] .== 'c')
97+
@test all(i -> i == 'c',v.var[:,:][:])
8798

8899
# write scalar
89100
v[:,:] = 'd'
90-
@test all(v[:,:][:] .== 'd')
101+
@test all(i -> i == 'd',v.var[:,:][:])
91102

92103
# using StepRange as index
93104
# write array (without transformation)
94105
v.var[1:end,1:end] = fill('e',size(v))
95-
@test all(v.var[1:end,1:end][:] .== 'e')
106+
@test all(i -> i == 'e',v.var[:,:][:])
96107

97108
# write scalar
98109
v.var[1:end,1:end] = 'f'
99-
@test all(v.var[1:end,1:end][:] .== 'f')
110+
@test all(i -> i == 'f',v.var[:,:][:])
100111

101112
# write array (with transformation)
102113
v[1:end,1:end] = fill('g',size(v))
103-
@test all(v[1:end,1:end][:] .== 'g')
114+
@test all(i -> i == 'g',v.var[:,:][:])
104115

105116
# write scalar
106117
v[1:end,1:end] = 'h'
107-
@test all(v[1:end,1:end][:] .== 'h')
118+
@test all(i -> i == 'h',v.var[:,:][:])
108119

109120
# write with StepRange
110121
v[:,:] = 'h'
111122
ref = fill('h',sz)
112123

113-
ref[1:2:end,1:2:end] .= 'i'
124+
if VERSION >= v"0.7.0-beta.0"
125+
ref[1:2:end,1:2:end] .= Ref('i')
126+
else
127+
ref[1:2:end,1:2:end] = 'i'
128+
end
114129
v[1:2:end,1:2:end] = 'i'
115-
@test v[:,:] == ref
116130

131+
@test v[:,:] == ref
117132

118133

119134
ref = ['a'+i+2*j for i = 0:sz[1]-1, j= 0:sz[2]-1]
@@ -130,4 +145,3 @@ v[:,:] = ref
130145

131146
NCDatasets.close(ds)
132147

133-

0 commit comments

Comments
 (0)