Skip to content

Compare child counts in == and isapprox on ClippedPolygon - #375

Merged
gpeairs merged 3 commits into
mainfrom
gp/clipped-eq-children
Nov 9, 2026
Merged

gpeairs merged 3 commits into
mainfrom
gp/clipped-eq-children

Conversation

@gpeairs

@gpeairs gpeairs commented Nov 9, 2026

Copy link
Copy Markdown
Member

== and isapprox on ClippedPolygons compared the two polygon trees node by node with zip, which stops at the shorter list of children. A polygon compared equal to the same polygon plus an extra disjoint shape, or with a hole cut in it:

a = union2d(Rectangle(10, 10))
b = union2d([Rectangle(10, 10), Rectangle(Point(20, 0), Point(30, 10))])
holed = difference2d(Rectangle(10, 10), Rectangle(Point(2, 2), Point(8, 8)))
a == b, a ≈ b, a == holed, a ≈ holed   # were all true, now all false

Now both return false when the trees have different numbers of children at any level. Child order still matters, as before.

Not breaking: this fixes silently incorrect results.

Both methods walked the two polygon trees with zip, which stops at the
shorter child list, so a polygon compared equal to itself plus an extra
disjoint shape or hole. Return false when the child counts differ at any
node.
@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@gpeairs
gpeairs merged commit 54e458a into main Nov 9, 2026
11 checks passed
@gpeairs
gpeairs deleted the gp/clipped-eq-children branch November 9, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant