Skip to content

Commit

Permalink
accept Symbols for dim(v,dimname)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Oct 30, 2023
1 parent d71cb75 commit 6beb7ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
18 changes: 3 additions & 15 deletions src/types.jl
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
# All types using in `NCDatasets`
# Note in CommonDataModel the special properties `attrib`, `dim` and `group`
# are made available.


# Exception type for error thrown by the NetCDF library
mutable struct NetCDFError <: Exception
code::Cint
msg::String
end

# base type of attributes list

abstract type BaseAttributes
end

abstract type AbstractNCDataset <: AbstractDataset
end

abstract type AbstractNCVariable{T,N} <: AbstractVariable{T,N}
end


abstract type AbstractDimensions
end

abstract type AbstractGroups
end


# Variable (as stored in NetCDF file, without using
# add_offset, scale_factor and _FillValue)
mutable struct Variable{NetCDFType,N,TDS} <: AbstractNCVariable{NetCDFType, N}
ds::TDS
varid::Cint
dimids::NTuple{N,Cint}
# attrib::Attributes{TDS}
end

mutable struct NCDataset{TDS} <: AbstractNCDataset where TDS <: Union{AbstractNCDataset,Nothing}
Expand Down Expand Up @@ -130,7 +119,6 @@ end

# view of subsets


struct SubVariable{T,N,TA,TI,TAttrib,TV} <: AbstractNCVariable{T,N}
parent::TA
indices::TI
Expand Down
4 changes: 2 additions & 2 deletions src/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ end
export dimnames


function dim(v::AbstractNCVariable,dimname::AbstractString)
if !(dimname in dimnames(v))
function dim(v::AbstractNCVariable,dimname::SymbolOrString)
if !(String(dimname) in dimnames(v))
error("$dimname is not among the dimensions of $(name(v))")
end
return dim(dataset(v),dimname)
Expand Down

0 comments on commit 6beb7ce

Please sign in to comment.