Skip to content

Commit

Permalink
more test cases for sel change
Browse files Browse the repository at this point in the history
  • Loading branch information
alexott committed Dec 26, 2012
1 parent 981db3e commit 004aaf8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/incanter-core/test/incanter/core_tests.clj
Expand Up @@ -39,6 +39,9 @@
(deftest dataset-tests (deftest dataset-tests
(is (= (sel dataset1 :cols :a) [1 4])) (is (= (sel dataset1 :cols :a) [1 4]))
(is (= (sel dataset1 :all 1) [2 5])) (is (= (sel dataset1 :all 1) [2 5]))
(is (= (sel dataset1 :all :b) [2 5]))
(is (= (sel dataset1 :all [:a :c]) (dataset [:a :c] [[1 3] [4 6]])))
(is (= (sel dataset1 :all :all) dataset1))
(is (= (sel dataset2 :cols :b) [2 5])) (is (= (sel dataset2 :cols :b) [2 5]))
(is (= (sel dataset2 :cols "c") [3 6])) (is (= (sel dataset2 :cols "c") [3 6]))
(is (= (sel dataset3 :cols :a) [1 4])) (is (= (sel dataset3 :cols :a) [1 4]))
Expand Down Expand Up @@ -198,6 +201,15 @@
;; use 'true' to select an entire row or column ;; use 'true' to select an entire row or column
(is (= (sel A :cols 2) (matrix [3 6 9 12]))) (is (= (sel A :cols 2) (matrix [3 6 9 12])))
(is (= (sel A :rows 1) (matrix [[4 5 6]]))) (is (= (sel A :rows 1) (matrix [[4 5 6]])))
(is (= (sel A :all [0 2]) (matrix [[1 3]
[4 6]
[7 9]
[10 12]])))
(is (= (sel A :all :all) A))
(is (= (sel A :all 2) (matrix [[3]
[6]
[9]
[12]])))
(is (= (sel A true true) A)) (is (= (sel A true true) A))
;; pass a vector of indices to select a set of rows and/or columns ;; pass a vector of indices to select a set of rows and/or columns
(is (= (sel A :cols [0 2]) (matrix [[1 3] (is (= (sel A :cols [0 2]) (matrix [[1 3]
Expand Down

0 comments on commit 004aaf8

Please sign in to comment.