Open nalimilan opened 6 years ago
Do we need it in Base at all? Seems like there are no uses, only definitions, which suggest to me that it would make a good stdlib package.
Probably, but what package? Something were we'd also put lag
and lead
?
Initially, it could just be stdlib/CircularShifts
or something. Could later be rolled into a more general package for utility views into arrays.
We could try to find a slightly more general name from the start to avoid renaming it if possible. lag
and lead
are not "circular" for example. LazyArrays? ArrayTools?
For me this seem to belong to a module that groups: Array slicing, Array reshaping, Array transpose. Its not super necessary that circshift
sits in base. But discoverability is IMHO pretty important.
Slicing, reshaping and transpose are really basic features, I'm not sure we want to move them to stdlib...
If we're talking about slicing JuliennedArrays.jl
does slicing much faster than mapslices in Base and also is much more flexible.
JuliennedArrays
is the best-named package.
be still my heart
We can probably punt on this for 1.0.
That's clearly not a big issue, but if we want to deprecate the functions something will have to be done before 1.0 (either a deprecation or moving them to stdlib).
This can be a vestigial API at some point in the future when a lovely, complete lazy package exists.
Implemented in the ShiftedArrays package, together with lag
and lead
. The two new AbstractArray types are ShiftedArray
(meaning: you get missing
if you are out of bounds) for lag
and lead
and CircShiftedArray
(meaning, you restart from the other extreme) for circshift
.
I guess the question now is what do we want the relationship between this Base function and the ShiftedArrays package to be? Should we consider deprecating it entirely and pointing people at the package instead? Or should we retain this as a way of doing eager array shifting?
This came up in a Slack discussion about adding
lag
andlead
functions, which are similar tocircshift
. In many cases, allocating a vector to store the result ofcircshift
is a waste, as a lazy view would be sufficient and as efficient. Looking at uses ofcircshift
on GitHub shows several examples where the result is discarded immediately.It would make sense to have
Iterators.circshift
, returning a customAbstractArray
object which would redirectgetindex
calls to the parent after shifting the index.circshift!(dest, src, shift)
would be replaced withcopy!(dest, Iterators.circshift(src, shift))
.