New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sel (and $) return a list most of the times, but sometimes a single element #368
Comments
Sounds like there is a bug here to be fixed but we should think carefully about how to fix it, i.e. exactly what dimensionality the inputs and outputs of the problematic functions expect. 0D, 1D, 2D, ND etc.. Can you share the exact code you were having problems with? |
hi there and congrats for Vectorz :^) We need to verify if this is only related to the old incanter (1.5.7 "stable") or also the new one. Simple way to replicate the problem: (type ($ :1 (to-dataset [{:1 1 :2 2}])))
; java.lang.Long
(type ($ :1 (to-dataset [{:1 1 :2 2} {:1 3 :2 4}])))
; clojure.lang.LazySeq I'm suggesting that |
Any ideas on how to proceed on this? It is a corner-case for calls to
|
I think it should be consistent for any length of column.... i.e. any selection of a column should always return a vector, even if it only has one element. I think this is worth a breaking change, it is incredibly annoying to have to write special case code for stuff like this. It should be possible to use core.matrix's |
My assessment is that this won't be a breaking change if the solutions already adopted by developers affected is similar to the |
I recall some of this was refactored in the work a couple of years ago during the project to port Incanter to use core.matrix, but probably hasn't been fully cleaned up. In most cases, Incanter functions should be fairly lightweight wrappers over core.matrix operations, perhaps adding some extra optional arguments and functionality. From the first
It is important to note that this is actually selecting on two dimensions! The first |
If a dataset selection returns only a single element the type of the result changes and breaks most functions accepting it, generating a confusing error that may be hard to guess.
By wrapping the returned type of sel with a
coll?
check it is possible to convert it into a single element list so that in any case the calling function can assume that the returned value will always be a list.Example:
Can we integrate this into the
sel
function?The text was updated successfully, but these errors were encountered: