Closed rafaqz closed 8 months ago
We could actually define DimSlices
so the Slices
object still has dimensions. It could then also hold DimStack
.
This is basically RasterSeries
in Rasters.jl, it already does this with the slice
method.
I wonder though if we might run into problems of eachslice
doesn't return a Slices
wrapped in an AbstractDimArray
. In principle, base methods in the future might specialize on Slices
, and if our generic implementations already forward that function to the underlying Slices
, then we would hit these specialized methods. But if we define our own DimSlices
object, then we wouldn't hit that.
Have you run into instances where eachslice
for AbstractDimStack
returning an iterator is inconvenient? Product
is nice in that it is an iterator with a size
that collects or maps to an array.
Ahh good point. AbstractSlices
could be useful then.
The inconvenience is having to collect the generator to index, but not having to collect Slices
. So the most efficient code is not generic for both arrays and stacks. Slices
is also an Abstact array so you can wrap it with a DimArray
.
I have some if blocks for this in Rasters.jl.
DimSlices
is now implemented and used for AbstractDimStack
in eachslice
, as well as being how groupby
works underneath.
@sethaxen I just noticed on 1.9 now we have a
Slices <: AbstractArray
object returned from arrays, but a generator returned for stacks - so we have to special case them a little.Could we add a
StackSlices
object, or something? I'm not sure it makes sense but thought I would make a note.