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

make sub() behave like ref() #721

Merged
merged 3 commits into from
Apr 16, 2012
Merged

Conversation

carlobaldassi
Copy link
Member

i.e. drop trailing singleton dimensions, as discussed here.

Example:

julia> a = rand(2, 3, 2)
2x3x2 Float64 Array:
[:, :, 1] =
 0.121652  0.232535  0.0812166
 0.347117  0.224052  0.885407 

[:, :, 2] =
 0.626699  0.342665  0.163809
 0.253675  0.659507  0.922081

julia> sub(a, 1:2, 2, 1)
2-element SubArray of 2x3x2 Float64 Array:
 0.232535
 0.224052

I think it's correct, but since it's not a trivial change, I'll leave it here for review/further discussion instead of pushing it directly.
Also, there's still a difference in behaviour, since sub still only allows either 1 index or the same number of indices as the parent array, but I think it was decided it's ref which has to change in that case.

i.e. drop trailing singleton dimensions
@@ -1,4 +1,4 @@
## subarrays ##
e# subarrays ##
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an accidental edit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the catch!

@JeffBezanson
Copy link
Sponsor Member

Looks good, but we need to abstract out the function that determines shape from indexes. When we do that this will have to be edited again.

@carlobaldassi
Copy link
Member Author

So if there are no objections I could merge this now to get the functionality, and we'll refactor the code when the abstraction for determining shape from indices is provided.

@StefanKarpinski
Copy link
Sponsor Member

Go for it.

carlobaldassi added a commit that referenced this pull request Apr 16, 2012
@carlobaldassi carlobaldassi merged commit 4c782a7 into JuliaLang:master Apr 16, 2012
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.

None yet

4 participants