ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
26.26k stars 1.8k forks source link

Line3D does not work #3346

Closed atamulis closed 1 year ago

atamulis commented 1 year ago

Description of bug / unexpected behavior

I am trying to learn how to use manim. I am interested in 3D plots, so I started going through the examples in the reference. So I tried the example in the documentation, https://docs.manim.community/en/stable/reference/manim.mobject.three_d.three_dimensions.Line3D.html . It led to an error,

TypeError: Scene.init() got an unexpected keyword argument 'start'

Expected behavior

I expected the given example to run.

How to reproduce the issue

Copy the example into a file and run manim on it.

Code for reproducing the problem ```py from manim import * class Line3D(ThreeDScene): def construct(self): axes = ThreeDAxes() line = Line3D(start=np.array([0, 0, 0]), end=np.array([2, 2, 2])) self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) self.add(axes, line) ```

Additional media files

Images/GIFs

Logs

Terminal output ```$ manim -ql -v DEBUG test1.py Manim Community v0.17.3 ╭───────────────────── Traceback (most recent call last) ──────────────────────╮ │ /usr/local/lib/python3.10/dist-packages/manim/cli/render/commands.py:115 in │ │ render │ │ │ │ 112 │ │ │ try: │ │ 113 │ │ │ │ with tempconfig({}): │ │ 114 │ │ │ │ │ scene = SceneClass() │ │ ❱ 115 │ │ │ │ │ scene.render() │ │ 116 │ │ │ except Exception: │ │ 117 │ │ │ │ error_console.print_exception() │ │ 118 │ │ │ │ sys.exit(1) │ │ │ │ /usr/local/lib/python3.10/dist-packages/manim/scene/scene.py:223 in render │ │ │ │ 220 │ │ """ │ │ 221 │ │ self.setup() │ │ 222 │ │ try: │ │ ❱ 223 │ │ │ self.construct() │ │ 224 │ │ except EndSceneEarlyException: │ │ 225 │ │ │ pass │ │ 226 │ │ except RerunSceneException as e: │ │ │ │ /home/andrius/Manim/planes_test/test1.py:6 in construct │ │ │ │ 3 class Line3D(ThreeDScene): │ │ 4 │ def construct(self): │ │ 5 │ │ axes = ThreeDAxes() │ │ ❱ 6 │ │ line = Line3D(start=np.array([0, 0, 0]), end=np.array([2, 2, 2] │ │ 7 │ │ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREE │ │ 8 │ │ self.add(axes, line) │ │ 9 │ │ │ │ /usr/local/lib/python3.10/dist-packages/manim/scene/three_d_scene.py:53 in │ │ __init__ │ │ │ │ 50 │ │ self.default_angled_camera_orientation_kwargs = ( │ │ 51 │ │ │ default_angled_camera_orientation_kwargs │ │ 52 │ │ ) │ │ ❱ 53 │ │ super().__init__(camera_class=camera_class, **kwargs) │ │ 54 │ │ │ 55 │ def set_camera_orientation( │ │ 56 │ │ self, │ ╰──────────────────────────────────────────────────────────────────────────────╯ TypeError: Scene.__init__() got an unexpected keyword argument 'start' ```

System specifications

System Details ``` Linux Mint 21.2 15 Gi RAM Python 3.10.12 $ pip list Package Version ----------------------- ---------------- appdirs 1.4.4 apt-clone 0.2.1 apturl 0.5.2 attrs 21.2.0 beautifulsoup4 4.10.0 beniget 0.4.1 blinker 1.4 Brlapi 0.8.3 Brotli 1.0.9 certifi 2020.6.20 chardet 4.0.0 charset-normalizer 3.2.0 click 8.0.3 click-default-group 1.2.4 cloup 0.13.1 colorama 0.4.4 colour 0.1.5 command-not-found 0.3 configobj 5.0.6 cryptography 3.4.8 cupshelpers 1.0 cycler 0.11.0 dbus-python 1.2.18 decorator 5.1.1 defer 1.0.6 distro 1.7.0 dnspython 2.1.0 eyeD3 0.8.10 filelock 3.6.0 fonttools 4.29.1 fs 2.4.12 gast 0.5.2 glcontext 2.4.0 gmpy2 2.1.2 grpcio 1.30.2 html5lib 1.1 httplib2 0.20.2 idna 3.3 ifaddr 0.1.7 IMDbPY 2021.4.18 importlib-metadata 4.6.4 iniconfig 1.1.1 isosurfaces 0.1.0 jeepney 0.7.1 keyring 23.5.0 kiwisolver 1.3.2 launchpadlib 1.10.16 lazr.restfulclient 0.14.4 lazr.uri 1.0.6 louis 3.20.0 lxml 4.8.0 lz4 3.1.3+dfsg macaroonbakery 1.3.1 Mako 1.1.3 manim 0.17.3 ManimPango 0.4.3 mapbox-earcut 1.0.1 Markdown 3.3.6 markdown-it-py 3.0.0 MarkupSafe 2.0.1 matplotlib 3.5.1 mdurl 0.1.2 moderngl 5.8.2 moderngl-window 2.4.4 more-itertools 8.10.0 mpmath 0.0.0 multipledispatch 1.0.0 nemo-emblems 5.8.0 netaddr 0.8.0 netifaces 0.11.0 networkx 2.8.8 numpy 1.21.5 oauthlib 3.2.0 onboard 1.4.1 packaging 21.3 PAM 0.4.2 pexpect 4.8.0 Pillow 9.5.0 pip 22.0.2 pluggy 0.13.0 ply 3.11 protobuf 3.12.4 psutil 5.9.0 ptyprocess 0.7.0 py 1.10.0 pycairo 1.24.0 pycups 2.0.1 pycurl 7.44.1 pydub 0.25.1 pyelftools 0.27 pyglet 2.0.9 Pygments 2.16.1 PyGObject 3.42.1 PyICU 2.8.1 pyinotify 0.9.6 PyJWT 2.3.0 pymacaroons 0.13.0 PyNaCl 1.5.0 pyparsing 2.4.7 pyparted 3.11.7 pyRFC3339 1.1 pyrr 0.10.3 pytest 6.2.5 python-apt 2.4.0+ubuntu2 python-dateutil 2.8.1 python-debian 0.1.43+ubuntu1.1 python-gnupg 0.4.8 python-magic 0.4.24 python-xlib 0.29 pythran 0.10.0 pytz 2022.1 pyxdg 0.27 PyYAML 5.4.1 reportlab 3.6.8 requests 2.31.0 requests-file 1.5.1 requests-toolbelt 0.9.1 rich 13.5.2 scipy 1.8.0 screen-resolution-extra 0.0.0 screeninfo 0.8.1 SecretStorage 3.3.1 setproctitle 1.2.2 setuptools 59.6.0 six 1.16.0 skia-pathops 0.7.4 soupsieve 2.3.1 srt 3.5.3 ssh-import-id 5.11 svgelements 1.9.6 sympy 1.9 systemd-python 234 tinycss2 1.1.1 tldextract 3.1.2 toml 0.10.2 tqdm 4.66.1 ubuntu-drivers-common 0.0.0 ufoLib2 0.13.1 ufw 0.36.1 unicodedata2 14.0.0 Unidecode 1.3.3 urllib3 1.26.5 wadllib 1.3.6 watchdog 2.3.1 webencodings 0.5.1 wheel 0.37.1 xdg 5 xkit 0.0.0 xlrd 1.2.0 youtube-dl 2021.12.17 zipp 1.0.0 ```
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): + Installed LaTeX packages:
FFMPEG Output of `ffmpeg -version`: ``` PASTE HERE ```

Additional comments

This is a new, clean install. The only non-standard thing I did is install manim running pip in sudo.

uwezi commented 1 year ago

You cannot call your scene the same as an Manim object. If you copy the code from the example 1:1

class ExampleLine3D(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes()
        line = Line3D(start=np.array([0, 0, 0]), end=np.array([2, 2, 2]))
        self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
        self.add(axes, line) 

everything will work fine.

The reason is not Manim but Python: when you write class Line3D(ThreeDScene) you create a new object class which overwrites the existing class Line3D. So when you then try line = Line3D(...) Python will try to create an object of your scene-class, rather the now overwritten original class to draw a line.