Skip to content

Add tests for polylabel utility #4269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

giolucasd
Copy link

@giolucasd giolucasd commented Jun 5, 2025

Overview: What does this pull request change?

Add tests for polylabel utility.

In detail:

  • Adds tests for classes Polygon and Cell, and method polylabel from file manim/utils/polylabel.py
  • Refactor the method 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.
  • Configure coverage to ignore type checking blocks, since it would always be considered uncovered.
  • Improve Polygon class docstring descriptions.
  • Fix class OpenGLMobject methods set_width and stretch_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:

  • method manim.mobject.opengl.opengl_mobject.OpenGLMobject.stretch_to_fit_width
  • method 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

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

1 participant