Skip to content

Bug in isapprox of functions #1483

@odow

Description

@odow

This is a real doozy. I thought I was going insane...

julia> using MathOptInterface, Test

julia> const MOI = MathOptInterface
MathOptInterface

julia> x = MOI.ScalarQuadraticFunction{Float16}(
           MOI.ScalarAffineTerm{Float16}[], 
           MOI.ScalarQuadraticTerm{Float16}[], 
           Float16(0.0),
       );

julia> y = MOI.ScalarQuadraticFunction{Float16}(
           MOI.ScalarAffineTerm{Float16}[
               MOI.ScalarAffineTerm{Float16}(Float16(1.0), MOI.VariableIndex(1234))
           ], 
           MOI.ScalarQuadraticTerm{Float16}[], 
           Float16(0.0),
       );

julia> z = MOI.ScalarQuadraticFunction{Float16}(
           MOI.ScalarAffineTerm{Float16}[], 
           MOI.ScalarQuadraticTerm{Float16}[], 
           Float16(0.0),
       );

julia> @test x  y  # ??? What ??? This should fail.
Test Passed

julia> @test y  x  # Good
Test Failed at REPL[18]:1
  Expression: y  x
   Evaluated: MathOptInterface.ScalarQuadraticFunction{Float16}(MathOptInterface.ScalarAffineTerm{Float16}[MathOptInterface.ScalarAffineTerm{Float16}(Float16(1.0), MathOptInterface.VariableIndex(1234))], MathOptInterface.ScalarQuadraticTerm{Float16}[], Float16(0.0))  MathOptInterface.ScalarQuadraticFunction{Float16}(MathOptInterface.ScalarAffineTerm{Float16}[], MathOptInterface.ScalarQuadraticTerm{Float16}[], Float16(0.0))
ERROR: There was an error during testing

julia> @test x  z  # Good 
Test Passed

julia> @test z  x  # Good
Test Passed

julia> @test y  z  # Good 
Test Failed at REPL[21]:1
  Expression: y  z
   Evaluated: MathOptInterface.ScalarQuadraticFunction{Float16}(MathOptInterface.ScalarAffineTerm{Float16}[MathOptInterface.ScalarAffineTerm{Float16}(Float16(1.0), MathOptInterface.VariableIndex(1234))], MathOptInterface.ScalarQuadraticTerm{Float16}[], Float16(0.0))  MathOptInterface.ScalarQuadraticFunction{Float16}(MathOptInterface.ScalarAffineTerm{Float16}[], MathOptInterface.ScalarQuadraticTerm{Float16}[], Float16(0.0))
ERROR: There was an error during testing

julia> @test z  y  # ??? What ???
Test Passed

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions