-
-
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] not concatenate #3737
Comments
If you specify the type of an array when constructing it, Julia doesn't attempt to
I think you want julia> [uint8(1):uint8(3), uint8(4)]
4-element Uint8 Array:
0x01
0x02
0x03
0x04 |
It was supposed to be the case that Then the waters were muddied a bit by the definition (array.jl:173) that allows We could go farther down this road and allow |
I still think this is probably a good idea. It would expand and clarify the distinction between |
+1 |
I would actually love to remove all concatenating behaviour apart for |
It appears to be unanimous! |
Deprecation warnings for concatenation could be a good start at least. |
We can turn them into a call to |
What's the replacement for concatenating vcat? |
And how does this fix the issue:
|
I would allow |
And the question is whether |
Ah yes, that is an issue too. Drat. |
Color me amazed that the idea of making |
Oops closed wrong issue. |
Honestly, I'm fine with it. |
How about letting |
Probably the biggest issue is that |
Even though |
Ok, i've implemented both options:
Personally, i prefer (1), and would rather do nothing than (2). |
The style-guide section of the manual http://docs.julialang.org/en/latest/manual/style-guide/#don-t-overuse will need to be updated when this behavior is changed. |
I have a growing urge to merge the |
What about the |
The feeling is that concatenation is the "weird" behavior, so we shouldn't suddenly switch to it when n=1: |
Although I admit that n=1 also has a "feel" of its own, which makes |
Also, while the |
I found myself needing an array of ranges and blithely began constructing it julia> [1:2, 4:8]
7-element Array{Int64,1}:
1
2
4
5
6
7
8 Only to discover that I was getting concatenation for free, but it's not what I was expecting. julia> Range1[1:2, 4:8]
2-element Array{Range1{T<:Real},1}:
1:2
4:8 |
Just encountered this with generating array indices. The silent expansion of ranges is really quite confusing and a potential performance gotcha. A=randn(5,5)
A[[1:2, 4:5], :] #4x5 Array{Float64,2}
A[[], :] #0x5 Array{Float64,2}
A[Range[1:2,4:5], :] #no method error
A[Range[], :] #no method error |
I believe we need to be able to create array of ranges in a concise way. For example, "[1:5, 1:3]" should be an array of two ranges: "1 to 5" and "1 to 3". |
This works:
and this works:
but this doesn't:
Is this expected behavior? I would expect to be able to construct Uint8 arrays this way.
The text was updated successfully, but these errors were encountered: