Skip to content

Commit

Permalink
Simplify initial index labels PR
Browse files Browse the repository at this point in the history
* removed support for nested traversal of `index_labels`. Support for
  this can be added later but it required making a lot of decisions
  about managing labels that up front that would be better addressed
  through iterative PRs
* removed `has_index_labels`. There are some odd corner cases for this
  one. Particularly for `SubArrays` where the presence of labels in the
  parent don't always have a clear way of propagating forward. Again,
  we can address this one but it will take some decisions about how
  labels are propagated.
* `UnlabelledIndices` and `LabelledIndices` are types that provide a
  more clear structure to what a label is and how they are accessed. For
  now access only is supported through `getlabels` and `setlabels`
  • Loading branch information
Tokazama committed Sep 29, 2022
1 parent d7c0a27 commit 809839b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ Base.last(x::LabelledIndices) = lastindex(parent(x))
"""
getlabels(x, idx)
Given a collection of labelled indices (`x`), the subset of lablled indices corresponding
to the index `idx` are returned.
Given a collection of labelled indices (`x`), returns the subset of lablled indices
corresponding to the index `idx` are returned.
"""
Base.@propagate_inbounds function getlabels(x::LabelledIndices, idx::I) where {I}
ndims_shape(I) === 0 ? parent(x)[idx] : LabelledIndices(parent(x)[idx])
Expand All @@ -733,8 +733,7 @@ end
"""
setlabels!(x, idx, vals)
Given a collection of labelled indices (`x`), the subset of lablled indices corresponding
to the index `idx` are returned.
Sets new labels `vals` at the indices `idx` for the collection of labelled indices `x`.
"""
Base.@propagate_inbounds setlabels!(x::LabelledIndices, i, v) = setindex!(parent(x), i, v)

Expand Down

0 comments on commit 809839b

Please sign in to comment.