feat: implement Base.circshift and Base.circshift!#8
Merged
AFeuerpfeil merged 1 commit intomainfrom Apr 1, 2026
Merged
Conversation
Adds circshift (non-mutating), circshift! (in-place 2-arg), and
circshift! (3-arg dest/src) for PeriodicArray.
The implementation materializes the new unit cell by evaluating
src[k - s] for each index k, correctly applying the map (e.g. Bloch
phase factors) for elements that wrap across cell boundaries. This
requires the map to satisfy the group action property
map(map(x, a), b) == map(x, a+b), consistent with the existing
reverse and repeat implementations.
Also fixes a linter-introduced regression where Vararg{Int, N} was
widened to Vararg{Integer, N} in getindex/setindex!, which had
reintroduced method ambiguities detected by Aqua.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
circshift(arr, shifts),circshift!(arr, shifts)(in-place), andcircshift!(dest, src, shifts)forPeriodicArraysrc[k - s]for each indexk, correctly applying the boundary map (e.g. Bloch phase factors) for elements that wrap across cell boundaries — unlike a naivecircshift(parent(arr), shifts)which would ignore the map at the seamBase(verified by Aqua)Vararg{Int, N}was widened toVararg{Integer, N}ingetindex/setindex!, which had reintroduced 4 method ambiguitiesTest plan
circshift(a, s)[i] == a[i - s]for all integersi, verified across many shifts (including wrapping cases) for both identity and non-trivial mapscircshift(a, 1)[1] == a[0] == f(data[end], -1)is correctly computed with the map appliedparent(circshift(circshift(a, s), -s)) == parent(a)for all shift valuescircshift!(dest, src, shifts)(3-arg) andcircshift!(arr, shifts)(in-place) both tested🤖 Generated with Claude Code