-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Rename indices
to axes
#25057
RFC: Rename indices
to axes
#25057
Conversation
adb04ee
to
25df693
Compare
Right -
Sometimes, there's nothing like some code to turn discussions into action (and feature freeze is upcoming, so it seemed worth making a start, or forgetting about it entirely). |
indices
to indexes
indices
to axes
The PR now replaces |
b3df872
to
8cd5192
Compare
Completely subjective, of course, but I got stuck more than once assuming |
+1 |
8cd5192
to
2dab3fd
Compare
@JeffBezanson: it's a bit hard to tell what your +1 is in reference to. |
Triage generally agrees with this rename from
It seems like the package is really about giving names and units to dimensions, I'm not sure what the "and axis values" at the end of the sentence actually means and kind of feel like it's just a post-hoc justification of the package name. Sorry, I don't mean to come off as snarky (it's a great package), but I think this proposed usage of |
I think that we should also move all of our |
Is this possible for v1.0? If that's desired, then we can choose one of:
|
2dab3fd
to
7fa7b22
Compare
Ah, you mean the collision because |
Yes, exactly. |
Hmm. That is a bit tough, but might be workable... |
7fa7b22
to
8f7ba49
Compare
@andyferris why did you merge this? In general you should be letting someone else do it or at least approves it. If you don’t get a review, posting “will merge in X days” is also sometimes necessary. Also, it looks like CI was not yet finished running. |
Actually, it looks like CI hasn’t even started yet here. I think we should quick revert this and reopen the PR. |
Triage seemed pretty definitive, and I assumed we're trying to clear the slate of v1.0 milestone items relatively quickly. Is this a general thing that we won't merge PRs we open ourselves? Sorry if I was being too hasty.
CI did a full run, then I did a quick rebase and my local and the Linux CI tests passed before I merged. Sorry again if I'm being too hasty - but I did put in some effort to make sure that the build wouldn't break from merging this. |
Did this break the build or no? |
Doesn't seem like it. I think the new name is better, so I'm cool with this. |
If CI had been permitted to run (most of them were unable to run), then we wouldn't have to be wondering this. I think the new name is fine too. I'm frustrated only in that Andy didn't push a revert commit, reopen the PR to run CI, and let someone else review or merge it. |
It's done now and and it didn't break the build, so let's carry on. |
Should |
It's also possible we don't need axes(A, d) = d > ndims(A) ? Base.OneTo(1) : axes(A)[d] But now that branch may disappear all by itself. |
Interprocedural constant prop is the Christmas gift from @vtjnash that keeps on giving! ❤️ |
The Different discussions around this issue
What is the advise here? Should |
After reading through the subject (before I just wanted to track down the error) my vote is to rename The point is that we always have to distinguish between axes that are represented by their integer and axes that are represented by the physical units. I actually would call the later an It is not possible to get both concepts under the same hood. Since |
Axes in Echoing @timholy's comment, I wonder if there's another term that could be used. He suggested |
I'm not a fan of the See also a similar comment by @StefanKarpinski above. |
@nalimilan: I don't see the issue with merging AxisArrays and NamedArrays. Is there something in NamedArrays that is not provided by AxisArrays? I would say that AxisArrays already is a pretty central part of the Julia ecosystem (through the use in Images.jl) and although this is certainly a little offtopic, AxisArrays would be a pretty good candidate for shipping as part of stdlib (depends how the later evolves). Regarding the axis terminology I still find it pretty natural and after reading wikipedia: https://en.wikipedia.org/wiki/Cartesian_coordinate_system it still fits from my understanding. Whatever action is done here (changing Base.axes or rename AxisArrays.axes or even rename AxisArrays) this needs to be done prior to 0.7 release. Changes in AxisArrays (and all(!) depending packages) is a major change that requires bandwidth of several package authors in particular of Tim Holy. This does not mean that it should not be done but it should be kept in mind. |
I haven't followed the development progress very closely recently, but off the top of my head AxisArrays don't support broadcasting yet, and the printing of NamedArrays is much nicer for categorical axes (see examples here). But these can be improved. My point here was just that axes is certainly not the most intuitive term for many applications (e.g. frequency tables), precisely because it refers to numerical coordinates. |
I'm working on getting myself back up to speed here. AxisArrays is long overdue for some love and a stronger direction. It's been torn between two schools of thought: is the axis information simply annotated metadata, with integer offsets still serving as the canonical indexing method? Or are the values in each axis the canonical (and only) set of indices available in the When I tried to merge The rename here is definitely an improvement — it makes way more sense that this function returns a collection of (axis) vectors if it's called |
@mbauman: Will this be a more experimental development or do you have a clear plan? Just asking since we need a solution for 0.7 if |
I tend to agree with @mbauman. The more I think about how I a (possibly mulitidimensional) I see the integer offsets (AND linear indexing of standard, multidimensional arrays) as tokens that let you get values (and maybe keys) quickly. I'd tend to think about introducing some kind of |
No, I don't have any concrete plans at the moment, and it's such a big change I'd like to put together a more cohesive proposal and seek consensus before enacting it. |
I'm not sure if this is the appropriate place to continue this conversation—shall I split this off into an AxisArrays issue?—but in any case I wanted to offer some perspective that touches on issues more general than AxisArrays. For AxisArrays, I still think integer offset indexing is useful, and would find it troublesome to have to type out Main message: I feel like a lot of confusion could be avoided were it not for the fact that
Aside: I'm using AxisArrays to store the result of measurements. AxisArrays is good for this because you typically have some set of knobs you want to turn in a measurement and a concrete type for the measurement result. In this case, abstracting away the underlying storage order of the axes is actually undesirable. The first axis is the "fast axis," i.e. the measurement knob that is turned most frequently, and each successive axis is a measurement knob that is turned less frequently. That's potentially a physically meaningful distinction. Doing things in a different order could give different measurement results, therefore I want an Array with named axes, not a Dict with named axes. |
I also use AxisArrays as a simple Array (with storage order) where I have the opportunity to encode the physical meaning into the array. Integer indexing is absolutely essential here. Indexing with boating point values (and/or units) might be nice in some circumstances but it is certainly not the only use case. |
I had a more radical (crazy?) proposal which was to make I also have sometimes wondered if (BTW, I can totally see that AxisArrays are useful as-is! But what occurs if my meaningful axis values really are |
In my most recent and often changing view, indexing method signatures are only ambiguous because people should be using I proposed using a macro to index by value in JuliaArrays/AxisArrays.jl#118. I can understand maybe that's not appealing and also had some reservations at the time. I guess alternatively one could have a macro for integer indexing and default to indexing by axis value. That could work for how I use AxisArrays with some adjustment period. I don't know though, I guess ultimately I feel like an AxisArray should be respected as an array and not a dict. Just to throw another random thought out there, perhaps another type could be defined that shares a lot of AxisArrays machinery but for which indexing is by axis value. |
I think this discussion would be best done as an issue on AxisArrays — issue JuliaArrays/AxisArrays.jl#84 is probably a great place for it to live. |
I think this has been discussed in a few places - the most obvious reference is #23434. I figured it would be worth giving this a shot before feature freeze.
To me,
indices
is not the ideal name for this function. Currently,indices
is defined on n-dimensional arrays to be a n-tuple of ranges for each dimension of the array.I feel that the indices of an indexable container would probably be the collection of things you can index with, which is currently what the
keys
function does. In #23434 several candidate replacements were suggested, includingaxes
,indexvectors
, ...I'm proposingThis PR now implementsindexes
here (an index can be a collection of individual entries, as in the index of a book; this function returns a collection of indexes) - but happy to discuss. (There's lots of other options...dimranges
?)axes
.Going further, I feel there is a bit of discord between "keys" and "indices", since we have
keys
andhaskey
as doing discovery of things we can dogetindex
andsetindex!
with. I don't see the advantage on forcing users to learn and use multiple words for the same concept. We could consider harmonizing like so:getindex
getindex
getkey
setindex!
setindex!
setkey!
keys
indices
orindex
keys
haskey
hasindex
haskey
Personally, I'd prefer the "index" version.
Of course this goes well beyond this PR, but it is something that may motivate (and explain my motivation for) merging this PR's deprecation of
indices
for v0.7.