|
201 | 201 | @test allunique(NNN) |
202 | 202 | end |
203 | 203 | end |
| 204 | + |
| 205 | +@testset "SnakePattern" begin |
| 206 | + base_lattice = FiniteCylinder(4, 16) |
| 207 | + base_V = vertices(base_lattice) |
| 208 | + base_NN = nearest_neighbours(base_lattice) |
| 209 | + |
| 210 | + lattice = SnakePattern(base_lattice, identity) |
| 211 | + |
| 212 | + V = vertices(lattice) |
| 213 | + @test all(zip(V, base_V)) do (x, y) |
| 214 | + return linearize_index(x) == linearize_index(y) |
| 215 | + end |
| 216 | + |
| 217 | + @test length(base_lattice) == length(lattice) |
| 218 | + @test lattice[1, 1] == first(V) |
| 219 | + |
| 220 | + NN = nearest_neighbours(lattice) |
| 221 | + @test all(zip(NN, base_NN)) do (x, y) |
| 222 | + return linearize_index.(Tuple(x)) == |
| 223 | + linearize_index.(Tuple(y)) |
| 224 | + end |
| 225 | + |
| 226 | + pattern(i) = length(lattice) - i + 1 |
| 227 | + lattice = SnakePattern(base_lattice, pattern) |
| 228 | + |
| 229 | + V = vertices(lattice) |
| 230 | + @test all(zip(V, base_V)) do (x, y) |
| 231 | + return linearize_index(x) == pattern(linearize_index(y)) |
| 232 | + end |
| 233 | + |
| 234 | + @test length(base_lattice) == length(lattice) |
| 235 | + @test lattice[1, 1] == first(V) |
| 236 | + |
| 237 | + base_NN = nearest_neighbours(base_lattice) |
| 238 | + NN = nearest_neighbours(lattice) |
| 239 | + @test all(zip(NN, base_NN)) do (x, y) |
| 240 | + return linearize_index.(Tuple(x)) == |
| 241 | + pattern.(linearize_index.(Tuple(y))) |
| 242 | + end |
| 243 | +end |
0 commit comments