Improve docs and add a doctest.
authorScott Gasch <[email protected]>
Sat, 18 Feb 2023 19:56:00 +0000 (11:56 -0800)
committerScott Gasch <[email protected]>
Sat, 18 Feb 2023 19:56:00 +0000 (11:56 -0800)
src/pyutils/misc_utils.py

index 0449cd5e130ccb5b6abfcf404a49fd5f0f9cfff2..8e52ae63eda3209b81d0205022396b15bcd6e4e2 100644 (file)
@@ -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