Skip to content
Snippets Groups Projects
Unverified Commit 3370d971 authored by Simon Belak's avatar Simon Belak Committed by GitHub
Browse files

Insights: fix `change` looping infinitely on input (0, -1) (#12282)

Insights: fix `change` looping infinitely on input (0, -1)
parent ffa6d85f
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@
(cond
(every? neg? [x1 x2]) (change (- x1) (- x2))
(and (neg? x1) (pos? x2)) (- (change x1 x2))
(neg? x1) (- (change x2 x1))
(neg? x1) (- (change x2 (- x1)))
:else (/ (- x2 x1) x1)))))
(defn reservoir-sample
......
......@@ -117,3 +117,15 @@
(transduce identity
(insights [{:base_type :type/DateTime} {:base_type :type/Number} {:base_type :type/Number}])
ts))
(deftest change-test
(is (= 0.0 (change 1 1)))
(is (= -0.5 (change 1 2)))
(is (= 1.0 (change 2 1)))
(is (= nil (change 1 0)))
(is (= -1.0 (change 0 1)))
(is (= 2.0 (change 1 -1)))
(is (= -2.0 (change -1 1)))
(is (= 1.0 (change -1 -2)))
(is (= nil (change -1 0)))
(is (= 1.0 (change 0 -1))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment