@@ -426,14 +426,11 @@ end
426
426
427
427
_write_data_to_nc (v:: Variable , data) = _write_data_to_nc (v, data, 1 )
428
428
429
- function _write_data_to_nc (v:: Variable{T, N} , data, indexes:: StepRange{<:Integer,<:Integer} ...) where {T, N}
430
- start,count,stride,jlshape = ncsub (v,indexes)
431
- nc_put_vars (v. ds. ncid,v. varid,start,count,stride,T .(data))
432
- end
429
+ function _write_data_to_nc (v:: Variable{T} , data, indexes:: AbstractRange{<:Integer} ...) where T
430
+ ind = prod (length .(indexes)) == 1 ? first .(indexes) : to_indices (v,indexes)
433
431
434
- function _write_data_to_nc (v:: Variable , data, indexes:: Union{AbstractRange{<:Integer}} ...)
435
- ind = prod (length .(indexes)) == 1 ? first .(indexes) : normalizeindexes (size (v),indexes)
436
- return _write_data_to_nc (v, data, ind... )
432
+ start,count,stride,jlshape = ncsub (v,indexes)
433
+ return nc_put_vars (v. ds. ncid,v. varid,start,count,stride,T .(data))
437
434
end
438
435
439
436
function eachchunk (v:: Variable )
@@ -451,19 +448,6 @@ haschunks(v::Variable) = (_chunking(v)[1] == :contiguous ? DiskArrays.Unchunked(
451
448
eachchunk (v:: CFVariable{T,N,<:Variable} ) where {T,N} = eachchunk (v. var)
452
449
haschunks (v:: CFVariable{T,N,<:Variable} ) where {T,N} = haschunks (v. var)
453
450
454
- _normalizeindex (n,ind:: Base.OneTo ) = 1 : 1 : ind. stop
455
- _normalizeindex (n,ind:: Colon ) = 1 : 1 : n
456
- _normalizeindex (n,ind:: Integer ) = ind: 1 : ind
457
- _normalizeindex (n,ind:: UnitRange ) = StepRange (ind)
458
- _normalizeindex (n,ind:: StepRange ) = ind
459
- _normalizeindex (n,ind) = error (" unsupported index" )
460
-
461
- # indexes can be longer than sz
462
- function normalizeindexes (sz,indexes)
463
- return ntuple (i -> _normalizeindex (sz[i],indexes[i]), length (sz))
464
- end
465
-
466
-
467
451
# computes the size of the array `a` after applying the indexes
468
452
# size(a[indexes...]) == size_getindex(a,indexes...)
469
453
0 commit comments