Currently, sel, and by extension $, have inconsistent behavior when returning a single row of a dataset. If 0 rows or 2+ rows are selected, the result is a dataset, but if 1 row is selected, the result is a vector.
(def dataset0 (dataset [:a :b :c] []))
(def dataset1 (dataset [:a :b :c] [[1 2 3]]))
(def dataset2 (dataset [:a :b :c] [[1 2 3] [4 5 6]]))
(def dataset3 (dataset [:a :b :c] [[1 2 3] [4 5 6] [7 8 9]]))
(= dataset0 ($ [] :all dataset3))
(= [1 2 3] ($ [0] :all dataset3))
(= dataset2 ($ [0 1] :all dataset3))
(= dataset0 ($ [:not 0] :all dataset1))
(= [1 2 3] ($ [:not 1] :all dataset2))
(= dataset2 ($ [:not 2] :all dataset3))
In both of these, and other similar cases, the behavior should be consistent:
(= dataset1 ($ [0] :all dataset3))
(= dataset1 ($ [:not 1] :all dataset2))
I have a pull request ready to go to implement this change, but I wanted to get feed back from the community as this could break existing code and requires changing one of the unit tests.
https://github.com/liebke/incanter/pull/143There is a related case, where a particular row is indexed (eg, 0 vs [0]). I don't have a strong opinion on this case, though it has been brought up before (
https://groups.google.com/forum/?fromgroups#!searchin/incanter/sel/incanter/OhGYASh6V_M/HPn9JQgne4wJ)
(= [1 2 3] ($ 0 :all dataset3))
Additionally, there is the question for columns, which have analogous behavior and for which I would make analogous arguments
(= [1 4 7] ($ :all [1] dataset3))