Add tests for polylabel utility #4269
Open
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.
Overview: What does this pull request change?
Add tests for polylabel utility.
In detail:
Polygon
andCell
, and methodpolylabel
from filemanim/utils/polylabel.py
Polygon.inside
in order to fix edge case behavior and decompose into smaller private methods. The former method would fail to recognize points in the right and up edges as inside the polygon.Polygon
class docstring descriptions.OpenGLMobject
methodsset_width
andstretch_to_fit_width
doctests.Motivation and Explanation: Why and how do your changes improve the library?
The polylabel utility is widely used in the project, but the existing tests were only indirectly testing these utilities. Therefore, adding unit tests can contribute to the robustness of the library.
Additionally, the implemented tests unmasked an edge case bug within the
Polygon.inside
method, leading to a fix and minor refactor.Links to added or changed documentation pages
There are no changes to documentation pages.
Further Information and Comments
There were two doctests failing in the main branch:
manim.mobject.opengl.opengl_mobject.OpenGLMobject.stretch_to_fit_width
manim.mobject.opengl.opengl_mobject.OpenGLMobject.set_width
The error was caused by comparison between python float and numpy float. I assumed that there was no problem checking against numpy float. Let me know if there are any objections.
Reviewer Checklist