summaryrefslogtreecommitdiff
path: root/gnosis-algorithm.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-03-03 01:53:32 +0200
committerThanos Apollo <[email protected]>2024-03-03 01:53:32 +0200
commitad57dfd1313f600d1cb2054933db3eac76f6fa56 (patch)
tree1f24028810dd8ce93659d7cf81bc0345a816a614 /gnosis-algorithm.el
parent1d2abb3c16f7d07d4b76ca662088eed7e4433a54 (diff)
gnosis-algorithm-next-ef: Add assertions
- Make sure correct value types are given
Diffstat (limited to 'gnosis-algorithm.el')
-rw-r--r--gnosis-algorithm.el5
1 files changed, 5 insertions, 0 deletions
diff --git a/gnosis-algorithm.el b/gnosis-algorithm.el
index be91c53..10d0b6c 100644
--- a/gnosis-algorithm.el
+++ b/gnosis-algorithm.el
@@ -125,6 +125,11 @@ reviews, increase the ef increase value (first item) by INCREASE.
For every FREQUENCY of C-FAILURES reviews, decrease the ef decrease
value (second item) by DECREASE."
(let ((change-p (= (% (max 1 (if success c-successes c-failures)) frequency) 0))
+ (cl-loop for (param type) in '((ef listp) (success booleanp) (increase numberp)
+ (decrease numberp) (threshold numberp))
+ do (cl-assert (funcall type (symbol-value param)) nil
+ "Assertion failed: %s must be of type %s" param type))
+ (let ((threshold-p (= (% (max 1 (if success c-successes c-failures)) threshold) 0))
(new-ef (if success (gnosis-algorithm-replace-at-index 2 (+ (nth 2 ef) (nth 0 ef)) ef)
(gnosis-algorithm-replace-at-index 2 (max 1.3 (- (nth 2 ef) (nth 1 ef))) ef))))
(cond ((and success change-p)