diff --git a/src/JuMP.jl b/src/JuMP.jl index 67dcae18c14..7c1659c75a6 100644 --- a/src/JuMP.jl +++ b/src/JuMP.jl @@ -372,6 +372,12 @@ else end Base.isempty(::AbstractJuMPScalar) = false +# Check if two arrays of AbstractJuMPScalars are equal. Useful for testing. +function isequal_canonical(x::AbstractArray{<:JuMP.AbstractJuMPScalar}, + y::AbstractArray{<:JuMP.AbstractJuMPScalar}) + return size(x) == size(y) && all(JuMP.isequal_canonical.(x, y)) +end + """ AbstractShape diff --git a/test/runtests.jl b/test/runtests.jl index 9f99cb4937f..27e2f47e05b 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -22,12 +22,6 @@ const MOI = MathOptInterface const MOIT = MOI.Test const MOIU = MOI.Utilities -# TODO: This should be defined in JuMP source with the other versions of -# isequal_canonical. -function JuMP.isequal_canonical(x::AbstractArray{<:JuMP.AbstractJuMPScalar}, y::AbstractArray{<:JuMP.AbstractJuMPScalar}) - size(x) == size(y) && all(JuMP.isequal_canonical.(x, y)) -end - macro test_expression(expr) esc(quote @test JuMP.isequal_canonical(@expression(m, $expr), $expr)