From e3fd3043c571544363d94cd1579b18ee9b3f2d97 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Sat, 18 Feb 2023 11:56:00 -0800 Subject: [PATCH] Improve docs and add a doctest. --- src/pyutils/misc_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pyutils/misc_utils.py b/src/pyutils/misc_utils.py index 0449cd5..8e52ae6 100644 --- a/src/pyutils/misc_utils.py +++ b/src/pyutils/misc_utils.py @@ -31,8 +31,18 @@ def debugger_is_attached() -> bool: def execute_probabilistically(probability_to_execute: float) -> bool: """ + Args: + probability_to_execute: the probability of returning True. + Returns: True with a given probability. + + >>> random.seed(22) + >>> execute_probabilistically(50.0) + False + >>> execute_probabilistically(50.0) + True + """ return random.uniform(0.0, 100.0) < probability_to_execute -- 2.46.0