Skip to content

Commit 9f146c9

Browse files
authored
Fix bug in restricted_copy (infiniteopt#360)
1 parent 59a8650 commit 9f146c9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Collections/VectorTuple.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ function _update_indices(inds::ContainerIndices{1, <:Vector}, i)
218218
new_axes = deleteat!(copy(inds.axes), i)
219219
cart_inds = CartesianIndices(new_axes)
220220
return length(new_axes) >= 2 ? ContainerIndices(cart_inds, new_axes) : nothing
221+
# return ContainerIndices(cart_inds, new_axes)
221222
end
222223

223224
# DenseAxisArray
@@ -243,7 +244,7 @@ function restricted_copy(vt::VectorTuple, inds::AbstractVector{<:Bool})
243244
prev_sum = 0
244245
delete_inds = Int[]
245246
new_ranges = copy(vt.ranges)
246-
new_indices = collect(vt.indices)
247+
new_indices = collect(Any, vt.indices)
247248
for i in eachindex(new_ranges)
248249
delete_sum = sum(inv_inds[new_ranges[i]])
249250
if length(new_ranges[i]) == delete_sum

test/Collections/VectorTuple.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@
276276
copy_inds = [false, false, true, false, true, true, false, true]
277277
@test IC.restricted_copy(vt, copy_inds) == IC.VectorTuple(cs, new_d)
278278
@test vt == IC.VectorTuple(a, c, d)
279+
# test with partial reduction of an vector
280+
vt = IC.VectorTuple([1, 2])
281+
@test IC.restricted_copy(vt, [true, false]) == IC.VectorTuple(1)
279282
end
280283
end
281284

0 commit comments

Comments
 (0)