Deprecate shift() in favor of circshift()?

The two functions shift() and circshift() both perform circular shifts on a vector or matrix. They have very similar calling conventions. One difference is that circshift is a Matlab-compatible name while shift is not. It appears that shift has been in the Octave codebase for at least a decade. My guess is that Matlab used to have the function under this name but has since renamed it for clarity.

Any objections to deprecating this function in Octave 8 and removing in Octave 10?

1 Like

None here. There are probably a few other similar items. Repelems vs repelem, sums vs sumsqr, etc. what’s the general policy on keeping duplicative functions in excess of what Matlab does? is there any particular advantage to shift to make it worth keeping around? e.g, I know for the subset of what it does repelems can be much faster than repelem. And I think sumsq is a compiled function, so also much faster.

Nope, both shift and circshift are m-files so they have equivalent performance (fast because it just uses indexing). We keep some aliases around in Octave such as inverse for inv or lgamma for gammaln. In those cases, however, the name is truly just an alias and there is no change in functionality. Occasionally Matlab “borrows” Octave functionality but implements a different API. In that case, we have to make the function use the new API and the old function is prefixed with an ‘o’ for Octave. The m-file oruntests is an example of that.

In this case, the functionality and API are just a hair’s width away from each other but they are distinct so we can’t make one an alias for the other nor are they so different that we need an entirely new function.

I went ahead and deprecated shift on the development branch in this cset: octave: 397d29f7135c.

2 Likes