# Commit to a common syntax for accessing additional index mapping information on axes

**URL:** <https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988>\
**Category:** Data\
**Created:** [July 29, 2022, 4:38pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988 "2022-07-29T16:38:47Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 12, 2022, 3:22am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/41 "2022-08-12T03:22:36Z")

</div>

I’m assuming that’s short for coordinates?

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [August 12, 2022, 8:16am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/42 "2022-08-12T08:16:54Z")

</div>

Yes, I think they call these values coordinates, and use “coords” in function/property names.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 12, 2022, 9:28am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/44 "2022-08-12T09:28:30Z")

</div>

I think there’s been a misunderstanding here. We already have agreed to `dimnames` for that use case. What this discussion is referring to has a label for each value along an axis. It’s often not a symbol or string.

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [August 12, 2022, 11:24am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/45 "2022-08-12T11:24:36Z")

</div>

Ohhh, sorry for the noise.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 12, 2022, 5:03pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/46 "2022-08-12T17:03:46Z")

</div>

Coordinates conflicts with its use in the geometry ecosystem.

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [August 12, 2022, 5:18pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/47 "2022-08-12T17:18:36Z")

</div>

> [@Zach\_Christensen](#):
>
> From the discussion it seems like those who wanted `axiskeys` would be fine with something similar like `axislabels`, which would resolve some of the overlap with `keys`.

FWIW, I voted for `axiskeys`, and I still prefer it over `axislabels`. As someone above said, it can be argued that it’s `Base.keys` that should have been `Base.indices`, with `keys` being more appropriate for the more generic use here. Regardless of that, even as things stand currently, I see the similarity with `keys` as a feature of `axiskeys`, not a bug.

`axislabels` is a sort of vague and generic name that one could get used to - the positive side of that is that it isn’t misleading like `axisvalues` or `axisnames`. But the negative is that, by itself, it doesn’t invoke an image of what it is.

`axiskeys` is much closer to being self-documenting in that regard.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 13, 2022, 5:29am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/48 "2022-08-13T05:29:35Z")

</div>

> [@digital\_carver](#):
>
> FWIW, I voted for `axiskeys`, and I still prefer it over `axislabels`. As someone above said, it can be argued that it’s `Base.keys` that should have been `Base.indices`, with `keys` being more appropriate for the more generic use here. Regardless of that, even as things stand currently, I see the similarity with `keys` as a feature of `axiskeys`, not a bug.

I understand where you’re coming from but I think we need to accept that there were logical reasons `keys` ended up being defined in base the way it is (even if we don’t find that logic particularly compelling) and we need to accept that it isn’t going to change anytime soon. I think the the issue with `axiskeys` isn’t really that it’s a bug. It just sounds like it means `keys(axes(data, dim))`. It’s also arguable that what we are discussing isn’t considered “keys” in the fullest sense of the term.

Depending on where you stand both “labels” and “keys” are ambiguous terms for this application. The question really is which of these will be the most comfortable to use by everyone for the foreseeable future.

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [August 13, 2022, 6:17am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/49 "2022-08-13T06:17:31Z")

</div>

> I think the the issue with `axiskeys` isn’t really that it’s a bug.

Just to be clear, I didn’t mean “bug” in a literal sense there. I was using the “it’s a feature, not a bug” idiom/meme to say that `axiskeys` sounding similar to `keys` is a positive, not a negative.

It’s a good thing in design when we can re-use existing mental models, and Julia programmers have a mental model about `keys` - something that’s on the index side of a collection rather than on the value side (whether that’s hashable keys on a `Dict` or symbols in a `NamedTuple`).

So, I think it’s more likely that the name `axiskeys` _helps_ people understand it more easily, based on that conceptual idea of what keys are. The positives of reusing that mental model are significant, and overweigh the chances that someone takes a more literal interpretation like `keys(axes(data, dim))`.

All that said, I don’t strongly dislike `axislabels` as the term for this. It would be my second choice among the discussed options. But `axiskeys` seems clearer and crisper (as in less vague) to me.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 14, 2022, 3:09pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/50 "2022-08-14T15:09:30Z")

</div>

> [@digital\_carver](#):
>
> It’s a good thing in design when we can re-use existing mental models, and Julia programmers have a mental model about `keys` - something that’s on the index side of a collection rather than on the value side (whether that’s hashable keys on a `Dict` or symbols in a `NamedTuple`).
> 
> So, I think it’s more likely that the name `axiskeys` _helps_ people understand it more easily, based on that conceptual idea of what keys are. The positives of reusing that mental model are significant, and overweigh the chances that someone takes a more literal interpretation like `keys(axes(data, dim))`

For the most part I agree with this and have mostly just been trying to give a fair voice to all sides of the discussion.

The one compelling reason I personally have for avoiding “keys” is that the entire dictionary interface isn’t fully developed in Julia. There may be future requirements for that interface relating to keys and we might end up building a set of methods that are somewhat ill fit for this hypothetical dictionary interface.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [August 15, 2022, 6:34am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/51 "2022-08-15T06:34:49Z")

</div>

> [@Zach\_Christensen](#):
>
> Coordinates conflicts with its use in the geometry ecosystem.

What exactly is the conflict? Yes, the “coordinates” term is used in geometry as well — but to me, it seems the same kind of “conflict” as “labels” are with plot and table labels. That is, not really confusing at all.  
And compared to labels, coordinates have the benefit of being more general, in my opinion.

> [@Zach\_Christensen](#):
>
> The one compelling reason I personally have for avoiding “keys” is that the entire dictionary interface isn’t fully developed in Julia. There may be future requirements for that interface relating to keys and we might end up building a set of methods that are somewhat ill fit for this hypothetical dictionary interface.

Curious if there’s anything to read on this. There are alternative dict implementations/interfaces such as [GitHub - andyferris/Dictionaries.jl: An alternative interface for dictionaries in Julia, for improved productivity and performance](https://github.com/andyferris/Dictionaries.jl), but they all seem to share the same concept of keys. What kind of conflict do you foresee? And what’s the relation between dicts and “axis arrays”?

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 15, 2022, 4:40pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/52 "2022-08-15T16:40:06Z")

</div>

> [@aplavin](#):
>
> What exactly is the conflict? Yes, the “coordinates” term is used in geometry as well — but to me, it seems the same kind of “conflict” as “labels” are with plot and table labels. That is, not really confusing at all.  
> And compared to labels, coordinates have the benefit of being more general, in my opinion.

Coordinates is more problematic because an array can have a coordinate system that isn’t this axis lookup/label we are after. It is also more confusing if we have an array of coordinates with coordinates. Yeah we know what it means because of the context and functional definition we’ve created, but I think it loses all intuitive meaning at that point.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 16, 2022, 3:45am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/53 "2022-08-16T03:45:05Z")

</div>

> [@aplavin](#):
>
> Curious if there’s anything to read on this. There are alternative dict implementations/interfaces such as [GitHub - andyferris/Dictionaries.jl: An alternative interface for dictionaries in Julia, for improved productivity and performance](https://github.com/andyferris/Dictionaries.jl), but they all seem to share the same concept of keys. What kind of conflict do you foresee? And what’s the relation between dicts and “axis arrays”?

I’m not aware of any effort to standardize the dictionary interface to the extent that Dictionaries.jl has. As far as conflicts, even conforming to Dictionaries.jl would be problematic because the keys would need to subtype `Dictionaries.AbstractIndices`. Even using a similar approach would be problematic because the Dictionary.jl approach to keys requires that `key(dict)[key] == key`, which is not how a lot of people want this particular feature to work.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [August 17, 2022, 3:56am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/54 "2022-08-17T03:56:31Z")

</div>

I still don’t get how the Dict/Dictionary interface is related to this discussion of arrays…

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 17, 2022, 6:23pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/55 "2022-08-17T18:23:23Z")

</div>

The argument for keys is that it’s self documenting because we use the term keys in Julia as the look up associated with a value. Keys are really defined as part of the dictionary interface though and as it becomes more well defined keys can take on a stricter meaning in Julia. As that interface matures our intent to self document this feature as returning a set of keys may be misleading. People may wonder why the indexing operation on keys isn’t reflective like we see in Dictionaries.jl or returns a hash look up into the buffer of values.

The point is that if the interface for dictionaries develops anymore (which we probably all want) then keys will take on additional meaning that we aren’t prepared to commit to for this new syntax we’re discussing. When that happens some people will be returning something that isn’t really what Julia defines as “keys” anymore.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [August 17, 2022, 8:03pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/56 "2022-08-17T20:03:17Z")

</div>

Ah, now I see why you mentioned dicts at all.  
As this thread is about arrays, I only thought of regular array keys: Julia uses keys and indices as basically synonyms. Then something like `axiskeys` can be read as a generalization of array keys/indices, which it actually is.  
Not sure if dict-related considerations should be taken into account here. The Julia array interface is very stable and is (I hope) unlikely to change, should only be extended when needed. And keys are an integral part of this interface, so their meaning will stay in the array context.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [August 17, 2022, 8:05pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/57 "2022-08-17T20:05:33Z")

</div>

> [@Zach\_Christensen](#):
>
> Coordinates is more problematic because an array can have a coordinate system that isn’t this axis lookup/label we are after. It is also more confusing if we have an array of coordinates with coordinates.

But isn’t it effectively the same with “labels”? You can have an array of labels for plotting/drawing/printing/whatever.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 17, 2022, 9:15pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/58 "2022-08-17T21:15:34Z")

</div>

> [@aplavin](#):
>
> Not sure if dict-related considerations should be taken into account here. The Julia array interface is very stable and is (I hope) unlikely to change, should only be extended when needed. And keys are an integral part of this interface, so their meaning will stay in the array context.

It should only be taken into account because it effects the entire motivation for using the term “keys” as self documenting what it returns.

The most commonly used parts of the array interface are stable but there are aspects that are ill defined or need some light reworking.

> [@aplavin](#):
>
> But isn’t it effectively the same with “labels”? You can have an array of labels for plotting/drawing/printing/whatever

No because the axis labels of labels are both conceptually the same. If you get the axis coordinates of coordinates then you are ascribing two completely different meanings of coordinates. One is this label/key like thing and the other may be referring to real world space.

So my issue with keys is that it’s ambiguous whether it will continue to be as clear of a self documenting syntax. My issue with coordinates is that at its best it is interpreted as the computational index positions when it’s already used to refer to real world coordinate systems. The meaning of a label for the x axis and labels along the x axis aren’t semantically different or very confusing. Its slightly less specific than what some people have in mind than keys but that is good to some and bad to others.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 20, 2022, 9:01pm UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/59 "2022-08-20T21:01:36Z")

</div>

@aplavin did I address your concerns here

---

<div class="post-metadata">

**Author:** ![blackeneth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blackeneth/32/10353_2.png) [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Post date:** [August 21, 2022, 1:25am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/60 "2022-08-21T01:25:06Z")

</div>

Now for something completely different.

From an ontological perspective, what you are specifying for an axis is its **domain** — the valid set that can be used for that axis.

How we describe those items in the set is typically different based on the context — they could be described as values, labels, levels, ids, types, etc.

So how about `axisdomain()` ?

This naming could also let you throw a descriptive error like “index is not in axis domain.”

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [August 21, 2022, 2:11am UTC](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988/61 "2022-08-21T02:11:47Z")

</div>

Wouldn’t the axis be the domain (possibly the dimension name) and what we are discussing would be the contents within a domain along the axis?

[Previous page](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988.md?page=2)

[Next page](https://discourse.julialang.org/t/commit-to-a-common-syntax-for-accessing-additional-index-mapping-information-on-axes/84988.md?page=4)
