From 179983d6d9d1811150bb3be6dfa7fa5ff968194c Mon Sep 17 00:00:00 2001 From: Alexander Barth Date: Thu, 16 Nov 2023 14:15:27 +0100 Subject: [PATCH] use delAttrib --- src/NCDatasets.jl | 2 +- src/attributes.jl | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/NCDatasets.jl b/src/NCDatasets.jl index a51c215a..05e41a36 100644 --- a/src/NCDatasets.jl +++ b/src/NCDatasets.jl @@ -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, diff --git a/src/attributes.jl b/src/attributes.jl index 665a5d1a..bb98bad1 100644 --- a/src/attributes.jl +++ b/src/attributes.jl @@ -25,6 +25,7 @@ _varid(v::Variable) = v.varid _dataset(v::Variable) = v.ds + """ attribnames(ds::Union{Dataset,Variable}) @@ -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