Skip to content

Fix cylinder snake patterns indexing a lazy iterator#81

Open
SAY-5 wants to merge 1 commit into
QuantumKitHub:mainfrom
SAY-5:fix-cylinder-snake-patterns
Open

Fix cylinder snake patterns indexing a lazy iterator#81
SAY-5 wants to merge 1 commit into
QuantumKitHub:mainfrom
SAY-5:fix-cylinder-snake-patterns

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 17, 2026

Copy link
Copy Markdown

Fixes #80.

backandforth_pattern and frontandback_pattern build their index list with Iterators.flatten(...) and then return a closure that indexes into it. Base.Iterators.Flatten supports iteration but has no getindex, so calling the pattern (e.g. via linearize_index) throws MethodError: no method matching getindex(::Base.Iterators.Flatten{…}, ::Int64). Collecting the iterator before indexing resolves it.

In frontandback_pattern the even-L branch also used edge = L / 2, which is a Float64 and makes 1:edge a float range; switched both branches to integer division so the ranges stay integer-typed.

Added a testset that calls the helpers on an InfiniteCylinder and checks the result over one unit cell is a permutation of 1:L*N.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backandforth_pattern/frontandback_pattern error, and SnakePattern needs periodic wrap on infinite lattices

1 participant