ManimCommunity / ManimCommunity/manim

`NumberLine.get_number_mobjects()` not working

Open
#2,473 4 comments 0 reactions 0 assignees View on GitHub
issue:bug
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## 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

```py
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.

Contributor guide

Open the contributing guide

Research direction

Start in mobject/number_line.py at NumberLine.get_number_mobjects(), using the reproduction snippet to inspect the no-argument failure. Check how the method is expected to select numbers and how explicit parameters behave. Done means the method returns the requested number mobjects without raising the reported AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.