Open
Conversation
Split functions into smaller, reusable ones, added input validation, optimized Voronoi calculations, improved error handling, and enhanced docstrings for better readability and maintenance.
Author
|
I have read the CLA Document and I sign the CLA. |
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.
Description
Refactored soccer pitch drawing code to improve modularity, performance, and reliability by splitting functions, adding input validation, optimizing Voronoi calculations, enhancing error handling, and improving docstrings. No specific issue fixed; changes driven by code quality improvement (inspired by Roboflow's sports repo: https://github.com/roboflow/sports). Dependencies:
numpy,opencv-python,supervision.Type of change
How has this change been tested, please provide a testcase or example of how you tested the change?
Tested by running
draw_pitch,draw_points_on_pitch,draw_paths_on_pitch, anddraw_pitch_voronoi_diagramwith sampleSoccerPitchConfigurationand syntheticxydata (e.g.,np.array([[10, 20], [30, 40]])for points, paths with 2+ points). Verified output images for correct pitch rendering, point/path placement, and Voronoi diagram accuracy using OpenCV'scv2.imshow.Any specific deployment considerations
None; changes are backward-compatible and require no new secrets or costs.
Docs
Updated docstrings in all functions (
draw_pitch,draw_points_on_pitch,draw_paths_on_pitch,draw_pitch_voronoi_diagram) to clarify parameter descriptions, specify array shapes (e.g.,xyas(n, 2)), detail return value formats (np.ndarray, shape, dtype), and include exception information.