-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Fix errors for LinearAlgebra operators of JuMP arrays #3476
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3476 +/- ##
=======================================
Coverage 98.09% 98.09%
=======================================
Files 37 37
Lines 5501 5518 +17
=======================================
+ Hits 5396 5413 +17
Misses 105 105
☔ View full report in Codecov by Sentry. |
Are these the only functions affected or are there others? |
So do we want to do it for everything? julia> using JuMP, LinearAlgebra
julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.
julia> @variable(model, x[1:2, 1:2])
2×2 Matrix{VariableRef}:
x[1,1] x[1,2]
x[2,1] x[2,2]
julia> ret = Any[]
Any[]
julia> for name in names(LinearAlgebra; all = true)
f = getfield(LinearAlgebra, name)
try
f(x)
catch err
if !(err isa MethodError)
push!(ret, (name, typeof(err)))
end
end
end
julia>
julia> ret
19-element Vector{Any}:
(:SymTridiagonal, ArgumentError)
(:_rightappdimmismatch, DimensionMismatch)
(:cholesky!, PosDefException)
(:condskeel, TypeError)
(:generic_norm1, StackOverflowError)
(:generic_norm2, StackOverflowError)
(:generic_normInf, StackOverflowError)
(:generic_normMinusInf, StackOverflowError)
(:indmaxcolumn, StackOverflowError)
(:norm, StackOverflowError)
(:norm1, StackOverflowError)
(:norm2, StackOverflowError)
(:normInf, StackOverflowError)
(:normMinusInf, StackOverflowError)
(:norm_sqr, StackOverflowError)
(:normalize, StackOverflowError)
(:normalize!, StackOverflowError)
(:qr, TypeError)
(:qrfactPivotedUnblocked!, StackOverflowError)
julia> using JuMP, LinearAlgebra
julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.
julia> @variable(model, x[1:2])
2-element Vector{VariableRef}:
x[1]
x[2]
julia> ret = Any[]
Any[]
julia> for name in names(LinearAlgebra; all = true)
f = getfield(LinearAlgebra, name)
try
f(x)
catch err
if !(err isa MethodError)
push!(ret, (name, typeof(err)))
end
end
end
julia> ret
17-element Vector{Any}:
(:_rightappdimmismatch, DimensionMismatch)
(:_triuppers_qr, BoundsError)
(:checksquare, BoundsError)
(:diag, ArgumentError)
(:generic_norm1, StackOverflowError)
(:generic_norm2, StackOverflowError)
(:generic_normInf, StackOverflowError)
(:generic_normMinusInf, StackOverflowError)
(:norm, StackOverflowError)
(:norm1, StackOverflowError)
(:norm2, StackOverflowError)
(:normInf, StackOverflowError)
(:normMinusInf, StackOverflowError)
(:norm_sqr, StackOverflowError)
(:normalize, StackOverflowError)
(:normalize!, StackOverflowError)
(:qr, TypeError) |
All the variants of norms look relevant to cover |
So those norms are not exported and they don't have any documentation: help?> LinearAlgebra.generic_norm1
No documentation found.
LinearAlgebra.generic_norm1 is a Function.
# 1 method for generic function "generic_norm1":
[1] generic_norm1(x) in LinearAlgebra at /Users/oscar/.julia/juliaup/julia-1.6.7+0.x64.apple.darwin14/share/julia/stdlib/v1.6/LinearAlgebra/src/generic.jl:477
help?> LinearAlgebra.norm1
No documentation found.
LinearAlgebra.norm1 is a Function.
# 2 methods for generic function "norm1":
[1] norm1(x::Union{DenseVector{T}, Base.ReinterpretArray{T, 1, S, A, IsReshaped} where {A<:Union{SubArray{T, N, A, I, true} where {T, N, A<:DenseArray, I<:Union{Tuple{Vararg{Real, N} where N}, Tuple{AbstractUnitRange, Vararg{Any, N} where N}}}, DenseArray}, IsReshaped, S}, Base.ReshapedArray{T, 1, A, MI} where {A<:Union{Base.ReinterpretArray{T, N, S, A, IsReshaped} where {T, N, A<:Union{SubArray{T, N, A, I, true} where {T, N, A<:DenseArray, I<:Union{Tuple{Vararg{Real, N} where N}, Tuple{AbstractUnitRange, Vararg{Any, N} where N}}}, DenseArray}, IsReshaped, S}, SubArray{T, N, A, I, true} where {T, N, A<:DenseArray, I<:Union{Tuple{Vararg{Real, N} where N}, Tuple{AbstractUnitRange, Vararg{Any, N} where N}}}, DenseArray}, MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}, N} where N}}, SubArray{T, 1, A, I, L} where {A<:Union{Base.ReinterpretArray{T, N, S, A, IsReshaped} where {T, N, A<:Union{SubArray{T, N, A, I, true} where {T, N, A<:DenseArray, I<:Union{Tuple{Vararg{Real, N} where N}, Tuple{AbstractUnitRange, Vararg{Any, N} where N}}}, DenseArray}, IsReshaped, S}, Base.ReshapedArray{T, N, A, MI} where {T, N, A<:Union{Base.ReinterpretArray{T, N, S, A, IsReshaped} where {T, N, A<:Union{SubArray{T, N, A, I, true} where {T, N, A<:DenseArray, I<:Union{Tuple{Vararg{Real, N} where N}, Tuple{AbstractUnitRange, Vararg{Any, N} where N}}}, DenseArray}, IsReshaped, S}, SubArray{T, N, A, I, true} where {T, N, A<:DenseArray, I<:Union{Tuple{Vararg{Real, N} where N}, Tuple{AbstractUnitRange, Vararg{Any, N} where N}}}, DenseArray}, MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}, N} where N}}, DenseArray}, I<:Tuple{Vararg{Union{Int64, AbstractRange{Int64}, Base.AbstractCartesianIndex, Base.ReshapedArray{T, N, A, Tuple{}} where {T, N, A<:AbstractUnitRange}}, N} where N}, L}, Array{T, N} where N}) where T<:Union{Float32, Float64} in LinearAlgebra at /Users/oscar/.julia/juliaup/julia-1.6.7+0.x64.apple.darwin14/share/julia/stdlib/v1.6/LinearAlgebra/src/dense.jl:102
[2] norm1(x) in LinearAlgebra at /Users/oscar/.julia/juliaup/julia-1.6.7+0.x64.apple.darwin14/share/julia/stdlib/v1.6/LinearAlgebra/src/generic.jl:557
help?> LinearAlgebra.norm2
No documentation found.
LinearAlgebra.norm2 is a Function.
# 2 methods for generic function "norm2": This is the exported list: #3467 (comment), and |
Ok that's fine, we shouldn't don't need to define fallbacks for methods that aren't exported. |
The matrix ones are more problematic: julia> la_y
29-element Vector{Any}:
(:bunchkaufman, MethodError(VariableRef, (1,), 0x0000000000007424))
(:cholesky, MethodError(VariableRef, (1,), 0x0000000000007424))
(:cholesky!, PosDefException(-1))
(:cond, MethodError(LinearAlgebra.svdvals!, (Any[y[1,1] y[1,2]; y[2,1] y[2,2]],), 0x0000000000007424))
(:condskeel, TypeError(:typeassert, "", NonlinearExpr, y[1,1]))
(:eigen, MethodError(LinearAlgebra.var"#eigen!##kw"(), ((permute = true, scale = true, sortby = LinearAlgebra.eigsortby), LinearAlgebra.eigen!, Any[y[1,1] y[1,2]; y[2,1] y[2,2]]), 0x0000000000007424))
(:eigmax, MethodError(LinearAlgebra.var"#eigvals!##kw"(), ((permute = true, scale = true), LinearAlgebra.eigvals!, Any[y[1,1] y[1,2]; y[2,1] y[2,2]]), 0x0000000000007424))
(:eigmin, MethodError(LinearAlgebra.var"#eigvals!##kw"(), ((permute = true, scale = true), LinearAlgebra.eigvals!, Any[y[1,1] y[1,2]; y[2,1] y[2,2]]), 0x0000000000007424))
(:eigvals, MethodError(LinearAlgebra.eigvals!, (Any[y[1,1] y[1,2]; y[2,1] y[2,2]],), 0x0000000000007424))
(:eigvecs, MethodError(LinearAlgebra.var"#eigen!##kw"(), ((permute = true, scale = true, sortby = LinearAlgebra.eigsortby), LinearAlgebra.eigen!, Any[y[1,1] y[1,2]; y[2,1] y[2,2]]), 0x0000000000007424))
(:factorize, MethodError(VariableRef, (1,), 0x0000000000007424))
(:hessenberg, MethodError(LinearAlgebra.hessenberg!, (Any[y[1,1] y[1,2]; y[2,1] y[2,2]],), 0x0000000000007424))
(:logabsdet, MethodError(VariableRef, (1,), 0x0000000000007424))
(:logdet, MethodError(VariableRef, (1,), 0x0000000000007424))
(:lu, MethodError(VariableRef, (1,), 0x0000000000007424))
(:lu!, MethodError(isless, (abs(y[1,1]), abs(y[2,1])), 0x0000000000007424))
(:nullspace, MethodError(AbstractFloat, (1,), 0x0000000000007424))
(:opnorm, MethodError(AbstractFloat, (0,), 0x0000000000007424))
(:pinv, MethodError(AbstractFloat, (1,), 0x0000000000007424))
(:qr, TypeError(:typeassert, "", NonlinearExpr, y[1,1]))
(:qr!, MethodError(convert, (VariableRef, 0), 0x0000000000007424))
(:rank, MethodError(AbstractFloat, (1,), 0x0000000000007424))
(:schur, MethodError(LinearAlgebra.schur!, (Any[y[1,1] y[1,2]; y[2,1] y[2,2]],), 0x0000000000007424))
(:svd, MethodError(LinearAlgebra.var"#svd!##kw"(), ((full = false, alg = LinearAlgebra.DivideAndConquer()), LinearAlgebra.svd!, Any[y[1,1] y[1,2]; y[2,1] y[2,2]]), 0x0000000000007424))
(:svdvals, MethodError(LinearAlgebra.svdvals!, (Any[y[1,1] y[1,2]; y[2,1] y[2,2]],), 0x0000000000007424))
(:tril, MethodError(convert, (VariableRef, 0), 0x0000000000007424))
(:tril!, MethodError(convert, (VariableRef, 0), 0x0000000000007424))
(:triu, MethodError(convert, (VariableRef, 0), 0x0000000000007424))
(:triu!, MethodError(convert, (VariableRef, 0), 0x0000000000007424)) No overflows, but do we want to add fallbacks for things like |
Let's go with this for now, and see what feedback we get? |
Closes #3467