Skip to content

Commit

Permalink
Merge pull request #73 from sepal-contrib/frag_module
Browse files Browse the repository at this point in the history
feat: fix: #72. Add stats param to fragmentation module
  • Loading branch information
dfguerrerom authored Sep 6, 2023
2 parents b2c457e + d21f34b commit 769ca63
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion component/message/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"windows": "Observation scale",
"window_lbl": "Scale {}",
"invalid_window": "A window should be a odd int in [3, 501]",
"no_windows": "Please provide at least 1 window size"
"no_windows": "Please provide at least 1 window size",
"stats": "Compute statistics"
},
"lm": {
"title": "LM: Landscape Mosaic",
Expand Down
4 changes: 2 additions & 2 deletions component/model/frag_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class FragModel(GWBModel):

# the init file
file = Any(None).tag(sync=True)

Expand All @@ -16,6 +15,7 @@ class FragModel(GWBModel):
foreground = Any([]).tag(sync=True)
spe_background_1 = Any([]).tag(sync=True)
spe_background_2 = Any([]).tag(sync=True)
statistics = Any(0).tag(sync=True)

# the process
connectivity = Any(cp.connectivity[0]["value"]).tag(sync=True)
Expand All @@ -25,7 +25,6 @@ class FragModel(GWBModel):
options = Any(cp.frag_options[0]["value"]).tag(sync=True)

def __init__(self):

super().__init__(process="frag")

def update_byte_list(self):
Expand All @@ -50,6 +49,7 @@ def update_params_list(self):
self.res,
self.join_attr("window_size"),
self.prescision,
self.statistics,
]
)

Expand Down
11 changes: 5 additions & 6 deletions component/tile/frag_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

class FragTile(GwbTile):
def __init__(self, model):

# create the widgets
connectivity = v.Select(
label=cm.acc.connectivity,
Expand All @@ -38,25 +37,27 @@ def __init__(self, model):
v_model=cp.prescision[0]["value"],
)

stats = v.Switch(label=cm.frag.stats, false_value=0, true_value=1, v_model=0)

# bind to the io
(
model.bind(connectivity, "connectivity")
.bind(res, "res")
.bind(windows.save, "window_size")
.bind(options, "options")
.bind(prescision, "prescision")
.bind(stats, "statistics")
)

# extra js behaviour
res.on_event("focusout", self._on_focus_out)

super().__init__(
model=model, inputs=[connectivity, res, windows, options, prescision]
model=model, inputs=[connectivity, res, windows, options, prescision, stats]
)

@su.loading_button()
@su.loading_button(debug=True)
def _on_click(self, widget, event, data):

# check inputs
if not all(
[
Expand All @@ -77,7 +78,6 @@ def _on_click(self, widget, event, data):
return

def _on_focus_out(self, widget, event, data):

# clear error
widget.error_messages = None

Expand All @@ -87,7 +87,6 @@ def _on_focus_out(self, widget, event, data):

valid = True
try:

value = int(widget.v_model)

if value < 0:
Expand Down

0 comments on commit 769ca63

Please sign in to comment.