Skip to content

Commit 8301e61

Browse files
reduce ambiguities (issue #20)
1 parent f1cd2e8 commit 8301e61

File tree

5 files changed

+6
-12
lines changed

5 files changed

+6
-12
lines changed

src/cfconventions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ good_data = NCDatasets.filter(ds["data"],:,:, accepted_status_flags = ["good_dat
102102
filter(ncv::AbstractVariable, indices::TIndices...; kwargs...) =
103103
_filter(ncv, indices...; kwargs...)
104104

105-
filter(ncv::AbstractVariable, indices::Vector{<:Integer}; kwargs...) =
105+
filter(ncv::AbstractVariable, indices::Union{Vector{<:Integer}, Array{<:CartesianIndex}}...; kwargs...) =
106106
_filter(ncv, indices...; kwargs...)
107107

108108
filter(ncv::AbstractVariable, indices::BitVector; kwargs...) =

src/cfvariable.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ end
441441
#@inline CFtransformdata(data::Char,fv,scale_factor,add_offset,time_origin,time_factor,DTcast) = CFtransform_missing(data,fv)
442442
#@inline CFinvtransformdata(data::Char,fv,scale_factor,add_offset,time_origin,time_factor,DT) = CFtransform_replace_missing(data,fv)
443443

444-
445444
function Base.getindex(v::CFVariable, indexes::TIndices...)
446445
data = v.var[indexes...]
447446
return CFtransformdata(data,fill_and_missing_values(v),scale_factor(v),add_offset(v),

src/memory_dataset.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import CommonDataModel as CDM
22

33
Base.size(RA::ResizableArray) = size(RA.A)
44
Base.getindex(RA::ResizableArray,inds...) = getindex(RA.A,inds...)
5-
Base.checkbounds(::Type{Bool},RA::ResizableArray,inds...) = all(minimum.(inds) .> 0)
5+
Base.checkbounds(::Type{Bool},RA::ResizableArray,inds::Union{Integer,AbstractVector{<:Integer}}...) = all(minimum.(inds) .> 0)
66

77
function grow!(RA::ResizableArray{T,N},new_size) where {T,N}
88
# grow
@@ -53,7 +53,7 @@ function grow_unlimited_dimension(ds,dname,len)
5353
end
5454
end
5555

56-
Base.getindex(v::MemoryVariable,ij...) = v.data[ij...]
56+
Base.getindex(v::MemoryVariable,ij::TIndices...) = v.data[ij...]
5757
CDM.load!(v::MemoryVariable,buffer,ij...) = buffer .= view(v.data,ij...)
5858

5959
function Base.setindex!(v::MemoryVariable,data,ij...)

src/multifile.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ function MFDataset(TDS,fnames::AbstractArray{<:AbstractString,N},mode = "r"; agg
126126
end
127127

128128

129-
Base.getindex(v::Union{MFVariable,DeferVariable},ci::CartesianIndices) = v[ci.indices...]
130-
Base.setindex!(v::Union{MFVariable,DeferVariable},data,ci::CartesianIndices) = setindex!(v,data,ci.indices...)
131-
132-
133-
134129
function close(mfds::MFDataset)
135130
close.(mfds.ds)
136131
return nothing
@@ -249,8 +244,8 @@ end
249244
dataset(v::Union{MFVariable,MFCFVariable}) = v.ds
250245

251246

252-
Base.getindex(v::MFCFVariable,ind...) = v.cfvar[ind...]
253-
Base.setindex!(v::MFCFVariable,data,ind...) = v.cfvar[ind...] = data
247+
Base.getindex(v::MFCFVariable,ind::TIndices...) = v.cfvar[ind...]
248+
Base.setindex!(v::MFCFVariable,data,ind::TIndices...) = v.cfvar[ind...] = data
254249

255250

256251
function Base.cat(vs::AbstractVariable...; dims::Integer)

src/types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
const SymbolOrString = Union{Symbol, AbstractString}
33

4-
const TIndices = Union{<:Integer,AbstractVector{<:Integer},AbstractArray{<:CartesianIndex}, CartesianIndex ,Colon}
4+
const TIndices = Union{<:Integer,AbstractVector{<:Integer},Colon}
55

66
"""
77

0 commit comments

Comments
 (0)