From 74f6127b6b6c89308d54887be2598bc2bb4624aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 26 May 2026 07:46:16 +0200 Subject: [PATCH] Remove _to_moi_arg --- src/JuMP/moi_bridge.jl | 14 ++++---------- src/JuMP/nlp_expr.jl | 2 ++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/JuMP/moi_bridge.jl b/src/JuMP/moi_bridge.jl index ff8b089..ce85a9a 100644 --- a/src/JuMP/moi_bridge.jl +++ b/src/JuMP/moi_bridge.jl @@ -3,22 +3,16 @@ # ── moi_function: JuMP → MOI ───────────────────────────────────────────────── -function _to_moi_arg(x::ArrayOfVariables{T,N}) where {T,N} +function JuMP.moi_function(x::ArrayOfVariables{T,N}) where {T,N} return ArrayOfContiguousVariables{N}(x.offset, x.size) end -function _to_moi_arg(x::GenericArrayExpr{V,N}) where {V,N} - args = Any[_to_moi_arg(a) for a in x.args] +function JuMP.moi_function(x::GenericArrayExpr{V,N}) where {V,N} + args = Any[JuMP.moi_function(a) for a in x.args] return ArrayNonlinearFunction{N}(x.head, args, x.size, x.broadcasted) end -_to_moi_arg(x::Array{<:Real}) = x - -_to_moi_arg(x::Real) = x - -function JuMP.moi_function(x::GenericArrayExpr{V,N}) where {V,N} - return _to_moi_arg(x) -end +JuMP.moi_function(x::Array{<:Real}) = x # ── Detect whether a JuMP expression contains array args ───────────────────── diff --git a/src/JuMP/nlp_expr.jl b/src/JuMP/nlp_expr.jl index 02de376..8ce1ab2 100644 --- a/src/JuMP/nlp_expr.jl +++ b/src/JuMP/nlp_expr.jl @@ -22,3 +22,5 @@ Base.size(expr::GenericArrayExpr) = expr.size JuMP.variable_ref_type(::Type{GenericArrayExpr{V,N}}) where {V,N} = V JuMP._is_real(::GenericArrayExpr) = true + +JuMP._is_real(::Array{<:Real}) = true