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

AllIndices type for identity indexing #24069

Closed
ChrisRackauckas opened this issue Oct 9, 2017 · 4 comments
Closed

AllIndices type for identity indexing #24069

ChrisRackauckas opened this issue Oct 9, 2017 · 4 comments

Comments

@ChrisRackauckas
Copy link
Member

With the proposal for #22858, I've been thinking it could be useful to have a type which commonly represents "AllIndices". So A[AllIndices()] would return A, making it the identity indexing element in some sense.

The reason is so that this could handle non-standard indexing. In some algorithms you might want the user to specify some indices that they "want to save", and you can default to AllIndices. In many of these cases, you haven't built the array yet and may be getting a non-standard type from the user, so defaulting to eachindex or something like that isn't possible. Currently a way to handle this is to default the chosen indices to nothing, and if you see nothing you treat it as AllIndices applied to the type by iterating eachindex after the array is built.

The name could change of course.

@mbauman
Copy link
Sponsor Member

mbauman commented Oct 9, 2017

How is this different from A[:]? Edit: duh, A[:] will reshape to a vector.

@ChrisRackauckas
Copy link
Member Author

Colon doesn't keep shape:

julia> A = rand(2,2)
2×2 Array{Float64,2}:
 0.138581  0.120538
 0.528131  0.11805

julia> A[:]
4-element Array{Float64,1}:
 0.138581
 0.528131
 0.120538
 0.11805

@mbauman
Copy link
Sponsor Member

mbauman commented Oct 9, 2017

This could be solved with #5405 as a base case (just the ellipsis).

@mbauman
Copy link
Sponsor Member

mbauman commented Oct 9, 2017

Now this is a duplicate of #5405. A single ellipsis represents this operation well, and it's now in EllipsisNotation.jl as A[..].

@mbauman mbauman closed this as completed Oct 9, 2017
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

No branches or pull requests

2 participants