manim
manim copied to clipboard
Fix Error when calling `.get_number_mobjects()` with no arguments in NumberLine
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().
- Extracted from the logic previously embedded in
- Updated
get_number_mobjects():- Uses
get_numbers_to_display()whennumbersis not provided.
- Uses
- 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 allowsadd_number()to focus only on adding the number objects to the axis. - Delegates label creation to
get_number_mobjects(). - Removed redundant checks of
font_sizeandlabel_constructor, as these are already handled insideget_number_mobject().
- Moved the logic for determining which numbers to include and which numbers to exclude to the
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