diff --git a/src/PolyhedralGeometry/iterators.jl b/src/PolyhedralGeometry/iterators.jl index 800cd2495352..f8ab731dbecd 100644 --- a/src/PolyhedralGeometry/iterators.jl +++ b/src/PolyhedralGeometry/iterators.jl @@ -93,22 +93,19 @@ function Base.:(==)(x::RayVector, y::RayVector) ix == iy || return false isnothing(ix) && return true r = ay[iy]//ax[ix] + r < zero(r) && return false return (r .* ax == ay) end function Base.:(==)(x::RayVector, y::AbstractVector) - try - ry = ray_vector(coefficient_field(x), y) - return x == ry - catch - return false - end + ry = ray_vector(coefficient_field(x), y) + return x == ry end Base.:(==)(x::AbstractVector, y::RayVector) = y == x -Base.:(==)(::PointVector, ::RayVector) = false -Base.:(==)(::RayVector, ::PointVector) = false +Base.:(==)(::PointVector, ::RayVector) = throw(ArgumentError("Cannot compare PointVector to RayVector")) +Base.:(==)(::RayVector, ::PointVector) = throw(ArgumentError("Cannot compare PointVector to RayVector")) ################################################################################ ######## Halfspaces and Hyperplanes diff --git a/test/PolyhedralGeometry/types.jl b/test/PolyhedralGeometry/types.jl index 3b60977be5a0..ada8376422c7 100644 --- a/test/PolyhedralGeometry/types.jl +++ b/test/PolyhedralGeometry/types.jl @@ -59,7 +59,7 @@ @test *(g(3), A) == 3 * a let Ao = other(g, a) - @test A != Ao + @test_throws ArgumentError A == Ao end end @@ -77,6 +77,9 @@ @test 5 * A == A @test fun(f, 5 * a) == A @test A == fun(f, 5 * a) + @test -5 * A != A + @test fun(f, -5 * a) != A + @test A != fun(f, -5 * a) end if f != ENF