Skip to content

Commit

Permalink
use delAttrib
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Nov 16, 2023
1 parent 9ea0f03 commit 179983d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/NCDatasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import CommonDataModel: AbstractDataset, AbstractVariable,
path, name, isopen, unlimited, dataset,
groupname, groupnames, group, defGroup,
dimnames, dim, defDim,
attribnames, attrib, defAttrib,
attribnames, attrib, defAttrib, delAttrib,
varbyattrib, CFStdName, @CF_str, ancillaryvariables, filter, coord, bounds,
MFDataset, MFCFVariable,
DeferDataset, metadata, Resource,
Expand Down
14 changes: 7 additions & 7 deletions src/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ _varid(v::Variable) = v.varid
_dataset(v::Variable) = v.ds



"""
attribnames(ds::Union{Dataset,Variable})
Expand Down Expand Up @@ -93,15 +94,14 @@ Check if `name` is an attribute
Base.haskey(a::CommonDataModel.Attributes{<:Union{Dataset,Variable}},name::SymbolOrString) =
_nc_has_att(_ncid(a.ds),_varid(a.ds),name)

"""
Base.delete!(a::Attributes, name)

Delete the attribute `name` from the attribute list `a`.
"""
function Base.delete!(a::CommonDataModel.Attributes{<:Union{Dataset,Variable}},name::SymbolOrString)
ds = _dataset(a.ds)
defmode(ds)
delAttrib(ds::Union{Dataset,Variable},name::SymbolOrString)
nc_del_att(_ncid(a.ds),_varid(a.ds),name)
Delete the attribute `name` in the dataset or variable.
"""
function delAttrib(ds::Union{Dataset,Variable},name::SymbolOrString)
defmode(_dataset(ds)) # make sure that the file is in define mode
nc_del_att(_ncid(ds),_varid(ds),name)
return nothing
end

0 comments on commit 179983d

Please sign in to comment.