Fixed some tests that broke when nominal attributes changed from string to keyword representations.

This commit is contained in:
Joshua Eckroth 2013-08-07 10:32:50 -04:00
parent dcf6534ea4
commit 937b9bf87d
2 changed files with 11 additions and 9 deletions

View file

@ -139,11 +139,11 @@
(deftest working-sequences-and-helpers
(let [ds (make-dataset "test" [:a :b {:c [:d :e]}] [{:a 1 :b 2 :c nil} [4 nil :e]])]
(is (= 2 (dataset-count ds)))
(is (= [{:a 1.0 :b 2.0 :c nil} {:a 4.0 :b nil :c "e"}] (dataset-as-maps ds)))
(is (= [{:a 1.0 :b 2.0 :c nil} {:a 4.0 :b nil :c :e}] (dataset-as-maps ds)))
(is (= [{:weight 1.0} {:weight 1.0}] (map meta (dataset-as-maps ds))))
(is (= [[1.0 2.0 nil] [4.0 nil "e"]] (dataset-as-vecs ds)))
(is (= [[1.0 2.0 nil] [4.0 nil :e]] (dataset-as-vecs ds)))
(is (= [{:weight 1.0} {:weight 1.0}] (map #(meta (instance-to-map %1)) (dataset-seq ds))))
(is (= [{:a 1.0 :b 2.0 :c nil} {:a 4.0 :b nil :c "e"}] (map #(instance-to-map %1) (dataset-seq ds))))))
(is (= [{:a 1.0 :b 2.0 :c nil} {:a 4.0 :b nil :c :e}] (map #(instance-to-map %1) (dataset-seq ds))))))
(deftest dataset-instance-predicates
(let [ds (make-dataset "test" [:a :b {:c [:d :e]}] [{:a 1 :b 2 :c :d} [4 5 :e]])
@ -228,4 +228,4 @@
[2 :bar]
[3 :bar]
[4 :foo]])]
(is (= (dataset-as-vecs (take-dataset ds 2)) [[1.0 "foo"] [2.0 "bar"]]))))
(is (= (dataset-as-vecs (take-dataset ds 2)) [[1.0 :foo] [2.0 :bar]]))))

View file

@ -183,8 +183,10 @@
{:attributes [0] :counts true :lowercase true
:stemmer "weka.core.stemmers.SnowballStemmer -S English"}
ds)))
'({:world 1.0, :this 0.0, :test 1.0, :is 0.0, :hello 1.0, :dog 1.0, :cat 1.0, :a 0.0, :class "no"}
{:world 1.0, :this 1.0, :test 1.0, :is 2.0, :hello 0.0, :dog 0.0, :cat 0.0, :a 2.0, :class "yes"})))))
'({:world 1.0, :this 0.0, :test 1.0, :is 0.0, :hello 1.0,
:dog 1.0, :cat 1.0, :a 0.0, :class :no}
{:world 1.0, :this 1.0, :test 1.0, :is 2.0, :hello 0.0,
:dog 0.0, :cat 0.0, :a 2.0, :class :yes})))))
(deftest make-apply-filter-add-attribute
(let [ds (make-dataset :test [:a :b {:c [:g :m]}]
@ -256,9 +258,9 @@
{:process inc-nums
:determine-dataset-format rename-attributes} ds)]
(is (= (map instance-to-map (dataset-seq res))
[{:foo 2.0 :bar 3.0 :c "g"}
{:foo 3.0 :bar 5.0 :c "m"}
{:foo 5.0 :bar 9.0 :c "g"}]))))
[{:foo 2.0 :bar 3.0 :c :g}
{:foo 3.0 :bar 5.0 :c :m}
{:foo 5.0 :bar 9.0 :c :g}]))))
(deftest make-apply-filter-clj-batch