From: Scott Gasch Date: Sat, 18 Feb 2023 19:56:00 +0000 (-0800) Subject: Improve docs and add a doctest. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=e3fd3043c571544363d94cd1579b18ee9b3f2d97;p=pyutils.git Improve docs and add a doctest. --- 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