Skip to content

Commit 8ae3e72

Browse files
fix issue #22
1 parent 77228b5 commit 8ae3e72

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/cfvariable.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ fillmode(v::CFVariable) = fillmode(v.var)
567567

568568
Base.Array(v::AbstractVariable{T,N}) where {T,N} = v[ntuple(i -> :, Val(N))...]
569569

570+
function Base.Array(v::AbstractVariable{T,0}) where {T}
571+
a = Array{T,0}(undef,size(v))
572+
# only a single element to load
573+
a .= v
574+
return a
575+
end
570576

571577
"""
572578
CommonDataModel.load!(ncvar::CFVariable, data, buffer, indices)

test/test_variable.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,9 @@ data2 = zeros(Int,1)
285285
data2 = zeros(Int,10)
286286
# asking too many elements
287287
@test_throws BoundsError load!(ds["data"].var,data2,1:10)
288+
289+
# issue 22
290+
filename = tempname()
291+
ds = TDS(filename, "c")
292+
v = defVar(ds, "a", Int32, ())
293+
@test ndims(Array(v)) == ndims(v) == 0

0 commit comments

Comments
 (0)