Cannot create Point using example code
Closed this issue · 3 comments
minhvt98 commented
Description of bug / unexpected behavior
When I tried to run the example code in manim's docs for Point
I got the an error message saying AttributeError: 'Point' object has no attribute 'color'
for this paticular line
point = Point(location=[0.63 * np.random.randint(-4, 4), 0.37 * np.random.randint(-4, 4), 0], color=np.random.choice(colorList))
Expected behavior
Code should run normally
How to reproduce the issue
Code for reproducing the problem
from manim import *
class ExamplePoint(Scene):
def construct(self):
colorList = [RED, GREEN, BLUE, YELLOW]
for i in range(200):
point = Point(location=[0.63 * np.random.randint(-4, 4), 0.37 * np.random.randint(-4, 4), 0], color=np.random.choice(colorList))
self.add(point)
for i in range(200):
point = Point(location=[0.37 * np.random.randint(-4, 4), 0.63 * np.random.randint(-4, 4), 0], color=np.random.choice(colorList))
self.add(point)
self.add(point)
Logs
Terminal output
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\cli\render\commands.py:102 in │
│ render │
│ │
│ 99 │ │ │ │ for SceneClass in scene_classes_from_file(file): │
│ 100 │ │ │ │ │ with tempconfig({}): │
│ 101 │ │ │ │ │ │ scene = SceneClass(renderer) │
│ ❱ 102 │ │ │ │ │ │ rerun = scene.render() │
│ 103 │ │ │ │ │ if rerun or config["write_all"]: │
│ 104 │ │ │ │ │ │ renderer.num_plays = 0 │
│ 105 │ │ │ │ │ │ continue │
│ │
│ C:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\scene\scene.py:229 in render │
│ │
│ 226 │ │ """ │
│ 227 │ │ self.setup() │
│ 228 │ │ try: │
│ ❱ 229 │ │ │ self.construct() │
│ 230 │ │ except EndSceneEarlyException: │
│ 231 │ │ │ pass │
│ 232 │ │ except RerunSceneException as e: │
│ │
│ D:\manimce\point_test.py:7 in construct │
│ │
│ 4 │ def construct(self): │
│ 5 │ │ colorList = [RED, GREEN, BLUE, YELLOW] │
│ 6 │ │ for i in range(200): │
│ ❱ 7 │ │ │ point = Point(location=[0.63 * np.random.randint(-4, 4), 0.37 * np.random.ra │
│ 8 │ │ │ self.add(point) │
│ 9 │ │ for i in range(200): │
│ 10 │ │ │ point = Point(location=[0.37 * np.random.randint(-4, 4), 0.63 * np.random.ra │
│ │
│ C:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\mobject\types\point_cloud_mobject.p │
│ y:376 in __init__ │
│ │
│ 373 │ │
│ 374 │ def __init__(self, location=ORIGIN, color=BLACK, **kwargs): │
│ 375 │ │ self.location = location │
│ ❱ 376 │ │ super().__init__(color=color, **kwargs) │
│ 377 │ │
│ 378 │ def init_points(self): │
│ 379 │ │ self.reset_points() │
│ │
│ C:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\mobject\types\point_cloud_mobject.p │
│ y:60 in __init__ │
│ │
│ 57 │ │
│ 58 │ def __init__(self, stroke_width=DEFAULT_STROKE_WIDTH, **kwargs): │
│ 59 │ │ self.stroke_width = stroke_width │
│ ❱ 60 │ │ super().__init__(**kwargs) │
│ 61 │ │
│ 62 │ def reset_points(self): │
│ 63 │ │ self.rgbas = np.zeros((0, 4)) │
│ │
│ C:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\mobject\opengl\opengl_mobject.py:15 │
│ 7 in __init__ │
│ │
│ 154 │ │ self.init_data() │
│ 155 │ │ self.init_updaters() │
│ 156 │ │ # self.init_event_listners() │
│ ❱ 157 │ │ self.init_points() │
│ 158 │ │ self.color = ManimColor.parse(color) │
│ 159 │ │ self.init_colors() │
│ 160 │
│ │
│ C:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\mobject\types\point_cloud_mobject.p │
│ y:380 in init_points │
│ │
│ 377 │ │
│ 378 │ def init_points(self): │
│ 379 │ │ self.reset_points() │
│ ❱ 380 │ │ self.generate_points() │
│ 381 │ │ self.set_points([self.location]) │
│ 382 │ │
│ 383 │ def generate_points(self): │
│ │
│ C:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\mobject\types\point_cloud_mobject.p │
│ y:384 in generate_points │
│ │
│ 381 │ │ self.set_points([self.location]) │
│ 382 │ │
│ 383 │ def generate_points(self): │
│ ❱ 384 │ │ self.add_points([self.location]) │
│ 385 │
│ │
│ C:\Users\Asus\anaconda3\envs\manimce\Lib\site-packages\manim\mobject\types\point_cloud_mobject.p │
│ y:81 in add_points │
│ │
│ 78 │ │ num_new_points = len(points) │
│ 79 │ │ self.points = np.append(self.points, points, axis=0) │
│ 80 │ │ if rgbas is None: │
│ ❱ 81 │ │ │ color = ManimColor(color) if color else self.color │
│ 82 │ │ │ rgbas = np.repeat([color_to_rgba(color, alpha)], num_new_points, axis=0) │
│ 83 │ │ elif len(rgbas) != len(points): │
│ 84 │ │ │ raise ValueError("points and rgbas must have same length") │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Point' object has no attribute 'color'
System specifications
System Details
- OS : Windows 11 Home Single Language version 23H2, build 22631.4317
- RAM: 16GB
- Python version: 3.12.7
- Visual Studio Code version: 1.95.3
- conda version: 23.7.4
- Installed modules:
Package Version
-------------------- -------------
asttokens 2.0.5
backcall 0.2.0
black 24.10.0
Brotli 1.1.0
build 1.2.2.post1
CacheControl 0.14.1
cairocffi 1.7.1
certifi 2024.8.30
cffi 1.17.1
charset-normalizer 3.4.0
cleo 2.1.0
click 8.1.7
click-default-group 1.2.4
cloup 3.0.5
colorama 0.4.6
colour 0.1.5
comm 0.2.2
commonmark 0.9.1
crashtest 0.4.1
debugpy 1.8.8
decorator 5.1.1
distlib 0.3.9
dulwich 0.21.3
executing 0.8.3
fastjsonschema 2.20.0
ffmpeg 1.4
filelock 3.16.1
future 1.0.0
glcontext 3.0.0
h2 4.1.0
hpack 4.0.0
hyperframe 6.0.1
idna 3.10
importlib_metadata 8.5.0
importlib_resources 6.4.5
installer 0.7.0
ipykernel 6.29.5
ipython 8.27.0
isosurfaces 0.1.2
jaraco.classes 3.4.0
jedi 0.19.1
jupyter_client 8.6.3
jupyter_core 5.7.2
keyring 24.3.1
manim 0.18.1
ManimPango 0.6.0
mapbox_earcut 1.0.1
markdown-it-py 3.0.0
matplotlib-inline 0.1.6
mdurl 0.1.2
moderngl 5.11.1
moderngl-window 2.4.1
more-itertools 10.5.0
msgpack 1.1.0
multipledispatch 0.6.0
mypy-extensions 1.0.0
nest_asyncio 1.6.0
networkx 3.4.2
numpy 1.26.4
packaging 24.2
pangocairocffi 0.4.0
pangocffi 0.8.0
parso 0.8.3
pathspec 0.12.1
pexpect 4.9.0
pickleshare 0.7.5
pillow 11.0.0
pip 24.2
pkginfo 1.11.2
platformdirs 4.3.6
poetry 1.8.4
poetry-core 1.9.1
poetry-plugin-export 1.8.0
progressbar 2.5
prompt-toolkit 3.0.43
psutil 6.1.0
ptyprocess 0.7.0
pure-eval 0.2.2
pycairo 1.27.0
pycparser 2.22
pydub 0.25.1
pyglet 1.5.27
Pygments 2.18.0
pyproject_hooks 1.2.0
pyrr 0.10.3
PySocks 1.7.1
python-dateutil 2.9.0
pywin32 307
pywin32-ctypes 0.2.3
PyYAML 6.0.2
pyzmq 26.2.0
RapidFuzz 3.10.1
requests 2.32.3
requests-toolbelt 1.0.0
rich 13.9.4
scipy 1.14.1
screeninfo 0.8.1
setuptools 75.1.0
shellingham 1.5.4
six 1.16.0
skia-pathops 0.8.0.post2
srt 3.5.3
stack-data 0.2.0
svgelements 1.9.6
tomli 2.1.0
tomlkit 0.13.2
tornado 6.4.1
tqdm 4.67.0
traitlets 5.14.3
trove-classifiers 2024.10.21.16
typing_extensions 4.12.2
urllib3 2.2.3
virtualenv 20.27.1
watchdog 6.0.0
wcwidth 0.2.13
wheel 0.44.0
win_inet_pton 1.1.0
zipp 3.21.0
zstandard 0.23.0
minhvt98 commented
For some unknown reason I can no longer replicate this myself so I'd close this one.
drio commented
I can replicate with this (notice that I use the opengl rendered):
Scene's code:
from manim import *
class Foo(Scene):
def construct(self):
point = Point().scale(1)
self.add(point)
self.interactive_embed()
Run with:
manim -pql --renderer=opengl scene.py
Manim Community v0.18.1
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/drio/dev/github.com/ManimCommunity/manim/manim/cli/render/commands.py:107 in render │
│ │
│ 104 │ │ │ │ for SceneClass in scene_classes_from_file(file): │
│ 105 │ │ │ │ │ with tempconfig({}): │
│ 106 │ │ │ │ │ │ scene = SceneClass(renderer) │
│ ❱ 107 │ │ │ │ │ │ rerun = scene.render() │
│ 108 │ │ │ │ │ if rerun or config["write_all"]: │
│ 109 │ │ │ │ │ │ renderer.num_plays = 0 │
│ 110 │ │ │ │ │ │ continue │
│ │
│ /home/drio/dev/github.com/ManimCommunity/manim/manim/scene/scene.py:235 in render │
│ │
│ 232 │ │ """ │
│ 233 │ │ self.setup() │
│ 234 │ │ try: │
│ ❱ 235 │ │ │ self.construct() │
│ 236 │ │ except EndSceneEarlyException: │
│ 237 │ │ │ pass │
│ 238 │ │ except RerunSceneException: │
│ │
│ /home/drio/dev/github.com/ManimCommunity/manim/project/scene.py:12 in construct │
│ │
│ 9 │ │ text = Text("drio", color=PINK, font_size=144).scale(1) │
│ 10 │ │ self.add(text) │
│ 11 │ │ │
│ ❱ 12 │ │ point = Point().scale(1) │
│ 13 │ │ self.add(point) │
│ 14 │ │ │
│ 15 │ │ #self.set_camera_orientation(phi=75 * DEGREES, theta=45 * DEGREES) │
│ │
│ /home/drio/dev/github.com/ManimCommunity/manim/manim/mobject/types/point_cloud_mobject.py:412 in │
│ __init__ │
│ │
│ 409 │ │ self, location: Vector3D = ORIGIN, color: ManimColor = BLACK, **kwargs: Any │
│ 410 │ ) -> None: │
│ 411 │ │ self.location = location │
│ ❱ 412 │ │ super().__init__(color=color, **kwargs) │
│ 413 │ │
│ 414 │ def init_points(self) -> None: │
│ 415 │ │ self.reset_points() │
│ │
│ /home/drio/dev/github.com/ManimCommunity/manim/manim/mobject/types/point_cloud_mobject.py:72 in │
│ __init__ │
│ │
│ 69 │ │
│ 70 │ def __init__(self, stroke_width: int = DEFAULT_STROKE_WIDTH, **kwargs: Any) -> None: │
│ 71 │ │ self.stroke_width = stroke_width │
│ ❱ 72 │ │ super().__init__(**kwargs) │
│ 73 │ │
│ 74 │ def reset_points(self) -> Self: │
│ 75 │ │ self.rgbas = np.zeros((0, 4)) │
│ │
│ /home/drio/dev/github.com/ManimCommunity/manim/manim/mobject/opengl/opengl_mobject.py:182 in │
│ __init__ │
│ │
│ 179 │ │ self.init_data() │
│ 180 │ │ self.init_updaters() │
│ 181 │ │ # self.init_event_listners() │
│ ❱ 182 │ │ self.init_points() │
│ 183 │ │ self.color = ManimColor.parse(color) │
│ 184 │ │ self.init_colors() │
│ 185 │
│ │
│ /home/drio/dev/github.com/ManimCommunity/manim/manim/mobject/types/point_cloud_mobject.py:416 in │
│ init_points │
│ │
│ 413 │ │
│ 414 │ def init_points(self) -> None: │
│ 415 │ │ self.reset_points() │
│ ❱ 416 │ │ self.generate_points() │
│ 417 │ │ self.set_points([self.location]) │
│ 418 │ │
│ 419 │ def generate_points(self) -> None: │
│ │
│ /home/drio/dev/github.com/ManimCommunity/manim/manim/mobject/types/point_cloud_mobject.py:420 in │
│ generate_points │
│ │
│ 417 │ │ self.set_points([self.location]) │
│ 418 │ │
│ 419 │ def generate_points(self) -> None: │
│ ❱ 420 │ │ self.add_points(np.array([self.location])) │
│ 421 │
│ │
│ /home/drio/dev/github.com/ManimCommunity/manim/manim/mobject/types/point_cloud_mobject.py:99 in │
│ add_points │
│ │
│ 96 │ │ num_new_points = len(points) │
│ 97 │ │ self.points = np.append(self.points, points, axis=0) │
│ 98 │ │ if rgbas is None: │
│ ❱ 99 │ │ │ color = ManimColor(color) if color else self.color │
│ 100 │ │ │ rgbas = np.repeat([color_to_rgba(color, alpha)], num_new_points, axis=0) │
│ 101 │ │ elif len(rgbas) != len(points): │
│ 102 │ │ │ raise ValueError("points and rgbas must have same length") │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Point' object has no attribute 'color'
uwezi commented
You should make clear already in the title that this is happening when using the OpenGL renderer!