-
-
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
reshape with zero dimensions #45589
Comments
What shape do you expect it to return? |
@giordano |
Why not |
@giordano `(0,4) is the original size. I'd say it should prefer that? |
Then my next question would be why you're reshaping it if you want to keep the same shape 🙂 |
Okay. How about |
I think it's reasonable to expect it to be consistent with this: julia> reshape(zeros(0,4), Val(2))
0×4 Matrix{Float64} |
Heh, never realized this works, though of course it makes sense:
Still it seems to me the example in the OP might as well work. |
Anything goes, so it should be able to return without an error... |
This discussion in the Julia Discourse might be relevant. I think if the returned array's shape is the same as the input array's shape and the input array is a container of plain data (e.g. |
In the meantime I opened an issue that turns out to partially duplicate this one: #54245 Then I fixed it in #54261 (not in v1.11). Perhaps the sizing for empty arrays should be considered again? The linked PR implements this behavior: julia> a = randn(0,4)
0×4 Matrix{Float64}
julia> size(reshape(a, 0, :))
(0, 0)
julia> ans == size(reshape(a, Val(2)))
false |
I think this should be able to return without error.
The text was updated successfully, but these errors were encountered: