Skip to content

Commit

Permalink
Fix index_map in MOI.copy_to (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored May 28, 2021
1 parent 4e317c9 commit 18f38bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/MOI_wrapper/MOI_copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function _extract_row_data(src, mapping, lb, ub, I, J, V, ::Type{S}) where {S}
end
row += 1
ind = MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64},S}(row)
dict[list[i]] = ind
mapping[list[i]] = ind
end
return
end
Expand Down
10 changes: 9 additions & 1 deletion test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,15 @@ end
c8: c + d == 2.2
""",
)
MOI.copy_to(dest, src; copy_names = true)
index_map = MOI.copy_to(dest, src; copy_names = true)
@test length(index_map) == 7
for (k, v) in index_map
if k isa MOI.VariableIndex
@test k == v
else
@test k isa MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64}}
end
end
v = MOI.get(dest, MOI.ListOfVariableIndices())
@test length(v) == 4
names = MOI.get.(dest, MOI.VariableName(), v)
Expand Down

2 comments on commit 18f38bf

@odow
Copy link
Member Author

@odow odow commented on 18f38bf May 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/37706

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.14.9 -m "<description of version>" 18f38bf741ed8cab2dd9c7f156e0610f38d060bb
git push origin v0.14.9

Please sign in to comment.