From 9a255ad1d62475e0c0533f73653b4b0a6d588abb Mon Sep 17 00:00:00 2001 From: pulsipher Date: Tue, 6 Aug 2024 15:06:52 -0400 Subject: [PATCH] Fix bug in restricted_copy --- src/Collections/VectorTuple.jl | 3 ++- test/Collections/VectorTuple.jl | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Collections/VectorTuple.jl b/src/Collections/VectorTuple.jl index 338e5bd3b..4cb31a9d9 100644 --- a/src/Collections/VectorTuple.jl +++ b/src/Collections/VectorTuple.jl @@ -218,6 +218,7 @@ function _update_indices(inds::ContainerIndices{1, <:Vector}, i) new_axes = deleteat!(copy(inds.axes), i) cart_inds = CartesianIndices(new_axes) return length(new_axes) >= 2 ? ContainerIndices(cart_inds, new_axes) : nothing + # return ContainerIndices(cart_inds, new_axes) end # DenseAxisArray @@ -243,7 +244,7 @@ function restricted_copy(vt::VectorTuple, inds::AbstractVector{<:Bool}) prev_sum = 0 delete_inds = Int[] new_ranges = copy(vt.ranges) - new_indices = collect(vt.indices) + new_indices = collect(Any, vt.indices) for i in eachindex(new_ranges) delete_sum = sum(inv_inds[new_ranges[i]]) if length(new_ranges[i]) == delete_sum diff --git a/test/Collections/VectorTuple.jl b/test/Collections/VectorTuple.jl index 3edd4a929..76432e24d 100644 --- a/test/Collections/VectorTuple.jl +++ b/test/Collections/VectorTuple.jl @@ -276,6 +276,9 @@ copy_inds = [false, false, true, false, true, true, false, true] @test IC.restricted_copy(vt, copy_inds) == IC.VectorTuple(cs, new_d) @test vt == IC.VectorTuple(a, c, d) + # test with partial reduction of an vector + vt = IC.VectorTuple([1, 2]) + @test IC.restricted_copy(vt, [true, false]) == IC.VectorTuple(1) end end