From c31f94b2e61981404c6b2eea9e68acdcf9a26b4e Mon Sep 17 00:00:00 2001 From: dominiquef Date: Tue, 17 Sep 2024 16:52:37 -0700 Subject: [PATCH] Fix mask on/off in application --- peak_finder/application.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/peak_finder/application.py b/peak_finder/application.py index 2ddc1e0..b9737ba 100644 --- a/peak_finder/application.py +++ b/peak_finder/application.py @@ -24,7 +24,7 @@ from geoh5py import Workspace from geoh5py.data import BooleanData, Data, ReferencedData from geoh5py.objects import Curve -from geoh5py.shared.utils import fetch_active_workspace, is_uuid +from geoh5py.shared.utils import fetch_active_workspace from geoh5py.ui_json import InputFile from tqdm import tqdm @@ -306,9 +306,9 @@ def line_field(self) -> ReferencedData | None: return self._line_field @line_field.setter - def line_field(self, value): - if is_uuid(value): - data = self.workspace.get_entity(uuid.UUID(value))[0] + def line_field(self, value: str | uuid.UUID | ReferencedData | None): + if isinstance(value, str | uuid.UUID) and self.survey is not None: + data = self.survey.get_entity(uuid.UUID(str(value)))[0] if not isinstance(data, ReferencedData): raise TypeError("Line field must be of type ReferencedData.") @@ -528,15 +528,19 @@ def update_survey_mask( if self.survey is None: return no_update, no_update + self._survey = None if masking_data is not None and masking_data != "None": - self._survey = None - if self.survey is not None and hasattr(self.survey, "remove_vertices"): masking_data_obj = self.survey.get_data(uuid.UUID(masking_data))[0] masking_array = masking_data_obj.values if masking_array is not None: self.survey.remove_vertices(~masking_array) + self.computed_lines = None + + if isinstance(self.line_field, Data): + self.line_field = self.line_field.uid # type: ignore + min_value = no_update if self.active_channels is not None: sign = 1 @@ -814,7 +818,7 @@ def update_figure_lines( # pylint: disable=too-many-arguments, too-many-locals, for channel_dict in list( # pylint: disable=too-many-nested-blocks self.active_channels.values() ): - if "values" not in channel_dict: + if "values" not in channel_dict or selected_line not in self.computed_lines: continue full_values = sign * np.array(channel_dict["values"])