JuliaArrays / AxisArrays.jl

Performant arrays where each dimension can have a named axis with values
http://JuliaArrays.github.io/AxisArrays.jl/latest/
Other
200 stars 41 forks source link

Add keyword indexing + constructor #177

Closed mcabbott closed 4 years ago

mcabbott commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

timholy commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

timholy commented 4 years ago

Thanks for a lovely PR, @mcabbott!