Skip to content

Add keyword indexing + constructor#177

Merged
timholy merged 7 commits into
JuliaArrays:masterfrom
mcabbott:keywords
Feb 6, 2020
Merged

Add keyword indexing + constructor#177
timholy merged 7 commits into
JuliaArrays:masterfrom
mcabbott:keywords

Conversation

@mcabbott

@mcabbott mcabbott commented Jan 27, 2020

Copy link
Copy Markdown
Contributor

This adds the following behaviour:

A = AxisArray(rand(2,5), x=[:a, :b], y=11:15)
A[x=:a]
@btime A[x=:a, y=1] # 5 ns, 0 allocations

I think this was discussed somewhere.... only this comment perhaps?

Edit: this also closes #174, because you can write

A[x=:b, y=13..14]
A[x=:b, y=atvalue(13)]

@timholy

timholy commented Feb 2, 2020

Copy link
Copy Markdown
Member

This seems like a nice improvement in usability. Let's give folks a couple more days to express concerns, and then I'd favor merging.

@mcabbott

mcabbott commented Feb 2, 2020

Copy link
Copy Markdown
Contributor Author

Excellent. Should I have a go at updating the readme to use this?

@timholy

timholy commented Feb 4, 2020

Copy link
Copy Markdown
Member

Given the lack of expressed concerns, sure, that would be great! Note that in addition to the README itself there is a test/readme.jl file.

@mcabbott

mcabbott commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

OK, have added the keyword indexing lines to test/readme.jl too. Have not touched docs/index.md.

I had a go at inserting a paragraph explaining that you can now use keywords, at the top of the readme. It's not great but see what you think?

@mcabbott

mcabbott commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

Test failure was my fault, in that JuliaMath/IntervalSets.jl#57 causes .. to come from EllipsisNotation.jl, and that has a method for A[..]. Should be fixed, except on 1.0.

@timholy timholy merged commit c09954f into JuliaArrays:master Feb 6, 2020
@timholy

timholy commented Feb 6, 2020

Copy link
Copy Markdown
Member

Thanks for a lovely PR, @mcabbott!

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.

How to select a subset of an AxisArray by keyword?

2 participants