Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FileFormats.NL] fix copy_to if MOI.Name is set #2446

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/FileFormats/NL/NL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@
dest.sense = MOI.get(model, MOI.ObjectiveSense())
elseif !has_nlp_objective && attr isa MOI.ObjectiveFunction
dest.f = _NLExpr(MOI.get(model, attr))
elseif attr == MOI.Name()
dest.name = MOI.get(model, MOI.Name())

Check warning on line 280 in src/FileFormats/NL/NL.jl

View check run for this annotation

Codecov / codecov/patch

src/FileFormats/NL/NL.jl#L279-L280

Added lines #L279 - L280 were not covered by tests
else
throw(MOI.UnsupportedAttribute(attr))
end
Expand Down
9 changes: 9 additions & 0 deletions test/FileFormats/NL/NL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,15 @@ J3 1
return
end

function test_copy_name_issue_2445()
src = MOI.Utilities.Model{Float64}()
MOI.set(src, MOI.Name(), "TestModel")
dest = NL.Model()
MOI.copy_to(dest, src)
@test MOI.get(dest, MOI.Name()) == "TestModel"
return
end

function runtests()
for name in names(@__MODULE__; all = true)
if startswith("$(name)", "test_")
Expand Down
Loading