-
Notifications
You must be signed in to change notification settings - Fork 37
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
Tuple comprehension does not work with map #101
Comments
It's probably because: julia> IndexedTables._promote_op(i -> Tuple(getfield(i, j) for j in s), typeof(t[1]))
Tuple{Any}
I think in this case we can't infer the output type of the lambda. The right thing to do here is return an Use julia> map(IndexedTables.astuple, t)
Table with 10 rows, 2 columns:
1 2
────────────────────
0.0824641 0.69732
0.953091 0.722422
0.335519 0.0399266
0.368203 0.319559
0.854868 0.783442
0.208625 0.961055
0.498797 0.347901
0.948223 0.433926
0.370459 0.808366
0.297149 0.0867216
|
Thanks for looking into this and for the tip! My concern came from the following inconsistence: julia> map(i -> Tuple(getfield(i, j) for j in s), t)
10-element Array{Any,1}:
(0.205925, 0.290762)
(0.720414, 0.145541)
(0.992084, 0.709543)
(0.116492, 0.285352)
(0.734721, 0.146378)
(0.958972, 0.180972)
(0.539473, 0.178098)
(0.748478, 0.402817)
(0.449255, 0.0980809)
(0.873253, 0.473562)
julia> map(i -> Tuple(getfield(i, j) for j in s), (i for i in t))
10-element Array{Tuple{Float64,Float64},1}:
(0.205925, 0.290762)
(0.720414, 0.145541)
(0.992084, 0.709543)
(0.116492, 0.285352)
(0.734721, 0.146378)
(0.958972, 0.180972)
(0.539473, 0.178098)
(0.748478, 0.402817)
(0.449255, 0.0980809)
(0.873253, 0.473562) where the "normal" |
I'm using |
A related issue happens with Query (one can't select columns programmatically with a |
Yeah, looks like the same issue as in Query.jl. I have a plan to move to an implementation like in base |
I think that's a great idea! On the plus side, that should:
|
I agree on 1, but disagree on 2 :) I think not relying on type inference is actually easier with |
I found a mysterious bug: in
map
, if I use a function outputting a tuple that I write explicitly, everything works. If instead the tuple is a result of a tuple comprehension, it only stores the first column.The text was updated successfully, but these errors were encountered: