Skip to content

NumberLine.get_number_mobjects() not working #2473

@leleogere

Description

@leleogere

Description of bug / unexpected behavior

When we call NumberLine.get_number_mobjects() without parameters, it tries to call .default_numbers_to_display() which doesn't seem to exist.

Expected behavior

I would expect that this function would return a group of the numbers of the number line (if I understand correctly its name).

How to reproduce the issue

Code for reproducing the problem
def construct(self):
    line = NumberLine(include_numbers=True)
    numbers = line.get_number_mobjects()
    self.add(line)

Logs

Terminal output
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│                                                                              │
│ /usr/local/lib/python3.8/site-packages/manim/cli/render/commands.py:139 in   │
│ render                                                                       │
│                                                                              │
│   136 │   │   for SceneClass in scene_classes_from_file(file):               │
│   137 │   │   │   try:                                                       │
│   138 │   │   │   │   scene = SceneClass()                                   │
│ ❱ 139 │   │   │   │   scene.render()                                         │
│   140 │   │   │   except Exception:                                          │
│   141 │   │   │   │   error_console.print_exception()                        │
│   142 │   │   │   │   sys.exit(1)                                            │
│ /usr/local/lib/python3.8/site-packages/manim/scene/scene.py:219 in render    │
│                                                                              │
│    216 │   │   """                                                           │
│    217 │   │   self.setup()                                                  │
│    218 │   │   try:                                                          │
│ ❱  219 │   │   │   self.construct()                                          │
│    220 │   │   except EndSceneEarlyException:                                │
│    221 │   │   │   pass                                                      │
│    222 │   │   except RerunSceneException as e:                              │
│                                                                              │
│ /manim/script.py:5 in construct                                              │
│                                                                              │
│   2 class Manimation(Scene):                                                 │
│   3 │   def construct(self):                                                 │
│   4 │     line = NumberLine(include_numbers=True)                            │
│ ❱ 5 │     numbers = line.get_number_mobjects()                               │
│   6 │     self.add(line)                                                     │
│                                                                              │
│ /usr/local/lib/python3.8/site-packages/manim/mobject/number_line.py:438 in   │
│ get_number_mobjects                                                          │
│                                                                              │
│   435 │                                                                      │
│   436 │   def get_number_mobjects(self, *numbers, **kwargs) -> VGroup:       │
│   437 │   │   if len(numbers) == 0:                                          │
│ ❱ 438 │   │   │   numbers = self.default_numbers_to_display()                │
│   439 │   │   return VGroup([self.get_number_mobject(number, **kwargs) for n │
│   440 │                                                                      │
│   441 │   def get_labels(self) -> VGroup:                                    │
│                                                                              │
│ /usr/local/lib/python3.8/site-packages/manim/mobject/mobject.py:623 in       │
│ __getattr__                                                                  │
│                                                                              │
│    620 │   │   │   return types.MethodType(setter, self)                     │
│    621 │   │                                                                 │
│    622 │   │   # Unhandled attribute, therefore error                        │
│ ❱  623 │   │   raise AttributeError(f"{type(self).__name__} object has no at │
│    624 │                                                                     │
│    625 │   @property                                                         │
│    626 │   def width(self):                                                  │
╰──────────────────────────────────────────────────────────────────────────────╯
AttributeError: NumberLine object has no attribute 'default_numbers_to_display'

System specifications

System Details
  • OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)):
  • RAM:
  • Python version (python/py/python3 --version):
  • Installed modules (provide output from pip list):
PASTE HERE
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020):
  • Installed LaTeX packages:
FFMPEG

Output of ffmpeg -version:

PASTE HERE

Additional comments

It looks like it doesn't work when providing parameters either, but for another reason. I did not investigate this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue:bugSomething isn't working... For use in issues

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions