From 809839b6f033cd994ec03effc1de7e18bceeb550 Mon Sep 17 00:00:00 2001 From: "Zachary P. Christensen" Date: Thu, 29 Sep 2022 05:03:40 -0400 Subject: [PATCH] Simplify initial index labels PR * 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` --- lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl b/lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl index bcdd82f9d..e286446fb 100644 --- a/lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl +++ b/lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl @@ -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]) @@ -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)