Skip to content

Commit

Permalink
removing the ability to provide a predicate to the bucket fn.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bradford Cross committed Apr 1, 2010
1 parent 781b3bf commit 0238d27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
7 changes: 2 additions & 5 deletions src/infer/probability.clj
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,13 @@
;; :otherwise (range-classifier r val-to-bucket))
(defn bucket
([f r] (bucket f identity r))
([f t r] (bucket f t r always-false))
([f t r p]
([f t r]
(fn [x]
(let [trans (t x)]
(if (nil? trans) :missing
(let [val-to-bucket (f trans)]
(if (nil? val-to-bucket) :missing
(if-let [short-circuit (p val-to-bucket)]
short-circuit
(range-classifier r val-to-bucket)))))))))
(range-classifier r val-to-bucket))))))))

(defn cond-prob-tuple
"build [a&b b] count tuples for calculating conditional probabilities p(a | b)"
Expand Down
16 changes: 1 addition & 15 deletions test/infer/probability_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -343,21 +343,7 @@
(fn [[x y]] (+ x y))
:foo
(range 0 10 1))
{:foo nil})))
(is (= :short-circuit
((bucket
(fn [[x y]] (+ x y))
#(vector (:foo %) (:bar %))
(range 0 10 1)
#(if (> 10 %) :short-circuit false))
{:foo 3 :bar 4})))
(is (= :negative
((bucket
(fn [[x y]] (- x y))
#(vector (:foo %) (:bar %))
(range 0 10 1)
bucket-negative?)
{:foo 3 :bar 4}))))
{:foo nil}))))

(deftest tree-comp-with-p
(is (= [{1 {0 1}} {1 1}]
Expand Down

0 comments on commit 0238d27

Please sign in to comment.