Skip to content

Commit

Permalink
fix issue #22
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Apr 16, 2024
1 parent 77228b5 commit 8ae3e72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cfvariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ fillmode(v::CFVariable) = fillmode(v.var)

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

function Base.Array(v::AbstractVariable{T,0}) where {T}
a = Array{T,0}(undef,size(v))
# only a single element to load
a .= v

This comment has been minimized.

Copy link
@rafaqz

rafaqz Apr 16, 2024

Member

a[] = v[]

Would probably save a lot of compilation

This comment has been minimized.

Copy link
@Alexander-Barth

Alexander-Barth Apr 30, 2024

Author Member

Thanks! I updated this.

return a
end

"""
CommonDataModel.load!(ncvar::CFVariable, data, buffer, indices)
Expand Down
6 changes: 6 additions & 0 deletions test/test_variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,9 @@ data2 = zeros(Int,1)
data2 = zeros(Int,10)
# asking too many elements
@test_throws BoundsError load!(ds["data"].var,data2,1:10)

# issue 22
filename = tempname()
ds = TDS(filename, "c")
v = defVar(ds, "a", Int32, ())
@test ndims(Array(v)) == ndims(v) == 0

0 comments on commit 8ae3e72

Please sign in to comment.