From 309f613b69c9ab116cffe6b5363f70a521a93c5f Mon Sep 17 00:00:00 2001 From: Fabian Gans Date: Tue, 16 Apr 2024 08:33:31 +0200 Subject: [PATCH] Fix need_batch for cartesianindex arguments (#166) --- src/diskarray.jl | 2 ++ test/runtests.jl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/diskarray.jl b/src/diskarray.jl index 0365931..f412d1d 100644 --- a/src/diskarray.jl +++ b/src/diskarray.jl @@ -63,6 +63,7 @@ _need_batch(_, ::Tuple{}, _) = false need_batch_index(::Union{Integer,UnitRange,Colon}, cs, _) = false, Base.tail(cs) need_batch_index(i::CartesianIndices{N}, cs, _) where N = false, last(splitcs(i, cs)) +need_batch_index(i::CartesianIndex{N}, cs, _) where N = false, last(splitcs(i,cs)) need_batch_index(::StepRange, cs, ::ChunkStrategy{CanStepRange}) = false, Base.tail(cs) function need_batch_index(i, cs, batchstrat) csnow, csrem = splitcs(i, cs) @@ -159,6 +160,7 @@ end splitcs(i::AbstractArray{<:CartesianIndex}, cs) = splitcs(first(i).I, (), cs) splitcs(i::AbstractArray{Bool}, cs) = splitcs(size(i), (), cs) splitcs(i::CartesianIndices, cs) = splitcs(i.indices, (), cs) +splitcs(i::CartesianIndex, cs) = splitcs(i.I,(),cs) splitcs(_, cs) = (first(cs),), Base.tail(cs) splitcs(si, csnow, csrem) = splitcs(Base.tail(si), (csnow..., first(csrem)), Base.tail(csrem)) splitcs(::Tuple{}, csnow, csrem) = (csnow, csrem) diff --git a/test/runtests.jl b/test/runtests.jl index 82fa42d..a60aa23 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -93,6 +93,8 @@ function test_setindex(a) a[[2, 4], 1:2, 1] = [1 2; 5 6] @test trueparent(a)[[2, 4], 1:2, 1] == [1 2; 5 6] @test setindex_count(a) == 8 + a[CartesianIndex(1,1,1)] = -10 + @test trueparent(a)[1,1,1] == -10 end function test_view(a)