Skip to content

Commit

Permalink
Fix mask on/off in application
Browse files Browse the repository at this point in the history
  • Loading branch information
domfournier committed Sep 17, 2024
1 parent 029a4bf commit c31f94b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions peak_finder/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]

Check warning on line 311 in peak_finder/application.py

View check run for this annotation

Codecov / codecov/patch

peak_finder/application.py#L310-L311

Added lines #L310 - L311 were not covered by tests

if not isinstance(data, ReferencedData):
raise TypeError("Line field must be of type ReferencedData.")
Expand Down Expand Up @@ -528,15 +528,19 @@ def update_survey_mask(
if self.survey is None:
return no_update, no_update

self._survey = None

Check warning on line 531 in peak_finder/application.py

View check run for this annotation

Codecov / codecov/patch

peak_finder/application.py#L531

Added line #L531 was not covered by tests
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

Check warning on line 539 in peak_finder/application.py

View check run for this annotation

Codecov / codecov/patch

peak_finder/application.py#L539

Added line #L539 was not covered by tests

if isinstance(self.line_field, Data):
self.line_field = self.line_field.uid # type: ignore

Check warning on line 542 in peak_finder/application.py

View check run for this annotation

Codecov / codecov/patch

peak_finder/application.py#L541-L542

Added lines #L541 - L542 were not covered by tests

min_value = no_update
if self.active_channels is not None:
sign = 1
Expand Down Expand Up @@ -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:

Check warning on line 821 in peak_finder/application.py

View check run for this annotation

Codecov / codecov/patch

peak_finder/application.py#L821

Added line #L821 was not covered by tests
continue
full_values = sign * np.array(channel_dict["values"])

Expand Down

0 comments on commit c31f94b

Please sign in to comment.