Skip to content

AttributeError: NumberLine object has no attribute 'default_numbers_to_display' when calling get_number_mobjects() #4244

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

Closed
kevinnadar22 opened this issue May 11, 2025 · 2 comments · May be fixed by #4248

Comments

@kevinnadar22
Copy link

kevinnadar22 commented May 11, 2025

Description of bug / unexpected behavior

When attempting to use get_number_mobjects() on a NumberLine object, I encountered the following error:

AttributeError: NumberLine object has no attribute 'default_numbers_to_display'

It seems like the method get_number_mobjects() internally calls self.default_numbers_to_display(), but this method is either missing or no longer available in the current implementation of NumberLine.

Expected behavior

Calling get_number_mobjects() with no arguments should use default numbers (e.g., from x_range) to generate label mobjects.

How to reproduce the issue

  1. Create a NumberLine object.
  2. Call get_number_mobjects() without passing any explicit numbers.
  3. Run the scene.
Code for reproducing the problem
from manim import *

class IntroductionToComplexNumbers(Scene):
    def construct(self):
        # Create real number line
        real_number_line = NumberLine(
            x_range=[-5, 5, 1],
            length=10,
            include_tip=False,
        )
        real_number_line_labels = real_number_line.get_number_mobjects()
        self.add(real_number_line, *real_number_line_labels)

Logs

Terminal output

Logs

System specifications

System Details
Environment

* **OS:** Windows 11
* **Manim version:** (e.g., v0.19.0) 
* **Python version:** (e.g., 3.10)
* **Installation:** pip
@irvanalhaq9
Copy link
Contributor

irvanalhaq9 commented May 11, 2025

It seems that the method .default_numbers_to_display() has been removed from Manim Community, but the code wasn't updated accordingly.
If your goal is to display numbers along the number line, you can do either of the following:

  1. Use .add_numbers() after creating NumberLine object:

    class IntroductionToComplexNumbers(Scene):
        def construct(self):
            real_number_line = NumberLine(
                x_range=[-5, 5, 1],
                length=10,
                include_tip=False,
            )
            real_number_line.add_numbers()
            self.add(real_number_line)
  2. Or, set include_numbers=True directly in the constructor:

    class IntroductionToComplexNumbers(Scene):
        def construct(self):
            real_number_line = NumberLine(
                x_range=[-5, 5, 1],
                length=10,
                include_tip=False,
                include_numbers=True,
            )
            self.add(real_number_line)

For more details, see the documentation:
👉 NumberLine — Manim Documentation

@irvanalhaq9
Copy link
Contributor

Hi @kevinnadar22

I think this issue still needs to be addressed.

When users call .get_number_mobjects() or .get_labels() on a NumberLine object, it will still raise an AttributeError because .default_numbers_to_display() is being accessed but doesn't exist.

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 a pull request may close this issue.

2 participants