projects
/
pyutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
47fbced
)
Improve docs and add a doctest.
author
Scott Gasch
<
[email protected]
>
Sat, 18 Feb 2023 19:56:00 +0000
(11:56 -0800)
committer
Scott Gasch
<
[email protected]
>
Sat, 18 Feb 2023 19:56:00 +0000
(11:56 -0800)
src/pyutils/misc_utils.py
patch
|
blob
|
history
diff --git
a/src/pyutils/misc_utils.py
b/src/pyutils/misc_utils.py
index 0449cd5e130ccb5b6abfcf404a49fd5f0f9cfff2..8e52ae63eda3209b81d0205022396b15bcd6e4e2 100644
(file)
--- 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