Skip to content

Commit

Permalink
fixed comparison between RayVectors; comparison between PointVector a…
Browse files Browse the repository at this point in the history
…nd RayVector now throws an error
  • Loading branch information
alexej-jordan committed Oct 17, 2024
1 parent 103439a commit f27a035
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/PolyhedralGeometry/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 105 in src/PolyhedralGeometry/iterators.jl

View check run for this annotation

Codecov / codecov/patch

src/PolyhedralGeometry/iterators.jl#L105

Added line #L105 was not covered by tests

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
Expand Down
5 changes: 4 additions & 1 deletion test/PolyhedralGeometry/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit f27a035

Please sign in to comment.