diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3427e4f9..511b640f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: version: - - '1.6' + - 'lts' - '1' #- '~1.8.0-0' - 'nightly' diff --git a/Project.toml b/Project.toml index e2734567..7c61e444 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" CFTime = "0.1.1" CommonDataModel = "0.3.4" DataStructures = "0.17, 0.18" -DiskArrays = "0.3.22" +DiskArrays = "0.4.5" NetCDF_jll = "=400.701.400, =400.702.400, =400.902.5, =400.902.208, =400.902.209, =400.902.211" NetworkOptions = "1.2" julia = "1.6" diff --git a/src/variable.jl b/src/variable.jl index 370372d3..7c319131 100644 --- a/src/variable.jl +++ b/src/variable.jl @@ -443,7 +443,8 @@ function eachchunk(v::Variable) return DiskArrays.GridChunks(v, chunksizes) end end -haschunks(v::Variable) = (_chunking(v)[1] == :contiguous ? DiskArrays.Unchunked() : DiskArrays.Chunked()) +haschunks(v::Variable) = (_chunking(v)[1] == :contiguous ? DiskArrays.Unchunked(DiskArrays.SubRanges(DiskArrays.CanStepRange(),1.0)) : + DiskArrays.Chunked(DiskArrays.SubRanges(DiskArrays.CanStepRange(),1.0))) eachchunk(v::CFVariable{T,N,<:Variable}) where {T,N} = eachchunk(v.var) haschunks(v::CFVariable{T,N,<:Variable}) where {T,N} = haschunks(v.var) @@ -537,38 +538,3 @@ function _range_indices_dest(of,v,rest...) end range_indices_dest(ri...) = _range_indices_dest((),ri...) -function _batchgetindex( - v::Variable{T}, - indices::Union{<:Integer,Colon,AbstractRange{<:Integer},AbstractVector{<:Integer}}...) where T - - @debug "transform vector of indices to ranges" - - sz_source = size(v) - ri = to_range_list.(indices,sz_source) - sz_dest = size_getindex(v,indices...) - - N = length(indices) - - ri_dest = range_indices_dest(ri...) - @debug "ri_dest $ri_dest" - @debug "ri $ri" - - if all(==(1),length.(ri)) - # single chunk - R = first(CartesianIndices(length.(ri))) - ind_source = ntuple(i -> ri[i][R[i]],N) - ind_dest = ntuple(i -> ri_dest[i][R[i]],length(ri_dest)) - return v[ind_source...] - end - - dest = Array{eltype(v),length(sz_dest)}(undef,sz_dest) - for R in CartesianIndices(length.(ri)) - ind_source = ntuple(i -> ri[i][R[i]],N) - ind_dest = ntuple(i -> ri_dest[i][R[i]],length(ri_dest)) - dest[ind_dest...] = v[ind_source...] - end - return dest -end - -DiskArrays.batchgetindex(v::Variable,indices::Union{<:Integer,Colon,AbstractRange{<:Integer},AbstractVector{<:Integer}}...) = _batchgetindex(v,indices...) -DiskArrays.batchgetindex(v::Variable,index::AbstractVector{Int}) = _batchgetindex(v,index) diff --git a/test/test_check_size.jl b/test/test_check_size.jl index b829feed..fec27bc5 100644 --- a/test/test_check_size.jl +++ b/test/test_check_size.jl @@ -33,10 +33,10 @@ ds["w"][:,1:15] = ones(10,15) @test size(ds["w"]) == (10,15) # w cannot grow along a fixed dimension -@test_throws DimensionMismatch ds["w"][:,:] = ones(11,15) +@test_throws Union{NCDatasets.NetCDFError,DimensionMismatch} ds["w"][:, :] = ones(11, 15) # NetCDF: Index exceeds dimension bound -@test_throws NCDatasets.NetCDFError ds["u"][100,100] +@test_throws Union{NCDatasets.NetCDFError,BoundsError} ds["u"][100,100] close(ds) rm(filename) diff --git a/test/test_variable.jl b/test/test_variable.jl index ad016860..7b07ceab 100644 --- a/test/test_variable.jl +++ b/test/test_variable.jl @@ -20,7 +20,7 @@ NCDataset(filename,"c") do ds v = defVar(ds,"small",Float64,("lon","lat")) # @test_throws Union{NCDatasets.NetCDFError,DimensionMismatch} v[:] = zeros(sz[1]+1,sz[2]) - @test_throws DimensionMismatch v[1:sz[1],1:sz[2]] = zeros(sz[1]+1,sz[2]) + @test_throws Union{NCDatasets.NetCDFError,DimensionMismatch} v[1:sz[1],1:sz[2]] = zeros(sz[1]+1,sz[2]) @test_throws NCDatasets.NetCDFError v[sz[1]+1,1] = 1 @test_throws NCDatasets.NetCDFError v[-1,1] = 1