Skip to content

Commit e476f03

Browse files
check dim name
1 parent 82155be commit e476f03

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/dimension.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ dimnames(ds::Union{AbstractDataset,AbstractVariable}) = ()
1212
1313
Return the length of the dimension `dimname` in the data set `ds`.
1414
"""
15-
dim(v::AbstractVariable,name::AbstractString) = dim(dataset(v),name)
15+
function dim(v::AbstractVariable,name::AbstractString)
16+
if !(dimname in dimnames(v))
17+
error("$dimname is not among the dimensions of $(name(v))")
18+
end
19+
return dim(dataset(v),dimname)
20+
end
1621

1722
function dim(ds::AbstractDataset,dimname::AbstractString)
1823
error("no dimension $dimname in $(path(ds))")

0 commit comments

Comments
 (0)