Repository navigation
Raise ValueError from circumcircle for collinear or coincident points - #9434
Merged
Merged
Conversation
When the three input points are collinear or coincident the denominator of the parametric solution is zero and the function crashed with a bare ZeroDivisionError. Raise a descriptive ValueError instead so callers can tell bad input apart from real arithmetic bugs. minimum_bounding_circle propagates the same ValueError for degenerate (all-collinear) point sets. Adds tests for the rejected degenerate inputs and for the non-degenerate results of circumcircle and minimum_bounding_circle. Signed-off-by: Charan Rathore <[email protected]>
Contributor
|
@kuzeyron This is ready to merge. The change is correct (the new test fails on master and passes with the fix, CI is green) and low risk. It's a low-value fix, and nobody has reported the crash. |
kuzeyron
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9432.
circumcircle solves for the circumcenter with a parametric formula whose denominator is zero for collinear or coincident input points, so those inputs crashed with a bare ZeroDivisionError. This raises a descriptive ValueError instead, which lets callers tell degenerate input apart from an internal arithmetic bug. minimum_bounding_circle propagates the same ValueError for all-collinear point sets (it hit the same ZeroDivisionError before; the circumcircle-based path has no meaningful answer for a degenerate set, so a clear error beats a cryptic one).
Tests: adds kivy/tests/test_geometry.py covering the rejected degenerate inputs and the non-degenerate results of circumcircle and minimum_bounding_circle. Verified locally by loading the real kivy/vector.py and kivy/geometry.py directly (the full suite needs the compiled graphics extensions, which CI covers): 3 passed on the patched code, and the collinear/coincident cases raise ZeroDivisionError on unpatched master.