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

`selectdim` for DimStack

Open Beforerr opened this issue 5 months ago • 4 comments

da = rand(X(1:10), Y(1:10))
ds = DimStack((a = da, b = da))
ds[1:3,:] # working
@view ds[1:3,:] # working
selectdim(ds,1,1:3) # not working

Maybe it would be nice to make selectdim work?

Beforerr avatar Jun 14 '25 15:06 Beforerr

I guess it should also work with dimensions for Dim, and selectors as the last argument.

rafaqz avatar Jun 15 '25 04:06 rafaqz

But also, what do you use this for? isn't it more concise to do ds[X=1:3] ?

rafaqz avatar Jun 15 '25 05:06 rafaqz

Yes, ds[X=1:3] is more concise and better if we know ds isa DimStack.

My use case is that I have generic code do selectdim on array-like objects. Since DimStack is kinda of like an array, having selectdim work would simplify the logic and codes.

Beforerr avatar Jun 16 '25 07:06 Beforerr

Makes total sense. Try a PR if you are up for it, I am very short on time currently.

rafaqz avatar Jun 16 '25 08:06 rafaqz