ANN: LazyStack, SliceMap, StarSlice

I have a few small packages for dealing with arrays of arrays, and similar things, which perhaps deserve announcement here:

  • LazyStack.jl has one function stack which glues an array of arrays into one big one. It is also happy to take a generator, like stack(f(x) for x in eachslice(A)), or a function to map over slices, like stack(f, eachcol(x), eachcol(y)), in which case it writes into a new array, widening the type if necessary. The slices must all be the same size, and are stacked along new dimension(s).

There is also a ragged variant rstack, which makes enough space for the largest slice. You can use OffsetArrays to control their positions.

  • SliceMap.jl is much narrower, aiming to provide a fast, differentiable, version of mapslices, primarily for columns of a matrix. There are various versions of this, some with static-array slices, and some which run multi-threaded. (By differentiable I mean that it defines gradients for Tracker & Zygote.)

  • StarSlice.jl is an experiment with notation for slicing, which overloads A[:,*] to mean collect.(eachcol(A)), and variants of that. Perhaps useful for mapslices type things, and perhaps as a way to write reductions. (This is not yet registered.)

6 Likes

I really like the idea of testing out using these operators within standard indexing notation. It’s a nice way to avoid burdening users with more syntax but avoids interfering with anywhere else they would be used. Nice work!

1 Like