This is an automated email from the ASF dual-hosted git repository. gstein pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/steve.git
commit a991c7f85a94376c49e9f5bfd322678c4a1f05e1 Author: Greg Stein <[email protected]> AuthorDate: Wed Jun 1 20:36:26 2022 -0500 small tweak to collecting a list of unique rando values --- monitoring/stv_tool.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/monitoring/stv_tool.py b/monitoring/stv_tool.py index cb7ffbc..22389c1 100755 --- a/monitoring/stv_tool.py +++ b/monitoring/stv_tool.py @@ -157,6 +157,7 @@ class CandidateList(object): def __init__(self, names): num_cand = len(names) randset = generate_random(num_cand) + #dbg('RANDSET: %s', randset) self.l = [ ] for n, r in zip(names, randset): @@ -386,14 +387,11 @@ def generate_random(count): random.seed(0) ### choose a seed based on input? for now: repeatable. while True: # Generate COUNT values in [0.0, 1.0) + # NOTE: use a list (not a set or dict) for repeatable ordering. values = [random.random() for x in range(count)] - # Ensure there are no duplicates - for value in values: - if values.count(value) > 1: - break - else: - # The loop finished without breaking out + # Use a set() to check for dups. If no dups, then return the values. + if len(set(values)) == count: return values
