Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Fix approx=.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taliesin Beynon committed Aug 23, 2018
1 parent d28e068 commit 042e23c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@
(let [arange (sym/arange-with-inference 0)
data (sym/variable "data")
added (sym/+ arange data)
result (range 0. 4.)
result (range 0 4)
data-tmp (ndarray/zeros [4])
exec (sym/bind added (context/default-context) {"data" data-tmp})]
(executor/forward exec)
(is (= 0 (count (executor/grad-arrays exec))))
(is (= result (-> (executor/outputs exec) (first) (ndarray/->vec))))))
(is (approx= 1e-4 result (-> (executor/outputs exec) (first))))))

(deftest test-scalar-pow
(let [data (sym/variable "data")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
(if (and (number? x) (number? y))
(let [diff (Math/abs (- x y))]
(< diff tolerance))
(reduce (fn [x y] (and x y))
(map #(approx= tolerance %1 %2) x y))))
(and
(= (count x) (count y))
(reduce (fn [x y] (and x y))
(map #(approx= tolerance %1 %2) x y)))))

0 comments on commit 042e23c

Please sign in to comment.