enthought / enthought/traitsui
ValueError thrown in TreeEditor with 2-dimension Array
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
With the following code:
```
import numpy as np
from traits.api import HasTraits, Array, List, self
from traitsui.api import View, Item, TreeEditor, TreeNode
class A(HasTraits):
a = Array
class B(HasTraits):
content = List
myself = self
def _content_default(self):
return [
A(a=np.arange(4)),
A(a=np.arange(20).reshape((4, 5)))
]
tree_editor = TreeEditor(
nodes=[
TreeNode(
node_for=[B],
children='content',
),
TreeNode(
node_for=[A],
children='',
),
])
view = View(Item('myself', editor=tree_editor, show_label=False))
B().configure_traits(view=view)
```
selecting the 2nd leaf with an array of shape (4, 5) throws 4 times (once per line):
```
Traceback (most recent call last):
File "/Users/yves/miniconda3/lib/python3.8/site-packages/traits/trait_notifiers.py", line 342, in __call__
self.handler(*args)
File "/Users/yves/miniconda3/lib/python3.8/site-packages/traitsui/editors/tuple_editor.py", line 195, in _field_changed
if new != value[index]:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.