You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -33,6 +33,16 @@ The slices must all have the same `size`, but they (and the container)
33
33
can have any number of dimensions. `stack` always places the slice dimensions first.
34
34
There are no options.
35
35
36
+
### Ragged stack
37
+
38
+
There is also a version which does not demand that slices have equal `size` (or equal `ndims`),
39
+
which always returns a new `Array`. You can control the position of slices `using OffsetArrays`:
40
+
41
+
```julia
42
+
rstack([1:n for n in1:10]) # upper triangular Matrix{Int}
43
+
rstack(OffsetArray(fill(n,4), rand(-2:2)) for n in1:10; fill=NaN)
44
+
```
45
+
36
46
### Other packages
37
47
38
48
This one plays well with [OffsetArrays.jl](https://github.com/JuliaArrays/OffsetArrays.jl),
@@ -47,3 +57,5 @@ Besides which, there are several other ways to achieve similar things:
47
57
* For a generator of arrays, the built-in `reduce(hcat,...)` may work, but it slow compared to `stack`: see [test/speed.jl](test/speed.jl) for some examples.
48
58
49
59
The package [ArraysOfArrays.jl](https://oschulz.github.io/ArraysOfArrays.jl/stable/#section_ArrayOfSimilarArrays-1) solves the opposite problem, of accessing one large array as if it were many slices. As does [`JuliennedArrays.Slices`](https://bramtayl.github.io/JuliennedArrays.jl/latest/#JuliennedArrays.Slices-Union{Tuple{NumberOfDimensions},%20Tuple{Item},%20Tuple{AbstractArray{Item,NumberOfDimensions},Vararg{Int64,N}%20where%20N}}%20where%20NumberOfDimensions%20where%20Item), and of course [`Base.eachslice`](https://docs.julialang.org/en/v1/base/arrays/#Base.eachslice).
60
+
61
+
Finally, after writing this I learned of [julia/31644](https://github.com/JuliaLang/julia/pull/31644) which extends `reduce(hcat,...)` to work on generators.
0 commit comments