DimensionalData.jl icon indicating copy to clipboard operation
DimensionalData.jl copied to clipboard

`mapslices` on `DimStack`

Open haakon-e opened this issue 1 year ago • 3 comments

It would be cool if you could do something like

# Setup
x, y = X(1:3), Y(10:13)
P = ones(x,y, name="P")
sp = ones(x, name="sp")
stack = DimStack(P,sp)

# new code
mapslices(stack, dims=X) do x
    # some calculation

    # assign output to each layer with some reasonable syntax
    (; sp = out1, P = out2)
end

the motivation for this is that I have some expensive function that operates on slices on some data I have, but the function outputs both a vector and a scalar (think eigenvalue/eigenvector pair), and it would be neat to apply a map-like method to assign the output to each layer.

haakon-e avatar Jun 25 '24 17:06 haakon-e