moved random skip logic into separate file, added some comments on how it works
This commit is contained in:
@ -2,5 +2,6 @@
|
||||
from .aggregator import Aggregator
|
||||
from .bits import read_bit
|
||||
from .bufjson import BufferedJSON
|
||||
from .randskip import randskip
|
||||
|
||||
|
||||
|
20
dap/utils/randskip.py
Normal file
20
dap/utils/randskip.py
Normal file
@ -0,0 +1,20 @@
|
||||
from random import randint
|
||||
|
||||
|
||||
def randskip(skip_rate):
|
||||
return (randint(1, skip_rate) != 1)
|
||||
|
||||
|
||||
# from randint docs:
|
||||
# randint(a, b)
|
||||
# Return random integer in range [a, b], including both end points.
|
||||
|
||||
# thus:
|
||||
# randskip(1) -> False 100% of times (never skip)
|
||||
# randskip(10) -> False 10% of times (skip 90%)
|
||||
# randskip(100) -> False 1% of times (skip 99%)
|
||||
|
||||
#TODO: does this actually make sense?
|
||||
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
import argparse
|
||||
from random import randint
|
||||
|
||||
import numpy as np
|
||||
|
||||
from algos import calc_apply_threshold, calc_force_send, calc_mask_pixels, calc_peakfinder_analysis, calc_radial_integration, calc_roi, calc_spi_analysis, JFData
|
||||
from utils import Aggregator, BufferedJSON, read_bit
|
||||
from utils import Aggregator, BufferedJSON, randskip, read_bit
|
||||
from zmqsocks import ZMQSockets
|
||||
|
||||
|
||||
@ -133,7 +132,7 @@ def work(backend_address, accumulator_host, accumulator_port, visualisation_host
|
||||
|
||||
# hits are sent at full rate, but no-hits are sent at reduced frequency
|
||||
is_no_hit_frame = (not results["is_hit_frame"])
|
||||
random_skip = (randint(1, skip_frames_rate) != 1)
|
||||
random_skip = randskip(skip_frames_rate)
|
||||
is_no_hit_frame_and_skipped = (is_no_hit_frame and random_skip)
|
||||
|
||||
if aggregation_is_enabled_but_not_ready or is_bad_frame or is_no_hit_frame_and_skipped:
|
||||
|
Reference in New Issue
Block a user