-
Notifications
You must be signed in to change notification settings - Fork 25
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
Unexpected behaviour with iterator constructors #83
Comments
Just leaving this here for reference. Disallowing iterators in the call might not be so limiting if something like #33 is implemented. Currently it is already possible to use julia> tb = Table(; A=Int[], B=Int[], C=Int[])
Table with 3 columns and 0 rows:
A B C
┌────────
julia> colnames = columnnames(tb)
(:A, :B, :C)
julia> push!(tb, (; zip(colnames, fill(1, length(colnames)))...))
Table with 3 columns and 1 row:
A B C
┌────────
1 │ 1 1 1
julia> push!(tb, (; zip(colnames, fill(2, length(colnames)))...))
Table with 3 columns and 2 rows:
A B C
┌────────
1 │ 1 1 1
2 │ 2 2 2 |
This is actually a well-known problem with
|
Here's possibly a clearer example of what's going on @adigitoleo:
Does that make sense? With the |
We could potentially check if any two columns are I'm not sure we can do more without changing the language (e.g. add an ownership model like Rust) - so the status-quo is advising to take care when mutating things. |
@andyferris Thanks for clearing that up. I'm pretty new to Julia so I wasn't aware of this. I agree with your other points, and the way you showed for how to generate the columns should work fine. Thanks for the package! |
Follow up from my last comment from today in #82. It seems there are a few similar issues so I'll close this if you want, but this isn't about implementing a new interface so much as stabilising what we have.
Constructing either a
Table
or aFlexTable
using an iterator seems to have unpredictable consequences. Specifically, subsequentpush!
operations are duplicated (by the number of columns?):For examples using
Table
see the linked issue. I think it's better to block iterator constructors completely rather than have this behaviour. Note that I'm just following what the example in ?NamedTuple suggests:The text was updated successfully, but these errors were encountered: