Page MenuHome

passing list of lists to numpy.array fails in space_view3d_math_vis
Closed, ResolvedPublic

Description

System Information
numpy - 1.16.1

Blender Version
Broken: version: 2.80 (sub 74), branch: master, commit date: 2019-06-25 01:29, hash: rB40a396792d77

Short description of error
When passing a list of lists to np.array() mathvis throws an exception

Traceback (most recent call last):
  File "<builddir>/bin/2.80/scripts/startup/bl_operators/console.py", line 55, in execute
    return execute(context, self.interactive)
  File "<builddir>/bin/2.80/scripts/modules/console_python.py", line 223, in execute
    func(*args)
  File "<builddir>/bin/2.80/scripts/addons/space_view3d_math_vis/__init__.py", line 169, in console_hook
    utils.VarStates.store_states()
  File "<builddir>/bin/2.80/scripts/addons/space_view3d_math_vis/utils.py", line 52, in store_states
    variables = get_math_data()
  File "<builddir>/bin/2.80/scripts/addons/space_view3d_math_vis/utils.py", line 98, in get_math_data
    if len(key)==0 or key[0] == "_" or not var:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Exact steps for others to reproduce the error

import numpy as np
a = np.array([[3, 0, 1], [1, 0, 2]])

After running np.array() the exception is thrown each time enter is pressed, until entering a=None

Event Timeline

Actually it is passing any list to np.array() not just list of lists.

a=np.array([3, 0, 1])

Note that the fix doesn't support numpy, it just avoid the error.

If you're interested numpy could be supported as either Vector or Matrix display types.