Skip to content

Commit bfd0edf

Browse files
issue #6
1 parent f4da189 commit bfd0edf

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

src/cfvariable.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Return a tuple of integers with the size of the variable `var`.
2222
Base.size(v::CFVariable) = size(v.var)
2323

2424
name(v::CFVariable) = name(v.var)
25+
dataset(v::CFVariable) = dataset(v.var)
26+
2527

2628
attribnames(v::CFVariable) = keys(v.attrib)
2729
attrib(v::CFVariable,name::AbstractString) = v.attrib[name]

src/variable.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ function variable(ds::AbstractDataset,variablename::AbstractString)
3131
end
3232

3333
function defVar(ds::AbstractDataset,name::AbstractString,type,dimnames)
34-
error("unimplemnted for abstract type")
34+
error("unimplemented for abstract type")
3535
end
3636

3737

38+
function dataset(v::AbstractVariable)
39+
error("unimplemented for abstract type")
40+
end
3841

3942

4043
function Base.show(io::IO,v::AbstractVariable)

test/memory_dataset.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ end
2020

2121
Base.getindex(v::MemoryVariable,ij...) = v.data[ij...]
2222
Base.setindex!(v::MemoryVariable,data,ij...) = v.data[ij...] = data
23+
CDM.dataset(v::MemoryVariable) = v.parent_dataset
2324
CDM.name(v::MemoryVariable) = v.name
2425
CDM.dimnames(v::MemoryVariable) = v.dimnames
2526
Base.size(v::MemoryVariable) = size(v.data)

test/test_scaling.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,6 @@ time_origin = DateTime(2000,1,1)
122122
md["data"][1,2] = DateTime(2000,2,1)
123123
@test md["data"].var[1,2] == Dates.value(md["data"][1,2] - time_origin) ÷ (24*60*60*1000)
124124

125+
126+
@test CDM.dataset(md["data"]) == md
125127
close(md)

0 commit comments

Comments
 (0)