From c63b19c6f2beb77cc19b9ed6a43a8eba5559cdd9 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 1 Nov 2024 14:18:50 +1300 Subject: [PATCH] Fix UnsupportedNonlinearOperator error for LinearAlgebra.norm (#3864) --- src/nlp_expr.jl | 4 ++++ test/test_nlp_expr.jl | 1 + 2 files changed, 5 insertions(+) diff --git a/src/nlp_expr.jl b/src/nlp_expr.jl index 066610bb8ba..5233165629d 100644 --- a/src/nlp_expr.jl +++ b/src/nlp_expr.jl @@ -1171,6 +1171,10 @@ function LinearAlgebra.logdet(::AbstractMatrix{<:AbstractJuMPScalar}) return throw(MOI.UnsupportedNonlinearOperator(:logdet)) end +function LinearAlgebra.norm(::AbstractArray{<:AbstractJuMPScalar}) + return throw(MOI.UnsupportedNonlinearOperator(:norm)) +end + function LinearAlgebra.norm(::AbstractArray{<:AbstractJuMPScalar}, ::Real) return throw(MOI.UnsupportedNonlinearOperator(:norm)) end diff --git a/test/test_nlp_expr.jl b/test/test_nlp_expr.jl index afc555f7da4..1bd9e0d2668 100644 --- a/test/test_nlp_expr.jl +++ b/test/test_nlp_expr.jl @@ -857,6 +857,7 @@ function test_linear_algebra_errors() @test_throws MOI.UnsupportedNonlinearOperator LinearAlgebra.qr(x) y = 2.0 .* x[:, 2] .+ 1.0 @test_throws MOI.UnsupportedNonlinearOperator LinearAlgebra.norm(y) + @test_throws MOI.UnsupportedNonlinearOperator LinearAlgebra.norm(y, 2) @test_throws MOI.UnsupportedNonlinearOperator LinearAlgebra.nullspace(y) return end