Skip to content

Commit

Permalink
Fix bug in restricted_copy (infiniteopt#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsipher authored Aug 6, 2024
1 parent 59a8650 commit 9f146c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Collections/VectorTuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/Collections/VectorTuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9f146c9

Please sign in to comment.