-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
make {a,b}
give better-typed arrays [original title: make [a,b] non-concatenating]
#2488
Comments
Thought of a reason not to do this: |
Ah, good point. But that's also a degenerate comprehension, so maybe we could let people write |
Probably a better option is to make |
Overall I think improving the typing of
|
With the exception of Jeff's example above, I find the syntax for concatenation sketchy. More than once I've struggled to easily create arrays of arrays because I forget that I need to attach the type. For consistency, I would really prefer that anything with |
Very personally, I like Let me do a suggestion. Instead of the current behavior of
This is just another idea, I'm pretty aware that it would break a lot of stuff, and probably it would not cover all use cases. OTHO improving the typing of EDIT: Ok, sorry, I discovered now that @nolta's branch does exactly what I'd described. |
I'll try to show the problem the concatenating [a,b] creates to me.
I want to put all sparse matrices into a single (typed) array of sparse matrices. If I do
it is ok, it returns an array of sparse matrices. However,
tries to concatenate and thus gives a dimension mismatch. Doing
gives a 18x3 sparse matrix, not an array of sparse matrices. And
gives an array of sparse matrices, but the type is lost. Currently I see no way to do what I want without having to specify the type |
No, you have a good point. I think we all feel that |
Meanwhile, I was able to workaround the issue by using a function
that enables me to do
to obtain what I desired without having to explicitly write the type. |
Sorry to ask again: will these changes eventually land in master? I getting |
@cdsousa: just FYI there is so much awesome stuff being worked on in base Julia these days that this probably hasn't crested to the top of anyone's priority list yet. There's no predicting when it will, and I wouldn't be surprised if it took longer than you'd like. If you need it, your best bet might be to dive in and implement it yourself, and submit a pull request. |
I like the [1:5...] syntax - presumably making [1:5] being a single cell array with a Range object in it. Then you could do [1:5, 2:6] with two Range1 objects etc. |
Thanks @timholy! My question was put since I saw that there were commits in some branch about this issue, but no PR so far. I was wondering more about if this will get implemented than when. Only after, I saw in another issue #3737 that there is a shared desire to change the current behavior, so I can guess that the answer is yes:) Anyway, I'm very happy there is so much work being put into Julia, this issue is just a detail. |
I hadn't noticed the commit, thanks for clarifying. |
It's redundant with
[a;b]
, plus it creates the following trap for the unwary:The text was updated successfully, but these errors were encountered: