I find myself writing a lot of this:
A = reshape(A, N, div(length(A), N))
Instead, I'd like to write
A = reshape(A, N, :)
IIRC, Python uses a -1 to achieve what you propose. I have to say that I never really liked it so much, and : looks way cleaner.
More generally,
B = reshape(A, N1, N2, N3, :)
etc; (should be a fairly easy hack?)
Yes I love this. Have wanted it so many times.
Even more generally, allow a single colon in any position:
B = reshape(A, N1, :, N3, N4)
Should still be perfectly implementable.
I remember proposing this a while ago in some issue and it wasn't generally liked.
I forget what the objection was before. Seems like a reasonable thing to me. It's possible that it was before :
became a thing we could dispatch on.
didn't :
use to have to be handled by the parser until not that long ago?
@malmaud I think it was https://github.com/JuliaLang/julia/pull/4263 (search term)
sorry I missed PR - anyhow it would be great if this feature could now be added
I can revamp that PR, but maybe one of the array experts like @mbauman or @timholy can way in on what they think of this idea.
+1. I think it's handy and useful. That's why I tried resurrecting your PR… but it got no traction at the time. Anyone's welcome to update either of my old commits and try it again. At a minimum the tests should be useful.
I feel like this is a common usage pattern and would be nice to have in Julia. MATLAB, for example, uses empty [] to tell reshape to compute the missing dimension: https://www.mathworks.com/help/matlab/ref/reshape.html#examples
Most helpful comment
I can revamp that PR, but maybe one of the array experts like @mbauman or @timholy can way in on what they think of this idea.