diff --git a/src/cfvariable.jl b/src/cfvariable.jl index a364e4bf..8de925a4 100644 --- a/src/cfvariable.jl +++ b/src/cfvariable.jl @@ -474,7 +474,7 @@ function Base.keys(v::AbstractVariable) end -function Base.getindex(v::AbstractVariable,name::AbstractString) +function Base.getindex(v::AbstractVariable,name::SymbolOrString) ds = dataset(v) ncvar = ds[name] if _isrelated(ncvar,v) diff --git a/test/test_cfconventions.jl b/test/test_cfconventions.jl index 7093fb5d..5af7e220 100644 --- a/test/test_cfconventions.jl +++ b/test/test_cfconventions.jl @@ -169,5 +169,11 @@ ds = NCDataset(fname) @test_throws KeyError ds[CF"longitude"] # error nclon_u2 = ds["ubar"][CF"longitude"] +@test name(nclon_u2) == "lon_u" + + +nclon_u2 = ds["ubar"]["lon_u"] +@test name(nclon_u2) == "lon_u" +nclon_u2 = ds["ubar"][:lon_u] @test name(nclon_u2) == "lon_u"