Skip to content

Commit

Permalink
refactor: allow 0 as missing values
Browse files Browse the repository at this point in the history
  • Loading branch information
dfguerrerom committed Aug 30, 2024
1 parent acf9172 commit 7d19900
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions component/widget/reclassify/reclassify_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,15 @@ def load_matrix_content(self, *_):
# check that the destination values are all available
widget = list(self.reclassify_table.class_select_list.values())[0]
classes = [i["value"] for i in widget.items]
if not all(v in classes for v in input_data.to_code.unique()):
# get the missing values
missing_values = ",".join(
[str(v) for v in input_data.to_code.unique() if v not in classes]
)

# get the missing values
missing_values = [v for v in input_data.to_code.unique() if v not in classes]

# if missing values are only 0, we can pass
if missing_values and not (len(missing_values) == 1 and missing_values[0] == 0):
missing_values_str = ",".join(map(str, missing_values))
raise Exception(
f"Some of the target land cover classes ({missing_values}) are not present in the destination land cover classes."
f"Some of the target land cover classes ({missing_values_str}) are not present in the destination land cover classes."
)

# fill the data
Expand Down

0 comments on commit 7d19900

Please sign in to comment.