From ad57dfd1313f600d1cb2054933db3eac76f6fa56 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 3 Mar 2024 01:53:32 +0200 Subject: gnosis-algorithm-next-ef: Add assertions - Make sure correct value types are given --- gnosis-algorithm.el | 5 +++++ 1 file changed, 5 insertions(+) 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) -- cgit v1.2.3