Skip to content

Commit

Permalink
replace _update_mixed_state with call to _on_glue_value_changed
Browse files Browse the repository at this point in the history
  • Loading branch information
cshanahan1 committed Dec 19, 2024
1 parent ba922b0 commit 1232043
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4401,25 +4401,17 @@ def is_mixed(self, glue_values):
return len(np.unique(glue_values, axis=0)) > 1

def _update_mixed_state(self):
if len(self.linked_states) <= 1:
mixed = False
else:
if self._processing_change_from_glue:
return

if len(self.linked_states) >= 1:
current_glue_values = []
for state in self.linked_states:
current_glue_values.append(self._get_glue_value(state))
mixed = self.is_mixed(current_glue_values)
# ensure the value corresponds to the first entry, this prevents the case where a glue
# change to one of the linked_states changes the value that will be adopted when
# unmixing something in mixed state and results in more consistent and predictable
# behavior
self._processing_change_from_glue = True
first_value = current_glue_values[0]
if isinstance(first_value, np.float32):
first_value = first_value.astype(np.float64)
self.value = first_value
self._processing_change_from_glue = False
self.sync = {**self.sync,
'mixed': mixed}

if len(current_glue_values) and current_glue_values[0] is not None:
# sync the initial value of the widget, avoiding recursion
self._on_glue_value_changed(current_glue_values[0])

def _on_value_changed(self, msg):
if self._processing_change_from_glue:
Expand Down

0 comments on commit 1232043

Please sign in to comment.