enthought / enthought/chaco

Bug in RangeSelection

Open
#822 0 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Python
Stars
305
Forks
97
PR merge metrics
No merged PRs in 30d

Description

**Problem Description**

Changing the index_mapper on our ColorBar now produces the following error on Chaco 5.0.0. This problem does not occur in 4.8.0.

```
Traceback (most recent call last):
File "/Users/charris/.edm/envs/seismic36/lib/python3.6/site-packages/traits/observation/_trait_event_notifier.py", line 122, in __call__
self.dispatcher(handler, event)
File "/Users/charris/.edm/envs/seismic36/lib/python3.6/site-packages/traits/observation/observe.py", line 27, in dispatch_same
handler(event)
File "/Users/charris/.edm/envs/seismic36/lib/python3.6/site-packages/chaco/tools/range_selection.py", line 700, in _axis_mapper_updated
self.deselect()
File "/Users/charris/.edm/envs/seismic36/lib/python3.6/site-packages/chaco/tools/range_selection.py", line 193, in deselect
self.selection = None
File "/Users/charris/.edm/envs/seismic36/lib/python3.6/site-packages/chaco/tools/range_selection.py", line 633, in _set_selection
l.set_value_selection(val)
File "/Users/charris/.edm/envs/seismic36/lib/python3.6/site-packages/chaco/plots/cmap_image_plot.py", line 81, in set_value_selection
del self.value.metadata["selection_masks"]
File "/Users/charris/.edm/envs/seismic36/lib/python3.6/site-packages/traits/trait_dict_object.py", line 199, in __delitem__
super().__delitem__(key)
KeyError: 'selection_masks'
```

The issue seems to originate in the changes made in #591 and #601. We are currently working around the issue with the following patch, which simply reverts the changes made in those PRs.

```python
class PatchedRangeSelection(RangeSelection):
def _axis_mapper_updated(self, event):
pass

def __mapper_changed(self, event):
self.deselect()

def _axis_changed(self, old, new):
if old is not None:
self.plot.on_trait_change(
self.__mapper_changed, old + "_mapper", remove=True)
if new is not None:
self.plot.on_trait_change(
self.__mapper_changed, old + "_mapper", remove=True)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.