flatten the code; early exit
This commit is contained in:
@ -30,7 +30,13 @@ def calc_force_send(results, data, pixel_mask_pf, image, data_summed, n_aggregat
|
|||||||
|
|
||||||
def calc_apply_threshold(results, data):
|
def calc_apply_threshold(results, data):
|
||||||
apply_threshold = results.get("apply_threshold", False)
|
apply_threshold = results.get("apply_threshold", False)
|
||||||
if apply_threshold and all(k in results for k in ("threshold_min", "threshold_max")):
|
if not apply_threshold:
|
||||||
|
return
|
||||||
|
|
||||||
|
for k in ("threshold_min", "threshold_max"):
|
||||||
|
if k not in results:
|
||||||
|
return
|
||||||
|
|
||||||
threshold_min = float(results["threshold_min"])
|
threshold_min = float(results["threshold_min"])
|
||||||
threshold_max = float(results["threshold_max"])
|
threshold_max = float(results["threshold_max"])
|
||||||
data[data < threshold_min] = 0.0
|
data[data < threshold_min] = 0.0
|
||||||
@ -42,11 +48,17 @@ def calc_apply_aggregation(results, data, data_summed, n_aggregated_images):
|
|||||||
force_send_visualisation = False
|
force_send_visualisation = False
|
||||||
|
|
||||||
apply_aggregation = results.get("apply_aggregation", False)
|
apply_aggregation = results.get("apply_aggregation", False)
|
||||||
if apply_aggregation and "aggregation_max" in results:
|
if not apply_aggregation:
|
||||||
|
return data, force_send_visualisation, data_summed, n_aggregated_images
|
||||||
|
|
||||||
|
if "aggregation_max" not in results:
|
||||||
|
return data, force_send_visualisation, data_summed, n_aggregated_images
|
||||||
|
|
||||||
if data_summed is not None:
|
if data_summed is not None:
|
||||||
data += data_summed
|
data += data_summed
|
||||||
n_aggregated_images += 1
|
n_aggregated_images += 1
|
||||||
data_summed = data.copy()
|
data_summed = data.copy()
|
||||||
|
|
||||||
results["aggregated_images"] = n_aggregated_images
|
results["aggregated_images"] = n_aggregated_images
|
||||||
results["worker"] = 1 #TODO: keep this for backwards compatibility?
|
results["worker"] = 1 #TODO: keep this for backwards compatibility?
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user