From cd76af01faf93d2fb8a351b9b98e146d50f70b6d Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Tue, 30 Jul 2024 15:13:41 +0200 Subject: [PATCH] DRY --- dap/worker.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/dap/worker.py b/dap/worker.py index 6ace835..e3c5b5e 100644 --- a/dap/worker.py +++ b/dap/worker.py @@ -362,16 +362,14 @@ def work(backend_address, accumulator_host, accumulator_port, visualisation_host accumulator_socket.send_json(results, FLAGS) - if apply_aggregation and "aggregation_max" in results: - if not forceSendVisualisation: - data = np.empty((2, 2), dtype=np.uint16) - results["type"] = str(data.dtype) - results["shape"] = data.shape - else: - if not results["is_good_frame"] or not (results["is_hit_frame"] or randint(1, skip_frames_rate) == 1): - data = np.empty((2, 2), dtype=np.uint16) - results["type"] = str(data.dtype) - results["shape"] = data.shape + + send_empty_cond1 = (apply_aggregation and "aggregation_max" in results and not forceSendVisualisation) + send_empty_cond2 = (not results["is_good_frame"] or not (results["is_hit_frame"] or randint(1, skip_frames_rate) == 1)) + + if send_empty_cond1 or send_empty_cond2: + data = np.empty((2, 2), dtype=np.uint16) + results["type"] = str(data.dtype) + results["shape"] = data.shape visualisation_socket.send_json(results, FLAGS | zmq.SNDMORE) visualisation_socket.send(data, FLAGS, copy=True, track=True)