Skip to content

Commit 7782992

Browse files
committed
treat float precision error, add isapprox for Rects
1 parent 558b364 commit 7782992

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/primitives/rectangles.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,11 @@ end
505505
#
506506
# Equality
507507
#
508-
Base.:(==)(b1::Rect, b2::Rect) = minimum(b1) == minimum(b2) && widths(b1) == widths(b2)
508+
Base.:(==)(b1::Rect, b2::Rect) = origin(b1) == origin(b2) && widths(b1) == widths(b2)
509509

510-
Base.isequal(b1::Rect, b2::Rect) = b1 == b2
510+
function Base.isapprox(r1::Rect, r2::Rect; kwargs...)
511+
return isapprox(origin(r1), origin(r2); kwargs...) && isapprox(widths(r1), widths(r2); kwargs...)
512+
end
511513

512514
##
513515
# Rect2 decomposition

test/geometrytypes.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,16 @@ end
467467
# go higher dimensions than that.
468468
M = rand(Mat4f)
469469
ps = Point2f[M * Point(p..., 1, 1) for p in coordinates(r)]
470-
@test Rect2f(ps) == M * r
470+
@test Rect2f(ps) M * r
471471

472472
M = Mat2f(0.5, -0.3, 0.7, 1.5)
473473
ps = Point2f[M * p for p in coordinates(r)]
474-
@test Rect2f(ps) == M * r
474+
@test Rect2f(ps) M * r
475475

476476
r = Rect3f(-1, -2, -3, 2, 4, 1)
477477
M = rand(Mat4f)
478478
ps = Point3f[M * Point(p..., 1) for p in coordinates(r)]
479-
@test Rect3f(ps) == M * r
479+
@test Rect3f(ps) M * r
480480
end
481481

482482
# TODO: this is effectively 0-indexed... should it be?

0 commit comments

Comments
 (0)