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 42 forks source link

WIP: Stash axes into indices #58

Closed mbauman closed 7 years ago

mbauman commented 7 years ago

Does not fully work yet, but I think this may be a viable approach. It makes things like broadcasting "just work". Not sure when I will get a chance to finish this... I have been slowly iterating bit by bit over the past few weeks.

timholy commented 7 years ago

I'd been toying with this notion too. Excited that you tried it! I cloned this and will start playing with it.

mbauman commented 7 years ago

It does make the Axis type rather strange — it becomes an AbstractUnitRange, acting like the linearindices of the value it wraps. Kinda. Right now I have ax[2] == 2 but ax[2:end] == OneTo(length(ax)-1) for a one-based axis, which is particularly bizarre.

But once you wrap your head around that bit of backwardness, it seems to make sense. Feel free to push directly to this branch.

timholy commented 7 years ago

I still like this idea in principle, but after playing with it a bit I'm concerned that the dual interpretations of "value" (as an AbstractUnitRange and whatever AbstractVector the user supplied) are at risk for serious confusion. For now I'm going to continue #57 using a more conservative approach, but this still merits further investigation.

mbauman commented 7 years ago

Yeah, I think this is trying to do too much with the Axis type. I had been hoping that this would work… and that we could rename Base.indices() to Base.axes(), which would help with the too-many-indices problem when describing how the indices you use to index with must be within the indices of the array.

I may still try to make this work with an IndicesWrapper that does the backwards "indices of the axes are the values of the type" operation.