Skip to content

Map function to slices with index labels #158

@Lincoln-Hannah

Description

@Lincoln-Hannah

Ability to map a function to slices of a KeyedArray including the dimension index names of each slice.
Proposed syntax below passes the slice and index names as a named tuple.

function my_func(  (; slice, I, X )  )

    "$I  $X    $(slice(:a))"

end

K  =   KeyedArray(   [1;2;;3;4;;;5;6;;7;8],   A=[:a,:b],   I=[:i,:j],   X=[:x,:y]   )



# proposed syntax
mapslices( my_func,  K;   dims=(:A) )

#would give the same result as 
@tullio Z[i,x] := my_func( (; slice=K[:,i,x], I=K.I[i], X=K.X[x])  )
KeyedArray( Z, I=K.I, X=K.X)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions