Skip to content

Return false from isapprox on Point arrays of different sizes - #374

Merged
gpeairs merged 2 commits into
mainfrom
gp/isapprox-length
Nov 9, 2026
Merged

gpeairs merged 2 commits into
mainfrom
gp/isapprox-length

Conversation

@gpeairs

@gpeairs gpeairs commented Nov 9, 2026

Copy link
Copy Markdown
Member

isapprox on arrays of Points compared elements pairwise with zip, which stops at the shorter array, so only the common prefix was checked:

p, q = Point(1.0, 2.0), Point(3.0, 4.0)
isapprox(Point{Float64}[], [p])   # was true, now false
isapprox([p], [p, q, q])          # was true, now false

Now arrays of different sizes compare false, like ==, instead of throwing DimensionMismatch like Base's array isapprox. isapprox on Polygons uses this method, so polygons with different numbers of vertices are no longer approximately equal when one's vertices are a prefix of the other's.

The elementwise tolerance is unchanged. Removing this method in favor of Base's norm-based array isapprox is part of GH#300 (#49) for 2.0.

Not breaking: this fixes silently incorrect results.

zip stopped at the shorter array, so only the common prefix was compared
and an empty array was approximately equal to any other.
@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 63f08b0 into main Nov 9, 2026
11 checks passed
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