Skip to content

Indexing by an array of values#97

Merged
ajkeller34 merged 2 commits intoJuliaArrays:masterfrom
ajkeller34:morevalue
Aug 13, 2017
Merged

Indexing by an array of values#97
ajkeller34 merged 2 commits intoJuliaArrays:masterfrom
ajkeller34:morevalue

Conversation

@ajkeller34
Copy link
Copy Markdown
Collaborator

Now that #52 has been merged, this PR attempts to address #84, except for the "by default" part. Simply broadcast atvalue:

julia> A = AxisArray(rand(7), Axis{:x}(-3:3))
1-dimensional AxisArray{Float64,1,...} with axes:
    :x, -3:3
And data, a 7-element Array{Float64,1}:
 0.44085 
 0.77351 
 0.192314
 0.904178
 0.912603
 0.485005
 0.730789

julia> A[atvalue.([-2,1])]
1-dimensional AxisArray{Float64,1,...} with axes:
    :x, [-2, 1]
And data, a 2-element Array{Float64,1}:
 0.77351 
 0.912603

With many dimensions, I concede that typing atvalue repeatedly might become tiresome. Perhaps in some follow-up PR I might implement a macro (@value?) for splicing atvalue repeatedly into an expression if a user wants to index all dimensions by value. I would guess that should be possible though I haven't tried or thought too deeply about it.

@ajkeller34
Copy link
Copy Markdown
Collaborator Author

Hmm, I guess this doesn't work on 0.5. The failures are related to the broadcasting changes in 0.6, so this is blocked until 0.5 support is dropped for AxisArrays.

@timholy
Copy link
Copy Markdown
Member

timholy commented Jul 9, 2017

I have no reservations about dropping 0.5 now, though perhaps we should finish & merge #90 (and then tag) first?

@ajkeller34
Copy link
Copy Markdown
Collaborator Author

I'm in no hurry to merge this. I'm not sure what is left to do in #90 (seems like requiring 0.6 is the simplest solution?) but let me know if I can help somehow.

@timholy
Copy link
Copy Markdown
Member

timholy commented Aug 6, 2017

#102 has been merged, so the way is clear here.

@ajkeller34 ajkeller34 closed this Aug 12, 2017
@ajkeller34 ajkeller34 reopened this Aug 12, 2017
@ajkeller34 ajkeller34 merged commit 83b4fde into JuliaArrays:master Aug 13, 2017
@ajkeller34 ajkeller34 deleted the morevalue branch August 13, 2017 19:05
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.

2 participants