Skip to content
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(::Array, Val{N}) always returns an Array #18160

Merged
merged 2 commits into from
Aug 21, 2016
Merged

Conversation

timholy
Copy link
Sponsor Member

@timholy timholy commented Aug 20, 2016

We have a convenience method, reshape(A, Val{N}), that reshapes to N dimensions, "collapsing" trailing dimensions if ndims(A) > N. However, one can also use this to "extend" dimensions, adding trailing 1s to the indices. When the array was an Array, we were returning an Array for ndims(A) >= N but not for ndims(A) <= N.

This was only a couple-line change, but I took the opportunity to move a few lines of code around to help clarify the organization.

@timholy timholy merged commit eca2083 into master Aug 21, 2016
@timholy timholy deleted the teh/reshape_Val branch August 21, 2016 14:12
tkelman pushed a commit that referenced this pull request Aug 21, 2016
(cherry picked from commit a3e6fcf)
ref #18160

reshape: only call to_shape when it will return Dims

(cherry picked from commit d92b2db)
@andyferris
Copy link
Member

I didn't know about this method. I need to be careful with StaticArrays because this is the obvious way to reshape them (with standard dimension sizes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants