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

Fix Bridges.runtests when model has no variable #2499

Merged
merged 7 commits into from
May 13, 2024
Merged

Fix Bridges.runtests when model has no variable #2499

merged 7 commits into from
May 13, 2024

Conversation

blegat
Copy link
Member

@blegat blegat commented May 10, 2024

Needed for jump-dev/SumOfSquares.jl#296

  • Needs tests

Without the fix of this PR, the added tests throws

test_runtests: Error During Test at /home/blegat/.julia/dev/MathOptInterface/src/Bridges/Bridges.jl:286
  Test threw exception
  Expression: MOI.get(model, attr, x)  primal_start
  MethodError: no method matching zero(::Type{Any})
  
  Closest candidates are:
    zero(::Type{Union{Missing, T}}) where T
     @ Base missing.jl:105
    zero(::Type{Union{}}, Any...)
     @ Base number.jl:310
    zero(::Type{Missing})
     @ Base missing.jl:104
    ...
  
  Stacktrace:
   [1] zero(::Type{Any})
     @ Base ./missing.jl:106
   [2] norm(itr::Vector{Any}, p::Int64)
     @ LinearAlgebra ~/.julia/juliaup/julia-1.10.3+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:596
   [3] isapprox(x::Vector{Any}, y::Vector{Float64}; atol::Int64, rtol::Float64, nans::Bool, norm::typeof(LinearAlgebra.norm))
     @ LinearAlgebra ~/.julia/juliaup/julia-1.10.3+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:1789
   [4] isapprox(x::Vector{Any}, y::Vector{Float64})
     @ LinearAlgebra ~/.julia/juliaup/julia-1.10.3+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:1785
   [5] eval_test(evaluated::Expr, quoted::Expr, source::LineNumberNode, negate::Bool)
     @ Test ~/.julia/juliaup/julia-1.10.3+0.x64.linux.gnu/share/julia/stdlib/v1.10/Test/src/Test.jl:355
   [6] macro expansion
     @ ~/.julia/juliaup/julia-1.10.3+0.x64.linux.gnu/share/julia/stdlib/v1.10/Test/src/Test.jl:669 [inlined]
   [7] runtests(Bridge::Type{MathOptInterface.Bridges.Constraint.GreaterToLessBridge}, input_fn::Main.TestConstraintFlipSign.var"#59#61", output_fn::Main.TestConstraintFlipSign.var"#60#62"; variable_start::Float64, constraint_start::Float64, eltype::Type, print_inner_model::Bool)
     @ MathOptInterface.Bridges ~/.julia/dev/MathOptInterface/src/Bridges/Bridges.jl:286

src/Bridges/Bridges.jl Outdated Show resolved Hide resolved
@blegat blegat changed the base branch from master to od/empty-vector-attr May 12, 2024 06:46
@blegat blegat changed the title Fix Bridges.runtests when model has not variable Fix Bridges.runtests when model has no variable May 12, 2024
@blegat
Copy link
Member Author

blegat commented May 12, 2024

I rebased to check, https://github.com/jump-dev/MathOptInterface.jl/pull/2501does not fix the error

@odow odow force-pushed the od/empty-vector-attr branch from 4b0b108 to 37fcc40 Compare May 12, 2024 20:57
@odow
Copy link
Member

odow commented May 12, 2024

Correct. That PR was to fix the Union{}[] return type, but it doesn't fix norm(::Vector{Any}). I'll take a look at this.

Base automatically changed from od/empty-vector-attr to master May 13, 2024 00:18
@odow odow merged commit 8742ceb into master May 13, 2024
17 of 18 checks passed
@odow odow deleted the bl/no_var branch May 13, 2024 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants