OpenGL: DecimalNumber set_value
Description of bug / unexpected behavior
When running the ValueTracker example for the DecimalNumber component, see https://docs.manim.community/en/stable/reference/manim.mobject.text.numbers.DecimalNumber.html with the opengl renderer, I get:
ValueError: setting an array element with a sequence. The requested array would exceed the maximum number of dimension of 32.
Expected behavior
No error
How to reproduce the issue
Paste the example from the link above into some file.py and run
manim render file.py --renderer=opengl --preview MovingSquareWithUpdaters
System specifications
System Details
- OS: Ubuntu 22.04
- RAM: 16GB
- Python version: Python 3.10.12
- Installed module: manim 0.18.0
FFMPEG
Output of ffmpeg -version:
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
The Problem comes from this line: https://github.com/ManimCommunity/manim/blob/286f366a3584ae84d29d13c2a2c1f70b43752f95/manim/mobject/opengl/opengl_vectorized_mobject.py#L268
width can be of type int, float, but also numpy.ndarray of various shapes, e.g. (1,) or (1,1), but also (1,1,1,1,...1) with more than 32 dimensions, which causes the issue. No matter the dimension of width, it always has exactly one entry as far as I can tell.
I fixed it for my purposes
if(isinstance(width, np.ndarray) and len(width) == 1):
width = width.reshape((1,))
This certainly isn't the right thing to do and it would be interesting to know why the width sometimes has such a weird type in the first place.
Hit the exact same issue when using OpenGL and calling set_value() on a DecimalNumber. The workaround above worked for me.