Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in RangeSelection #822

Open
coreysharris opened this issue Nov 15, 2021 · 0 comments
Open

Bug in RangeSelection #822

coreysharris opened this issue Nov 15, 2021 · 0 comments

Comments

@coreysharris
Copy link

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.

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)
@corranwebster corranwebster added this to the Release 5.1.0 milestone Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants