manim icon indicating copy to clipboard operation
manim copied to clipboard

Fix Error when calling `.get_number_mobjects()` with no arguments in NumberLine

Open irvanalhaq9 opened this issue 7 months ago • 0 comments

Overview: What does this pull request change?

Fix #4244

Motivation and Explanation: Why and how do your changes improve the library?

Calling get_number_mobjects() in NumberLine without any arguments caused error.
This PR resolves this issue (see: #4244).

Changes

  • Introduced method get_numbers_to_display():
    • Extracted from the logic previously embedded in add_numbers().
  • Updated get_number_mobjects():
    • Uses get_numbers_to_display() when numbers is not provided.
  • Simplified add_numbers():
    • Moved the logic for determining which numbers to include and which numbers to exclude to the get_numbers_to_display() method. This allows add_number() to focus only on adding the number objects to the axis.
    • Delegates label creation to get_number_mobjects().
    • Removed redundant checks of font_size and label_constructor, as these are already handled inside get_number_mobject().

Links to added or changed documentation pages

No changes in the documentation: https://manimce--4248.org.readthedocs.build/en/4248/reference/manim.mobject.graphing.number_line.NumberLine.html#manim.mobject.graphing.number_line.NumberLine

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

irvanalhaq9 avatar May 13 '25 15:05 irvanalhaq9