"Manim\Lib\site-packages\manim\mobject\graphing\functions.py:162: FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future."
Expected behavior
No warning should display when the passed function parameter returns expected values.
How to reproduce the issue
This occurs when the class ParametricFunction is called with
parameter use_vectorized = True
and passing a function argument that when called returns three uniform ndarrays
Code for reproducing the problem
```py
def function(t_range):
x = np.array([0, 0, 0])
y = np.array([1 ,1 ,1])
z = np.array([2, 2, 2])
return np.array([x, y, z])
t_range = np.array([0, 1, 0.001])
vector_sum_path = ParametricFunction(
function,
t_range = t_range,
use_vectorized = True
)
```
Proposed fix
This change on the aforementioned line 162 fixes the warning,
```py
if self.use_vectorized:
x, y, z = self.function(t_range)
if not isinstance(z, np.ndarray):
z = np.zeros_like(x)
points = np.stack([x, y, z], axis=1) # ONLY CHANGE HERE
```
I don't usually write Python and haven't used Numpy a whole lot, so I don't know if this is a suitable fix, but it does take care of the warning.
System specifications
System Details
- OS: Windows 10 version 22H2
- RAM: 16GB
- Python version: 3.10.6
- Installed modules:
```
Package Version
--------------------------------- ------------
arrow 1.2.0
backcall 0.2.0
backports.cached-property 1.0.1
backports.entry-points-selectable 1.1.0
binaryornot 0.4.4
cairocffi 1.2.0
certifi 2021.5.30
cffi 1.14.6
chardet 4.0.0
charset-normalizer 2.0.6
click 8.1.3
click-default-group 1.2.2
cloup 0.13.1
colorama 0.4.4
colour 0.1.5
commonmark 0.9.1
cookiecutter 1.7.2
cycler 0.10.0
decorator 5.1.0
distlib 0.3.3
filelock 3.0.12
glcontext 2.3.4
h11 0.12.0
httpcore 0.12.3
httpx 0.16.1
idna 3.2
ipython 7.28.0
isosurfaces 0.1.0
jedi 0.18.0
Jinja2 2.11.3
jinja2-time 0.2.0
kiwisolver 1.3.2
manim 0.16.0.post0
manimlib 0.2.0
ManimPango 0.4.0.post1
mapbox-earcut 0.12.10
MarkupSafe 1.1.1
matplotlib 3.4.3
matplotlib-inline 0.1.3
moderngl 5.6.4
moderngl-window 2.4.0
mpmath 1.2.1
multipledispatch 0.6.0
networkx 2.6.3
numpy 1.21.2
opencv-python 4.5.3.56
pangocairocffi 0.4.0
pangocffi 0.8.0
parso 0.8.2
pickleshare 0.7.5
Pillow 9.2.0
pip 22.2.1
pkginfo 1.6.1
platformdirs 2.3.0
poyo 0.5.0
progressbar 2.5
prompt-toolkit 3.0.20
pup 1.0.0a12
pycairo 1.20.1
pycparser 2.20
pydub 0.25.1
pyglet 1.5.21
Pygments 2.10.0
PyOpenGL 3.1.5
pyparsing 2.4.7
pyreadline 2.1
pyrr 0.10.3
python-dateutil 2.8.2
python-slugify 5.0.2
PyYAML 5.4.1
requests 2.26.0
rfc3986 1.5.0
rich 6.2.0
scipy 1.8.0
screeninfo 0.8
setuptools 57.4.0
six 1.16.0
skia-pathops 0.7.1
sniffio 1.2.0
srt 3.5.1
sympy 1.8
text-unidecode 1.3
tqdm 4.62.3
traitlets 5.1.0
typing-extensions 3.10.0.2
urllib3 1.26.7
validators 0.18.2
virtualenv 20.8.1
watchdog 2.1.6
wcwidth 0.2.5
wheel 0.36.2
zstandard 0.15.1
```
LaTeX details
+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:
```
i adjustbox: Graphics package-alike macros for "general" boxes
i adobemapping: Adobe cmap and pdfmapping files
i amscls: AMS document classes for LaTeX
i amsfonts: TeX fonts from the American Mathematical Society
i amsmath: AMS mathematical facilities for LaTeX
i atbegshi: Execute stuff at \shipout time
i atveryend: Hooks at the very end of a document
i auxhook: Hooks for auxiliary files
i babel: Multilingual support for LaTeX, LuaLaTeX, XeLaTeX, and Plain TeX
i bibtex: Process bibliographies (bib files) for LaTeX or other formats
i bibtex.win32: win32 files of bibtex
i bigintcalc: Integer calculations on very large numbers
i bitset: Handle bit-vector datatype
i booktabs: Publication quality tables in LaTeX
i cm: Computer Modern fonts
i ctablestack: Catcode table stable support
i dehyph: German hyphenation patterns for traditional orthography
i dvipdfmx: An extended version of dvipdfm
i dvipdfmx.win32: win32 files of dvipdfmx
i dvips: A DVI to PostScript driver
i dvips.win32: win32 files of dvips
i ec: Computer modern fonts in T1 and TS1 encodings
i epstopdf-pkg: Call epstopdf "on the fly"
i etex: An extended version of TeX, from the NTS project
i etexcmds: Avoid name clashes with e-TeX commands
i etoolbox: e-TeX tools for LaTeX
i euenc: Unicode font encoding definitions for XeTeX
i everyshi: Take action at every \shipout
i fancyvrb: Sophisticated verbatim text
i filehook: Hooks for input files
i firstaid: First aid for external LaTeX files and packages that need updating
i float: Improved interface for floating objects
i fontspec: Advanced font selection in XeLaTeX and LuaLaTeX
i framed: Framed or shaded regions that can break across pages
i geometry: Flexible and complete interface to document dimensions
i gettitlestring: Clean up title references
i glyphlist: Adobe Glyph List and TeX extensions
i graphics: The LaTeX standard graphics bundle
i graphics-cfg: Sample configuration files for LaTeX color and graphics
i graphics-def: Colour and graphics option files
i helvetic: URW 'Base 35' font pack for LaTeX
i hycolor: Implements colour for packages hyperref and bookmark
i hyperref: Extensive support for hypertext in LaTeX
i hyph-utf8: Hyphenation patterns expressed in UTF-8
i hyphen-base: core hyphenation support files
i iftex: Am I running under pdfTeX, XeTeX or LuaTeX?
i inconsolata: A monospaced font, with support files for use with TeX
i infwarerr: Complete set of information/warning/error message macros
i intcalc: Expandable arithmetic operations with integers
i knuth-lib: Core TeX and Metafont sources from Knuth
i kpathsea: Path searching library for TeX-related files
i kpathsea.win32: win32 files of kpathsea
i kvdefinekeys: Define keys for use in the kvsetkeys package
i kvoptions: Key value format for package options
i kvsetkeys: Key value parser with default handler support
i l3backend: LaTeX3 backend drivers
i l3kernel: LaTeX3 programming conventions
i l3packages: High-level LaTeX3 concepts
i latex: A TeX macro package that defines LaTeX
i latex-amsmath-dev: Development pre-release of the LaTeX amsmath bundle
i latex-bin: LaTeX executables and man pages
i latex-bin.win32: win32 files of latex-bin
i latex-fonts: A collection of fonts used in LaTeX distributions
i latex-tools-dev: Development pre-release of the LaTeX tools bundle
i latexconfig: configuration files for LaTeX-related formats
i latexmk: Fully automated LaTeX document generation
i latexmk.win32: win32 files of latexmk
i letltxmacro: Let assignment for LaTeX macros
i lm: Latin modern fonts in outline formats
i lm-math: OpenType maths fonts for Latin Modern
i ltxcmds: Some LaTeX kernel commands for general use
i lua-alt-getopt: Process application arguments the same way as getopt_long
i lua-uni-algos: Unicode algorithms for LuaTeX
i luahbtex: LuaTeX with HarfBuzz library for glyph shaping
i luahbtex.win32: win32 files of luahbtex
i lualatex-math: Fixes for mathematics-related LuaLaTeX issues
i lualibs: Additional Lua functions for LuaTeX macro programmers
i luaotfload: OpenType 'loader' for Plain TeX and LaTeX
i luaotfload.win32: win32 files of luaotfload
i luatex: The LuaTeX engine
i luatex.win32: win32 files of luatex
i luatexbase: Basic resource management for LuaTeX code
i mdwtools: Miscellaneous tools by Mark Wooding
i metafont: A system for specifying fonts
i metafont.win32: win32 files of metafont
i mfware: Supporting tools for use with Metafont
i mfware.win32: win32 files of mfware
i modes: A collection of Metafont mode_def's
i natbib: Flexible bibliography support
i pdfescape: Implements pdfTeX's escape features using TeX or e-TeX
i pdftex: A TeX extension for direct creation of PDF
i pdftex.win32: win32 files of pdftex
i pdftexcmds: LuaTeX support for pdfTeX utility functions
i plain: The Plain TeX format
i psnfss: Font support for common PostScript fonts
i refcount: Counter operations with label references
i rerunfilecheck: Checksum based rerun checks on auxiliary files
i scheme-infraonly: infrastructure-only scheme (no TeX at all)
i selnolig: Selectively disable typographic ligatures
i stringenc: Converting a string between different encodings
i symbol: URW 'Base 35' font pack for LaTeX
i tex: A sophisticated typesetting engine
i tex-ini-files: Model TeX format creation files
i tex.win32: win32 files of tex
i texlive-scripts: TeX Live infrastructure programs
i texlive-scripts.win32: win32 files of texlive-scripts
i texlive.infra: basic TeX Live infrastructure
i texlive.infra.win32: win32 files of texlive.infra
i times: URW 'Base 35' font pack for LaTeX
i tipa: Fonts and macros for IPA phonetics characters
i tlgs.win32: Freely available PostScript interpreter
i tlperl.win32: internal Perl for Windows
i tools: The LaTeX standard tools bundle
i unicode-data: Unicode data and loaders for TeX
i unicode-math: Unicode mathematics support for XeTeX and LuaTeX
i uniquecounter: Provides unlimited unique counter
i url: Verbatim with URL-sensitive line breaks
i xcolor: Driver-independent color extensions for LaTeX and pdfLaTeX
i xetex: An extended variant of TeX for use with Unicode sources
i xetex.win32: win32 files of xetex
i xetexconfig: crop.cfg for XeLaTeX
i xkeyval: Extension of the keyval package
i xunicode: Generate Unicode characters from accented glyphs
i zapfding: URW 'Base 35' font pack for LaTeX
```
Description of bug / unexpected behavior
Deprecation warning from Numpy.
Expected behavior
No warning should display when the passed
function
parameter returns expected values.How to reproduce the issue
This occurs when the class ParametricFunction is called with
use_vectorized = True
function
argument that when called returns three uniform ndarraysCode for reproducing the problem
```py def function(t_range): x = np.array([0, 0, 0]) y = np.array([1 ,1 ,1]) z = np.array([2, 2, 2]) return np.array([x, y, z]) t_range = np.array([0, 1, 0.001]) vector_sum_path = ParametricFunction( function, t_range = t_range, use_vectorized = True ) ```Proposed fix
This change on the aforementioned line 162 fixes the warning,
I don't usually write Python and haven't used Numpy a whole lot, so I don't know if this is a suitable fix, but it does take care of the warning.
System specifications
System Details
- OS: Windows 10 version 22H2 - RAM: 16GB - Python version: 3.10.6 - Installed modules: ``` Package Version --------------------------------- ------------ arrow 1.2.0 backcall 0.2.0 backports.cached-property 1.0.1 backports.entry-points-selectable 1.1.0 binaryornot 0.4.4 cairocffi 1.2.0 certifi 2021.5.30 cffi 1.14.6 chardet 4.0.0 charset-normalizer 2.0.6 click 8.1.3 click-default-group 1.2.2 cloup 0.13.1 colorama 0.4.4 colour 0.1.5 commonmark 0.9.1 cookiecutter 1.7.2 cycler 0.10.0 decorator 5.1.0 distlib 0.3.3 filelock 3.0.12 glcontext 2.3.4 h11 0.12.0 httpcore 0.12.3 httpx 0.16.1 idna 3.2 ipython 7.28.0 isosurfaces 0.1.0 jedi 0.18.0 Jinja2 2.11.3 jinja2-time 0.2.0 kiwisolver 1.3.2 manim 0.16.0.post0 manimlib 0.2.0 ManimPango 0.4.0.post1 mapbox-earcut 0.12.10 MarkupSafe 1.1.1 matplotlib 3.4.3 matplotlib-inline 0.1.3 moderngl 5.6.4 moderngl-window 2.4.0 mpmath 1.2.1 multipledispatch 0.6.0 networkx 2.6.3 numpy 1.21.2 opencv-python 4.5.3.56 pangocairocffi 0.4.0 pangocffi 0.8.0 parso 0.8.2 pickleshare 0.7.5 Pillow 9.2.0 pip 22.2.1 pkginfo 1.6.1 platformdirs 2.3.0 poyo 0.5.0 progressbar 2.5 prompt-toolkit 3.0.20 pup 1.0.0a12 pycairo 1.20.1 pycparser 2.20 pydub 0.25.1 pyglet 1.5.21 Pygments 2.10.0 PyOpenGL 3.1.5 pyparsing 2.4.7 pyreadline 2.1 pyrr 0.10.3 python-dateutil 2.8.2 python-slugify 5.0.2 PyYAML 5.4.1 requests 2.26.0 rfc3986 1.5.0 rich 6.2.0 scipy 1.8.0 screeninfo 0.8 setuptools 57.4.0 six 1.16.0 skia-pathops 0.7.1 sniffio 1.2.0 srt 3.5.1 sympy 1.8 text-unidecode 1.3 tqdm 4.62.3 traitlets 5.1.0 typing-extensions 3.10.0.2 urllib3 1.26.7 validators 0.18.2 virtualenv 20.8.1 watchdog 2.1.6 wcwidth 0.2.5 wheel 0.36.2 zstandard 0.15.1 ```LaTeX details
+ LaTeX distribution (e.g. TeX Live 2020): + Installed LaTeX packages: ``` i adjustbox: Graphics package-alike macros for "general" boxes i adobemapping: Adobe cmap and pdfmapping files i amscls: AMS document classes for LaTeX i amsfonts: TeX fonts from the American Mathematical Society i amsmath: AMS mathematical facilities for LaTeX i atbegshi: Execute stuff at \shipout time i atveryend: Hooks at the very end of a document i auxhook: Hooks for auxiliary files i babel: Multilingual support for LaTeX, LuaLaTeX, XeLaTeX, and Plain TeX i bibtex: Process bibliographies (bib files) for LaTeX or other formats i bibtex.win32: win32 files of bibtex i bigintcalc: Integer calculations on very large numbers i bitset: Handle bit-vector datatype i booktabs: Publication quality tables in LaTeX i cm: Computer Modern fonts i ctablestack: Catcode table stable support i dehyph: German hyphenation patterns for traditional orthography i dvipdfmx: An extended version of dvipdfm i dvipdfmx.win32: win32 files of dvipdfmx i dvips: A DVI to PostScript driver i dvips.win32: win32 files of dvips i ec: Computer modern fonts in T1 and TS1 encodings i epstopdf-pkg: Call epstopdf "on the fly" i etex: An extended version of TeX, from the NTS project i etexcmds: Avoid name clashes with e-TeX commands i etoolbox: e-TeX tools for LaTeX i euenc: Unicode font encoding definitions for XeTeX i everyshi: Take action at every \shipout i fancyvrb: Sophisticated verbatim text i filehook: Hooks for input files i firstaid: First aid for external LaTeX files and packages that need updating i float: Improved interface for floating objects i fontspec: Advanced font selection in XeLaTeX and LuaLaTeX i framed: Framed or shaded regions that can break across pages i geometry: Flexible and complete interface to document dimensions i gettitlestring: Clean up title references i glyphlist: Adobe Glyph List and TeX extensions i graphics: The LaTeX standard graphics bundle i graphics-cfg: Sample configuration files for LaTeX color and graphics i graphics-def: Colour and graphics option files i helvetic: URW 'Base 35' font pack for LaTeX i hycolor: Implements colour for packages hyperref and bookmark i hyperref: Extensive support for hypertext in LaTeX i hyph-utf8: Hyphenation patterns expressed in UTF-8 i hyphen-base: core hyphenation support files i iftex: Am I running under pdfTeX, XeTeX or LuaTeX? i inconsolata: A monospaced font, with support files for use with TeX i infwarerr: Complete set of information/warning/error message macros i intcalc: Expandable arithmetic operations with integers i knuth-lib: Core TeX and Metafont sources from Knuth i kpathsea: Path searching library for TeX-related files i kpathsea.win32: win32 files of kpathsea i kvdefinekeys: Define keys for use in the kvsetkeys package i kvoptions: Key value format for package options i kvsetkeys: Key value parser with default handler support i l3backend: LaTeX3 backend drivers i l3kernel: LaTeX3 programming conventions i l3packages: High-level LaTeX3 concepts i latex: A TeX macro package that defines LaTeX i latex-amsmath-dev: Development pre-release of the LaTeX amsmath bundle i latex-bin: LaTeX executables and man pages i latex-bin.win32: win32 files of latex-bin i latex-fonts: A collection of fonts used in LaTeX distributions i latex-tools-dev: Development pre-release of the LaTeX tools bundle i latexconfig: configuration files for LaTeX-related formats i latexmk: Fully automated LaTeX document generation i latexmk.win32: win32 files of latexmk i letltxmacro: Let assignment for LaTeX macros i lm: Latin modern fonts in outline formats i lm-math: OpenType maths fonts for Latin Modern i ltxcmds: Some LaTeX kernel commands for general use i lua-alt-getopt: Process application arguments the same way as getopt_long i lua-uni-algos: Unicode algorithms for LuaTeX i luahbtex: LuaTeX with HarfBuzz library for glyph shaping i luahbtex.win32: win32 files of luahbtex i lualatex-math: Fixes for mathematics-related LuaLaTeX issues i lualibs: Additional Lua functions for LuaTeX macro programmers i luaotfload: OpenType 'loader' for Plain TeX and LaTeX i luaotfload.win32: win32 files of luaotfload i luatex: The LuaTeX engine i luatex.win32: win32 files of luatex i luatexbase: Basic resource management for LuaTeX code i mdwtools: Miscellaneous tools by Mark Wooding i metafont: A system for specifying fonts i metafont.win32: win32 files of metafont i mfware: Supporting tools for use with Metafont i mfware.win32: win32 files of mfware i modes: A collection of Metafont mode_def's i natbib: Flexible bibliography support i pdfescape: Implements pdfTeX's escape features using TeX or e-TeX i pdftex: A TeX extension for direct creation of PDF i pdftex.win32: win32 files of pdftex i pdftexcmds: LuaTeX support for pdfTeX utility functions i plain: The Plain TeX format i psnfss: Font support for common PostScript fonts i refcount: Counter operations with label references i rerunfilecheck: Checksum based rerun checks on auxiliary files i scheme-infraonly: infrastructure-only scheme (no TeX at all) i selnolig: Selectively disable typographic ligatures i stringenc: Converting a string between different encodings i symbol: URW 'Base 35' font pack for LaTeX i tex: A sophisticated typesetting engine i tex-ini-files: Model TeX format creation files i tex.win32: win32 files of tex i texlive-scripts: TeX Live infrastructure programs i texlive-scripts.win32: win32 files of texlive-scripts i texlive.infra: basic TeX Live infrastructure i texlive.infra.win32: win32 files of texlive.infra i times: URW 'Base 35' font pack for LaTeX i tipa: Fonts and macros for IPA phonetics characters i tlgs.win32: Freely available PostScript interpreter i tlperl.win32: internal Perl for Windows i tools: The LaTeX standard tools bundle i unicode-data: Unicode data and loaders for TeX i unicode-math: Unicode mathematics support for XeTeX and LuaTeX i uniquecounter: Provides unlimited unique counter i url: Verbatim with URL-sensitive line breaks i xcolor: Driver-independent color extensions for LaTeX and pdfLaTeX i xetex: An extended variant of TeX for use with Unicode sources i xetex.win32: win32 files of xetex i xetexconfig: crop.cfg for XeLaTeX i xkeyval: Extension of the keyval package i xunicode: Generate Unicode characters from accented glyphs i zapfding: URW 'Base 35' font pack for LaTeX ```