From bca998493e2e3f28aace32230133843b77c4a2ea Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 25 Oct 2023 08:46:41 +1300 Subject: [PATCH] [FileFormats] revert change to extract_function_and_set (#2321) --- src/FileFormats/MOF/write.jl | 5 +++-- test/FileFormats/MOF/MOF.jl | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/FileFormats/MOF/write.jl b/src/FileFormats/MOF/write.jl index a5955ab535..50b18f50e3 100644 --- a/src/FileFormats/MOF/write.jl +++ b/src/FileFormats/MOF/write.jl @@ -54,7 +54,8 @@ end _lift_variable_indices(arg) = arg # Recursion fallback. -function _extract_function_and_set(expr::Expr) +# TODO(odow): Used by PolyJuMP. Make private in future. +function extract_function_and_set(expr::Expr) if expr.head == :call # One-sided constraint or foo-in-set. @assert length(expr.args) == 3 if expr.args[1] == :in @@ -100,7 +101,7 @@ function write_nlpblock( end for (row, bounds) in enumerate(nlp_block.constraint_bounds) constraint = MOI.constraint_expr(nlp_block.evaluator, row) - (func, set) = _extract_function_and_set(constraint) + (func, set) = extract_function_and_set(constraint) func = _lift_variable_indices(func) push!( object["constraints"], diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/MOF.jl index c60e131e8f..e0bb62d467 100644 --- a/test/FileFormats/MOF/MOF.jl +++ b/test/FileFormats/MOF/MOF.jl @@ -190,15 +190,15 @@ function test_nonlinear_error_handling() [MOI.VariableIndex(1)], ) # Function-in-Set - @test_throws Exception MOF._extract_function_and_set(:(foo in set)) + @test_throws Exception MOF.extract_function_and_set(:(foo in set)) # Not a constraint. - @test_throws Exception MOF._extract_function_and_set(:(x^2)) + @test_throws Exception MOF.extract_function_and_set(:(x^2)) # Two-sided constraints - @test MOF._extract_function_and_set(:(1 <= x <= 2)) == - MOF._extract_function_and_set(:(2 >= x >= 1)) == + @test MOF.extract_function_and_set(:(1 <= x <= 2)) == + MOF.extract_function_and_set(:(2 >= x >= 1)) == (:x, MOI.Interval(1, 2)) # Less-than constraint. - @test MOF._extract_function_and_set(:(x <= 2)) == (:x, MOI.LessThan(2)) + @test MOF.extract_function_and_set(:(x <= 2)) == (:x, MOI.LessThan(2)) end function _convert_mof_to_expr(